writeback: kill off ->range_cycle option wb-next
authorJens Axboe <axboe@kernel.dk>
Wed, 27 Sep 2017 19:50:50 +0000 (13:50 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 28 Sep 2017 08:00:22 +0000 (02:00 -0600)
All types of writeback are now range cyclic. Kill off the member
from struct wb_writeback_work and struct writeback_control.

Remove the various checks for whether or not this is range cyclic
writeback or not in the writeback code and file systems.

For tracing, we leave the member there, and just always set it to 1.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
15 files changed:
drivers/staging/lustre/lustre/llite/rw.c
fs/afs/write.c
fs/btrfs/extent_io.c
fs/ceph/addr.c
fs/cifs/file.c
fs/ext4/inode.c
fs/f2fs/data.c
fs/fs-writeback.c
fs/gfs2/aops.c
include/linux/writeback.h
include/trace/events/btrfs.h
include/trace/events/ext4.h
include/trace/events/f2fs.h
include/trace/events/writeback.h
mm/page-writeback.c

index e72090572bcc210fbcb5b248abaad14797e1703b..d5960dd204050f0c60e7d43035e56e62937fc6d1 100644 (file)
@@ -1002,18 +1002,8 @@ int ll_writepages(struct address_space *mapping, struct writeback_control *wbc)
        int result;
        int ignore_layout = 0;
 
-       if (wbc->range_cyclic) {
-               start = mapping->writeback_index << PAGE_SHIFT;
-               end = OBD_OBJECT_EOF;
-       } else {
-               start = wbc->range_start;
-               end = wbc->range_end;
-               if (end == LLONG_MAX) {
-                       end = OBD_OBJECT_EOF;
-                       range_whole = start == 0;
-               }
-       }
-
+       start = mapping->writeback_index << PAGE_SHIFT;
+       end = OBD_OBJECT_EOF;
        mode = CL_FSYNC_NONE;
        if (wbc->sync_mode == WB_SYNC_ALL)
                mode = CL_FSYNC_LOCAL;
@@ -1034,12 +1024,11 @@ int ll_writepages(struct address_space *mapping, struct writeback_control *wbc)
                result = 0;
        }
 
-       if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) {
-               if (end == OBD_OBJECT_EOF)
-                       mapping->writeback_index = 0;
-               else
-                       mapping->writeback_index = (end >> PAGE_SHIFT) + 1;
-       }
+       if (end == OBD_OBJECT_EOF)
+               mapping->writeback_index = 0;
+       else
+               mapping->writeback_index = (end >> PAGE_SHIFT) + 1;
+
        return result;
 }
 
index 106e43db11153fc1faed12ab326e25d4a9dc3c7d..2e21c197173fd872a32dadfebd596d7f721e70b6 100644 (file)
@@ -570,24 +570,12 @@ int afs_writepages(struct address_space *mapping,
 
        _enter("");
 
-       if (wbc->range_cyclic) {
-               start = mapping->writeback_index;
-               end = -1;
-               ret = afs_writepages_region(mapping, wbc, start, end, &next);
-               if (start > 0 && wbc->nr_to_write > 0 && ret == 0)
-                       ret = afs_writepages_region(mapping, wbc, 0, start,
-                                                   &next);
-               mapping->writeback_index = next;
-       } else if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) {
-               end = (pgoff_t)(LLONG_MAX >> PAGE_SHIFT);
-               ret = afs_writepages_region(mapping, wbc, 0, end, &next);
-               if (wbc->nr_to_write > 0)
-                       mapping->writeback_index = next;
-       } else {
-               start = wbc->range_start >> PAGE_SHIFT;
-               end = wbc->range_end >> PAGE_SHIFT;
-               ret = afs_writepages_region(mapping, wbc, start, end, &next);
-       }
+       start = mapping->writeback_index;
+       end = -1;
+       ret = afs_writepages_region(mapping, wbc, start, end, &next);
+       if (start > 0 && wbc->nr_to_write > 0 && ret == 0)
+               ret = afs_writepages_region(mapping, wbc, 0, start, &next);
+       mapping->writeback_index = next;
 
        _leave(" = %d", ret);
        return ret;
@@ -685,7 +673,6 @@ int afs_writeback_all(struct afs_vnode *vnode)
        struct writeback_control wbc = {
                .sync_mode      = WB_SYNC_ALL,
                .nr_to_write    = LONG_MAX,
-               .range_cyclic   = 1,
        };
        int ret;
 
index 3e5bb0cdd3cdd46dbc92273d370d9593963820e7..5c3bd7d504354cc411916c336ef23c448a3e7fc7 100644 (file)
@@ -3803,14 +3803,8 @@ int btree_write_cache_pages(struct address_space *mapping,
        int tag;
 
        pagevec_init(&pvec, 0);
-       if (wbc->range_cyclic) {
-               index = mapping->writeback_index; /* Start from prev offset */
-               end = -1;
-       } else {
-               index = wbc->range_start >> PAGE_SHIFT;
-               end = wbc->range_end >> PAGE_SHIFT;
-               scanned = 1;
-       }
+       index = mapping->writeback_index; /* Start from prev offset */
+       end = -1;
        if (wbc->sync_mode == WB_SYNC_ALL)
                tag = PAGECACHE_TAG_TOWRITE;
        else
@@ -3830,7 +3824,7 @@ retry:
                        if (!PagePrivate(page))
                                continue;
 
-                       if (!wbc->range_cyclic && page->index > end) {
+                       if (page->index > end) {
                                done = 1;
                                break;
                        }
@@ -3930,7 +3924,6 @@ static int extent_write_cache_pages(struct address_space *mapping,
        pgoff_t index;
        pgoff_t end;            /* Inclusive */
        pgoff_t done_index;
-       int range_whole = 0;
        int scanned = 0;
        int tag;
 
@@ -3947,16 +3940,8 @@ static int extent_write_cache_pages(struct address_space *mapping,
                return 0;
 
        pagevec_init(&pvec, 0);
-       if (wbc->range_cyclic) {
-               index = mapping->writeback_index; /* Start from prev offset */
-               end = -1;
-       } else {
-               index = wbc->range_start >> PAGE_SHIFT;
-               end = wbc->range_end >> PAGE_SHIFT;
-               if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
-                       range_whole = 1;
-               scanned = 1;
-       }
+       index = mapping->writeback_index; /* Start from prev offset */
+       end = -1;
        if (wbc->sync_mode == WB_SYNC_ALL)
                tag = PAGECACHE_TAG_TOWRITE;
        else
@@ -3992,7 +3977,7 @@ retry:
                                continue;
                        }
 
-                       if (!wbc->range_cyclic && page->index > end) {
+                       if (page->index > end) {
                                done = 1;
                                unlock_page(page);
                                continue;
@@ -4051,9 +4036,7 @@ retry:
                goto retry;
        }
 
-       if (wbc->range_cyclic || (wbc->nr_to_write > 0 && range_whole))
-               mapping->writeback_index = done_index;
-
+       mapping->writeback_index = done_index;
        btrfs_add_delayed_iput(inode);
        return ret;
 }
index b3e3edc09d80382c72a1d2d42515ad67ea51bdb3..5aa5a901c4481cfaba7d3863f7ee610fcd15bc93 100644 (file)
@@ -791,7 +791,7 @@ static int ceph_writepages_start(struct address_space *mapping,
        unsigned int wsize = i_blocksize(inode);
        struct ceph_osd_request *req = NULL;
        struct ceph_writeback_ctl ceph_wbc;
-       bool should_loop, range_whole = false;
+       bool should_loop;
        bool stop, done = false;
 
        dout("writepages_start %p (mode=%s)\n", inode,
@@ -812,7 +812,7 @@ static int ceph_writepages_start(struct address_space *mapping,
 
        pagevec_init(&pvec, 0);
 
-       start_index = wbc->range_cyclic ? mapping->writeback_index : 0;
+       start_index = mapping->writeback_index;
        index = start_index;
 
 retry:
@@ -830,19 +830,11 @@ retry:
        should_loop = false;
        if (ceph_wbc.head_snapc && snapc != last_snapc) {
                /* where to start/end? */
-               if (wbc->range_cyclic) {
-                       index = start_index;
-                       end = -1;
-                       if (index > 0)
-                               should_loop = true;
-                       dout(" cyclic, start at %lu\n", index);
-               } else {
-                       index = wbc->range_start >> PAGE_SHIFT;
-                       end = wbc->range_end >> PAGE_SHIFT;
-                       if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
-                               range_whole = true;
-                       dout(" not cyclic, %lu to %lu\n", index, end);
-               }
+               index = start_index;
+               end = -1;
+               if (index > 0)
+                       should_loop = true;
+               dout(" cyclic, start at %lu\n", index);
        } else if (!ceph_wbc.head_snapc) {
                /* Do not respect wbc->range_{start,end}. Dirty pages
                 * in that range can be associated with newer snapc.
@@ -1194,9 +1186,7 @@ release_pvec_pages:
                goto retry;
        }
 
-       if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
-               mapping->writeback_index = index;
-
+       mapping->writeback_index = index;
 out:
        ceph_osdc_put_request(req);
        ceph_put_snap_context(last_snapc);
index 92fdf9c35de2153fd6f008c4d1306ead6d806c89..98498afc3f87064693582606d7f8766c9035ab7d 100644 (file)
@@ -2021,7 +2021,7 @@ wdata_prepare_pages(struct cifs_writedata *wdata, unsigned int found_pages,
                        break;
                }
 
-               if (!wbc->range_cyclic && page->index > end) {
+               if (page->index > end) {
                        *done = true;
                        unlock_page(page);
                        break;
@@ -2112,7 +2112,7 @@ static int cifs_writepages(struct address_space *mapping,
 {
        struct cifs_sb_info *cifs_sb = CIFS_SB(mapping->host->i_sb);
        struct TCP_Server_Info *server;
-       bool done = false, scanned = false, range_whole = false;
+       bool done = false, scanned = false;
        pgoff_t end, index;
        struct cifs_writedata *wdata;
        int rc = 0;
@@ -2124,16 +2124,8 @@ static int cifs_writepages(struct address_space *mapping,
        if (cifs_sb->wsize < PAGE_SIZE)
                return generic_writepages(mapping, wbc);
 
-       if (wbc->range_cyclic) {
-               index = mapping->writeback_index; /* Start from prev offset */
-               end = -1;
-       } else {
-               index = wbc->range_start >> PAGE_SHIFT;
-               end = wbc->range_end >> PAGE_SHIFT;
-               if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
-                       range_whole = true;
-               scanned = true;
-       }
+       index = mapping->writeback_index; /* Start from prev offset */
+       end = -1;
        server = cifs_sb_master_tcon(cifs_sb)->ses->server;
 retry:
        while (!done && index <= end) {
@@ -2214,9 +2206,7 @@ retry:
                goto retry;
        }
 
-       if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
-               mapping->writeback_index = index;
-
+       mapping->writeback_index = index;
        return rc;
 }
 
index 31db875bc7a13dde67b9a6b17ce498b4c16bd17f..f33f700b110c80188187fba5dc94795e22f4d4bb 100644 (file)
@@ -2792,16 +2792,11 @@ static int ext4_writepages(struct address_space *mapping,
        if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
                range_whole = 1;
 
-       if (wbc->range_cyclic) {
-               writeback_index = mapping->writeback_index;
-               if (writeback_index)
-                       cycled = 0;
-               mpd.first_page = writeback_index;
-               mpd.last_page = -1;
-       } else {
-               mpd.first_page = wbc->range_start >> PAGE_SHIFT;
-               mpd.last_page = wbc->range_end >> PAGE_SHIFT;
-       }
+       writeback_index = mapping->writeback_index;
+       if (writeback_index)
+               cycled = 0;
+       mpd.first_page = writeback_index;
+       mpd.last_page = -1;
 
        mpd.inode = inode;
        mpd.wbc = wbc;
@@ -2940,12 +2935,11 @@ unplug:
        }
 
        /* Update index */
-       if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
-               /*
-                * Set the writeback_index so that range_cyclic
-                * mode will write it back later
-                */
-               mapping->writeback_index = mpd.first_page;
+       /*
+        * Set the writeback_index so that range_cyclic
+        * mode will write it back later
+        */
+       mapping->writeback_index = mpd.first_page;
 
 out_writepages:
        trace_ext4_writepages_result(inode, wbc, ret,
index 36b535207c88906efae946f71195781497be87f5..05edac5fdf2e26eb4fa9efb3529b939586e6214d 100644 (file)
@@ -1632,7 +1632,6 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
        pgoff_t done_index;
        pgoff_t last_idx = ULONG_MAX;
        int cycled;
-       int range_whole = 0;
        int tag;
 
        pagevec_init(&pvec, 0);
@@ -1643,21 +1642,13 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
        else
                clear_inode_flag(mapping->host, FI_HOT_DATA);
 
-       if (wbc->range_cyclic) {
-               writeback_index = mapping->writeback_index; /* prev offset */
-               index = writeback_index;
-               if (index == 0)
-                       cycled = 1;
-               else
-                       cycled = 0;
-               end = -1;
-       } else {
-               index = wbc->range_start >> PAGE_SHIFT;
-               end = wbc->range_end >> PAGE_SHIFT;
-               if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
-                       range_whole = 1;
-               cycled = 1; /* ignore range_cyclic tests */
-       }
+       writeback_index = mapping->writeback_index; /* prev offset */
+       index = writeback_index;
+       if (index == 0)
+               cycled = 1;
+       else
+               cycled = 0;
+       end = -1;
        if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
                tag = PAGECACHE_TAG_TOWRITE;
        else
@@ -1755,8 +1746,7 @@ continue_unlock:
                end = writeback_index - 1;
                goto retry;
        }
-       if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
-               mapping->writeback_index = done_index;
+       mapping->writeback_index = done_index;
 
        if (last_idx != ULONG_MAX)
                f2fs_submit_merged_write_cond(F2FS_M_SB(mapping), mapping->host,
index 686d510e618c4f0dff630b63047f8cce6764a3c6..65bbc627addfc10fc24b6fa374a131550f18e947 100644 (file)
@@ -49,7 +49,6 @@ struct wb_writeback_work {
        enum writeback_sync_modes sync_mode;
        unsigned int tagged_writepages:1;
        unsigned int for_kupdate:1;
-       unsigned int range_cyclic:1;
        unsigned int for_background:1;
        unsigned int for_sync:1;        /* sync(2) WB_SYNC_ALL writeback */
        unsigned int auto_free:1;       /* free on completion */
@@ -945,8 +944,7 @@ static unsigned long get_nr_dirty_pages(void)
                get_nr_dirty_inodes();
 }
 
-static void wb_start_writeback(struct bdi_writeback *wb, bool range_cyclic,
-                              enum wb_reason reason)
+static void wb_start_writeback(struct bdi_writeback *wb, enum wb_reason reason)
 {
        struct wb_writeback_work *work;
 
@@ -982,7 +980,6 @@ static void wb_start_writeback(struct bdi_writeback *wb, bool range_cyclic,
 
        work->sync_mode = WB_SYNC_NONE;
        work->nr_pages  = wb_split_bdi_pages(wb, get_nr_dirty_pages());
-       work->range_cyclic = range_cyclic;
        work->reason    = reason;
        work->auto_free = 1;
        work->start_all = 1;
@@ -1526,7 +1523,6 @@ static long writeback_sb_inodes(struct super_block *sb,
                .for_kupdate            = work->for_kupdate,
                .for_background         = work->for_background,
                .for_sync               = work->for_sync,
-               .range_cyclic           = work->range_cyclic,
                .range_start            = 0,
                .range_end              = LLONG_MAX,
        };
@@ -1698,7 +1694,6 @@ static long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages,
        struct wb_writeback_work work = {
                .nr_pages       = nr_pages,
                .sync_mode      = WB_SYNC_NONE,
-               .range_cyclic   = 1,
                .reason         = reason,
        };
        struct blk_plug plug;
@@ -1858,7 +1853,6 @@ static long wb_check_background_flush(struct bdi_writeback *wb)
                        .nr_pages       = LONG_MAX,
                        .sync_mode      = WB_SYNC_NONE,
                        .for_background = 1,
-                       .range_cyclic   = 1,
                        .reason         = WB_REASON_BACKGROUND,
                };
 
@@ -1892,7 +1886,6 @@ static long wb_check_old_data_flush(struct bdi_writeback *wb)
                        .nr_pages       = nr_pages,
                        .sync_mode      = WB_SYNC_NONE,
                        .for_kupdate    = 1,
-                       .range_cyclic   = 1,
                        .reason         = WB_REASON_PERIODIC,
                };
 
@@ -1984,7 +1977,7 @@ static void __wakeup_flusher_threads_bdi(struct backing_dev_info *bdi,
                return;
 
        list_for_each_entry_rcu(wb, &bdi->wb_list, bdi_node)
-               wb_start_writeback(wb, true, reason);
+               wb_start_writeback(wb, reason);
 }
 
 void wakeup_flusher_threads_bdi(struct backing_dev_info *bdi,
@@ -2428,7 +2421,6 @@ void sync_inodes_sb(struct super_block *sb)
                .sb             = sb,
                .sync_mode      = WB_SYNC_ALL,
                .nr_pages       = LONG_MAX,
-               .range_cyclic   = 1,
                .done           = &done,
                .reason         = WB_REASON_SYNC,
                .for_sync       = 1,
index 68ed069625370fa821de91b058c4c9d229db3a89..4e9d86dd741346057c198828119d304e47e2cb0c 100644 (file)
@@ -384,25 +384,16 @@ static int gfs2_write_cache_jdata(struct address_space *mapping,
        pgoff_t end;
        pgoff_t done_index;
        int cycled;
-       int range_whole = 0;
        int tag;
 
        pagevec_init(&pvec, 0);
-       if (wbc->range_cyclic) {
-               writeback_index = mapping->writeback_index; /* prev offset */
-               index = writeback_index;
-               if (index == 0)
-                       cycled = 1;
-               else
-                       cycled = 0;
-               end = -1;
-       } else {
-               index = wbc->range_start >> PAGE_SHIFT;
-               end = wbc->range_end >> PAGE_SHIFT;
-               if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
-                       range_whole = 1;
-               cycled = 1; /* ignore range_cyclic tests */
-       }
+       writeback_index = mapping->writeback_index; /* prev offset */
+       index = writeback_index;
+       if (index == 0)
+               cycled = 1;
+       else
+               cycled = 0;
+       end = -1;
        if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
                tag = PAGECACHE_TAG_TOWRITE;
        else
@@ -439,9 +430,7 @@ retry:
                goto retry;
        }
 
-       if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
-               mapping->writeback_index = done_index;
-
+       mapping->writeback_index = done_index;
        return ret;
 }
 
index 9c0091678af487d417ec0614dbe44765f762a31e..52319fbf300f19b752bd33dbaeeab9d7d059ab55 100644 (file)
@@ -87,7 +87,6 @@ struct writeback_control {
        unsigned for_background:1;      /* A background writeback */
        unsigned tagged_writepages:1;   /* tag-and-write to avoid livelock */
        unsigned for_reclaim:1;         /* Invoked from the page allocator */
-       unsigned range_cyclic:1;        /* range_start is cyclic */
        unsigned for_sync:1;            /* sync(2) WB_SYNC_ALL writeback */
 #ifdef CONFIG_CGROUP_WRITEBACK
        struct bdi_writeback *wb;       /* wb this writeback is issued under */
index dc1d0df91e0b0ee193f6c0b58184fb1272cf1c70..734349288fec315c400c9cbd611bd1e97ebc5d32 100644 (file)
@@ -502,7 +502,7 @@ DECLARE_EVENT_CLASS(btrfs__writepage,
                __entry->range_end      = wbc->range_end;
                __entry->for_kupdate    = wbc->for_kupdate;
                __entry->for_reclaim    = wbc->for_reclaim;
-               __entry->range_cyclic   = wbc->range_cyclic;
+               __entry->range_cyclic   = 1;
                __entry->writeback_index = inode->i_mapping->writeback_index;
                __entry->root_objectid  =
                                 BTRFS_I(inode)->root->root_key.objectid;
index 9c3bc3883d2fac1fbd4683d9eb4efbd74282f5c6..e1de610895f1acc17c30c753a7324869ad074b88 100644 (file)
@@ -394,7 +394,7 @@ TRACE_EVENT(ext4_writepages,
                __entry->writeback_index = inode->i_mapping->writeback_index;
                __entry->sync_mode      = wbc->sync_mode;
                __entry->for_kupdate    = wbc->for_kupdate;
-               __entry->range_cyclic   = wbc->range_cyclic;
+               __entry->range_cyclic   = 1;
        ),
 
        TP_printk("dev %d,%d ino %lu nr_to_write %ld pages_skipped %ld "
index 5d216f7fb05ae05337dde54bfcb8a4e2dcd2983b..e291e4717bf7d45eb332737c839d9dd17bee4466 100644 (file)
@@ -1174,7 +1174,7 @@ TRACE_EVENT(f2fs_writepages,
                __entry->for_background = wbc->for_background;
                __entry->tagged_writepages      = wbc->tagged_writepages;
                __entry->for_reclaim    = wbc->for_reclaim;
-               __entry->range_cyclic   = wbc->range_cyclic;
+               __entry->range_cyclic   = 1;
                __entry->for_sync       = wbc->for_sync;
        ),
 
index 9b57f014d79d033336d7dc63a00972e5e9535230..22e40e54943f46592cfe8e017016a4f466dcd544 100644 (file)
@@ -225,7 +225,7 @@ DECLARE_EVENT_CLASS(writeback_work_class,
                __entry->sb_dev = work->sb ? work->sb->s_dev : 0;
                __entry->sync_mode = work->sync_mode;
                __entry->for_kupdate = work->for_kupdate;
-               __entry->range_cyclic = work->range_cyclic;
+               __entry->range_cyclic = 1;
                __entry->for_background = work->for_background;
                __entry->reason = work->reason;
                __entry->cgroup_ino = __trace_wb_assign_cgroup(wb);
@@ -328,7 +328,7 @@ DECLARE_EVENT_CLASS(wbc_class,
                __entry->for_kupdate    = wbc->for_kupdate;
                __entry->for_background = wbc->for_background;
                __entry->for_reclaim    = wbc->for_reclaim;
-               __entry->range_cyclic   = wbc->range_cyclic;
+               __entry->range_cyclic   = 1;
                __entry->range_start    = (long)wbc->range_start;
                __entry->range_end      = (long)wbc->range_end;
                __entry->cgroup_ino     = __trace_wbc_assign_cgroup(wbc);
index 8d1fc593bce8f54aceae26fa6c8b1fde73275f2b..507c18eb33faddc521fef8b5af7f45967f07ce31 100644 (file)
@@ -2149,25 +2149,16 @@ int write_cache_pages(struct address_space *mapping,
        pgoff_t end;            /* Inclusive */
        pgoff_t done_index;
        int cycled;
-       int range_whole = 0;
        int tag;
 
        pagevec_init(&pvec, 0);
-       if (wbc->range_cyclic) {
-               writeback_index = mapping->writeback_index; /* prev offset */
-               index = writeback_index;
-               if (index == 0)
-                       cycled = 1;
-               else
-                       cycled = 0;
-               end = -1;
-       } else {
-               index = wbc->range_start >> PAGE_SHIFT;
-               end = wbc->range_end >> PAGE_SHIFT;
-               if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
-                       range_whole = 1;
-               cycled = 1; /* ignore range_cyclic tests */
-       }
+       writeback_index = mapping->writeback_index; /* prev offset */
+       index = writeback_index;
+       if (index == 0)
+               cycled = 1;
+       else
+               cycled = 0;
+       end = -1;
        if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
                tag = PAGECACHE_TAG_TOWRITE;
        else
@@ -2285,9 +2276,7 @@ continue_unlock:
                end = writeback_index - 1;
                goto retry;
        }
-       if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
-               mapping->writeback_index = done_index;
-
+       mapping->writeback_index = done_index;
        return ret;
 }
 EXPORT_SYMBOL(write_cache_pages);