Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 28920
b: refs/heads/master
c: 111ebb6
h: refs/heads/master
v: v3
  • Loading branch information
OGAWA Hirofumi authored and Linus Torvalds committed Jun 23, 2006
1 parent e3ff367 commit c49c235
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 32 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4c91c3648c620003cb7b21b8858f36cd6132e168
refs/heads/master: 111ebb6e6f7bd7de6d722c5848e95621f43700d9
24 changes: 11 additions & 13 deletions trunk/fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1079,9 +1079,9 @@ static int cifs_writepages(struct address_space *mapping,
unsigned int bytes_written;
struct cifs_sb_info *cifs_sb;
int done = 0;
pgoff_t end = -1;
pgoff_t end;
pgoff_t index;
int is_range = 0;
int range_whole = 0;
struct kvec iov[32];
int len;
int n_iov = 0;
Expand Down Expand Up @@ -1122,16 +1122,14 @@ static int cifs_writepages(struct address_space *mapping,
xid = GetXid();

pagevec_init(&pvec, 0);
if (wbc->sync_mode == WB_SYNC_NONE)
if (wbc->range_cyclic) {
index = mapping->writeback_index; /* Start from prev offset */
else {
index = 0;
scanned = 1;
}
if (wbc->start || wbc->end) {
index = wbc->start >> PAGE_CACHE_SHIFT;
end = wbc->end >> PAGE_CACHE_SHIFT;
is_range = 1;
end = -1;
} else {
index = wbc->range_start >> PAGE_CACHE_SHIFT;
end = wbc->range_end >> PAGE_CACHE_SHIFT;
if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
range_whole = 1;
scanned = 1;
}
retry:
Expand Down Expand Up @@ -1167,7 +1165,7 @@ static int cifs_writepages(struct address_space *mapping,
break;
}

if (unlikely(is_range) && (page->index > end)) {
if (!wbc->range_cyclic && page->index > end) {
done = 1;
unlock_page(page);
break;
Expand Down Expand Up @@ -1271,7 +1269,7 @@ static int cifs_writepages(struct address_space *mapping,
index = 0;
goto retry;
}
if (!is_range)
if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
mapping->writeback_index = index;

FreeXid(xid);
Expand Down
4 changes: 4 additions & 0 deletions trunk/fs/fs-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ void sync_inodes_sb(struct super_block *sb, int wait)
{
struct writeback_control wbc = {
.sync_mode = wait ? WB_SYNC_ALL : WB_SYNC_HOLD,
.range_start = 0,
.range_end = LLONG_MAX,
};
unsigned long nr_dirty = read_page_state(nr_dirty);
unsigned long nr_unstable = read_page_state(nr_unstable);
Expand Down Expand Up @@ -559,6 +561,8 @@ int write_inode_now(struct inode *inode, int sync)
struct writeback_control wbc = {
.nr_to_write = LONG_MAX,
.sync_mode = WB_SYNC_ALL,
.range_start = 0,
.range_end = LLONG_MAX,
};

if (!mapping_cap_writeback_dirty(inode->i_mapping))
Expand Down
22 changes: 10 additions & 12 deletions trunk/fs/mpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,9 @@ mpage_writepages(struct address_space *mapping,
struct pagevec pvec;
int nr_pages;
pgoff_t index;
pgoff_t end = -1; /* Inclusive */
pgoff_t end; /* Inclusive */
int scanned = 0;
int is_range = 0;
int range_whole = 0;

if (wbc->nonblocking && bdi_write_congested(bdi)) {
wbc->encountered_congestion = 1;
Expand All @@ -721,16 +721,14 @@ mpage_writepages(struct address_space *mapping,
writepage = mapping->a_ops->writepage;

pagevec_init(&pvec, 0);
if (wbc->sync_mode == WB_SYNC_NONE) {
if (wbc->range_cyclic) {
index = mapping->writeback_index; /* Start from prev offset */
end = -1;
} else {
index = 0; /* whole-file sweep */
scanned = 1;
}
if (wbc->start || wbc->end) {
index = wbc->start >> PAGE_CACHE_SHIFT;
end = wbc->end >> PAGE_CACHE_SHIFT;
is_range = 1;
index = wbc->range_start >> PAGE_CACHE_SHIFT;
end = wbc->range_end >> PAGE_CACHE_SHIFT;
if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
range_whole = 1;
scanned = 1;
}
retry:
Expand Down Expand Up @@ -759,7 +757,7 @@ mpage_writepages(struct address_space *mapping,
continue;
}

if (unlikely(is_range) && page->index > end) {
if (!wbc->range_cyclic && page->index > end) {
done = 1;
unlock_page(page);
continue;
Expand Down Expand Up @@ -810,7 +808,7 @@ mpage_writepages(struct address_space *mapping,
index = 0;
goto retry;
}
if (!is_range)
if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
mapping->writeback_index = index;
if (bio)
mpage_bio_submit(WRITE, bio);
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ asmlinkage long sys_sync_file_range(int fd, loff_t offset, loff_t nbytes,
}

if (nbytes == 0)
endbyte = -1;
endbyte = LLONG_MAX;
else
endbyte--; /* inclusive */

Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ extern const char linux_banner[];
#define LONG_MAX ((long)(~0UL>>1))
#define LONG_MIN (-LONG_MAX - 1)
#define ULONG_MAX (~0UL)
#define LLONG_MAX ((long long)(~0ULL>>1))
#define LLONG_MIN (-LLONG_MAX - 1)
#define ULLONG_MAX (~0ULL)

#define STACK_MAGIC 0xdeadbeef

Expand Down
5 changes: 3 additions & 2 deletions trunk/include/linux/writeback.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,15 @@ struct writeback_control {
* a hint that the filesystem need only write out the pages inside that
* byterange. The byte at `end' is included in the writeout request.
*/
loff_t start;
loff_t end;
loff_t range_start;
loff_t range_end;

unsigned nonblocking:1; /* Don't get stuck on request queues */
unsigned encountered_congestion:1; /* An output: a queue is full */
unsigned for_kupdate:1; /* A kupdate writeback */
unsigned for_reclaim:1; /* Invoked from the page allocator */
unsigned for_writepages:1; /* This is a writepages() call */
unsigned range_cyclic:1; /* range_start is cyclic */
};

/*
Expand Down
6 changes: 3 additions & 3 deletions trunk/mm/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
struct writeback_control wbc = {
.sync_mode = sync_mode,
.nr_to_write = mapping->nrpages * 2,
.start = start,
.end = end,
.range_start = start,
.range_end = end,
};

if (!mapping_cap_writeback_dirty(mapping))
Expand All @@ -204,7 +204,7 @@ int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
static inline int __filemap_fdatawrite(struct address_space *mapping,
int sync_mode)
{
return __filemap_fdatawrite_range(mapping, 0, 0, sync_mode);
return __filemap_fdatawrite_range(mapping, 0, LLONG_MAX, sync_mode);
}

int filemap_fdatawrite(struct address_space *mapping)
Expand Down
3 changes: 3 additions & 0 deletions trunk/mm/page-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ static void balance_dirty_pages(struct address_space *mapping)
.sync_mode = WB_SYNC_NONE,
.older_than_this = NULL,
.nr_to_write = write_chunk,
.range_cyclic = 1,
};

get_dirty_limits(&wbs, &background_thresh,
Expand Down Expand Up @@ -331,6 +332,7 @@ static void background_writeout(unsigned long _min_pages)
.older_than_this = NULL,
.nr_to_write = 0,
.nonblocking = 1,
.range_cyclic = 1,
};

for ( ; ; ) {
Expand Down Expand Up @@ -407,6 +409,7 @@ static void wb_kupdate(unsigned long arg)
.nr_to_write = 0,
.nonblocking = 1,
.for_kupdate = 1,
.range_cyclic = 1,
};

sync_supers();
Expand Down
2 changes: 2 additions & 0 deletions trunk/mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ pageout_t pageout(struct page *page, struct address_space *mapping)
struct writeback_control wbc = {
.sync_mode = WB_SYNC_NONE,
.nr_to_write = SWAP_CLUSTER_MAX,
.range_start = 0,
.range_end = LLONG_MAX,
.nonblocking = 1,
.for_reclaim = 1,
};
Expand Down

0 comments on commit c49c235

Please sign in to comment.