ceph: remove reliance on bdi congestion
authorNeilBrown <neilb@suse.de>
Tue, 22 Mar 2022 21:39:04 +0000 (14:39 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 Mar 2022 22:57:00 +0000 (15:57 -0700)
The bdi congestion tracking in not widely used and will be removed.

CEPHfs is one of a small number of filesystems that uses it, setting just
the async (write) congestion flags at what it determines are appropriate
times.

The only remaining effect of the async flag is to cause (some)
WB_SYNC_NONE writes to be skipped.

So instead of setting the flag, set an internal flag and change:

 - .writepages to do nothing if WB_SYNC_NONE and the flag is set

 - .writepage to return AOP_WRITEPAGE_ACTIVATE if WB_SYNC_NONE and the
   flag is set.

The writepages change causes a behavioural change in that pageout() can
now return PAGE_ACTIVATE instead of PAGE_KEEP, so SetPageActive() will
be called on the page which (I think) wil further delay the next attempt
at writeout.  This might be a good thing.

Link: https://lkml.kernel.org/r/164549983739.9187.14895675781408171186.stgit@noble.brown
Signed-off-by: NeilBrown <neilb@suse.de>
Cc: Anna Schumaker <Anna.Schumaker@Netapp.com>
Cc: Chao Yu <chao@kernel.org>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Jeff Layton <jlayton@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Lars Ellenberg <lars.ellenberg@linbit.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Paolo Valente <paolo.valente@linaro.org>
Cc: Philipp Reisner <philipp.reisner@linbit.com>
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ceph/addr.c
fs/ceph/super.c
fs/ceph/super.h

index c98e523..dc7af34 100644 (file)
@@ -563,7 +563,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
 
        if (atomic_long_inc_return(&fsc->writeback_count) >
            CONGESTION_ON_THRESH(fsc->mount_options->congestion_kb))
-               set_bdi_congested(inode_to_bdi(inode), BLK_RW_ASYNC);
+               fsc->write_congested = true;
 
        req = ceph_osdc_new_request(osdc, &ci->i_layout, ceph_vino(inode), page_off, &len, 0, 1,
                                    CEPH_OSD_OP_WRITE, CEPH_OSD_FLAG_WRITE, snapc,
@@ -623,7 +623,7 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
 
        if (atomic_long_dec_return(&fsc->writeback_count) <
            CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb))
-               clear_bdi_congested(inode_to_bdi(inode), BLK_RW_ASYNC);
+               fsc->write_congested = false;
 
        return err;
 }
@@ -635,6 +635,10 @@ static int ceph_writepage(struct page *page, struct writeback_control *wbc)
        BUG_ON(!inode);
        ihold(inode);
 
+       if (wbc->sync_mode == WB_SYNC_NONE &&
+           ceph_inode_to_client(inode)->write_congested)
+               return AOP_WRITEPAGE_ACTIVATE;
+
        wait_on_page_fscache(page);
 
        err = writepage_nounlock(page, wbc);
@@ -707,8 +711,7 @@ static void writepages_finish(struct ceph_osd_request *req)
                        if (atomic_long_dec_return(&fsc->writeback_count) <
                             CONGESTION_OFF_THRESH(
                                        fsc->mount_options->congestion_kb))
-                               clear_bdi_congested(inode_to_bdi(inode),
-                                                   BLK_RW_ASYNC);
+                               fsc->write_congested = false;
 
                        ceph_put_snap_context(detach_page_private(page));
                        end_page_writeback(page);
@@ -760,6 +763,10 @@ static int ceph_writepages_start(struct address_space *mapping,
        bool done = false;
        bool caching = ceph_is_cache_enabled(inode);
 
+       if (wbc->sync_mode == WB_SYNC_NONE &&
+           fsc->write_congested)
+               return 0;
+
        dout("writepages_start %p (mode=%s)\n", inode,
             wbc->sync_mode == WB_SYNC_NONE ? "NONE" :
             (wbc->sync_mode == WB_SYNC_ALL ? "ALL" : "HOLD"));
@@ -954,11 +961,8 @@ get_more_pages:
 
                        if (atomic_long_inc_return(&fsc->writeback_count) >
                            CONGESTION_ON_THRESH(
-                                   fsc->mount_options->congestion_kb)) {
-                               set_bdi_congested(inode_to_bdi(inode),
-                                                 BLK_RW_ASYNC);
-                       }
-
+                                   fsc->mount_options->congestion_kb))
+                               fsc->write_congested = true;
 
                        pages[locked_pages++] = page;
                        pvec.pages[i] = NULL;
index bf79f36..4a3b77d 100644 (file)
@@ -802,6 +802,7 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,
        fsc->have_copy_from2 = true;
 
        atomic_long_set(&fsc->writeback_count, 0);
+       fsc->write_congested = false;
 
        err = -ENOMEM;
        /*
index 67f145e..0bd97ae 100644 (file)
@@ -121,6 +121,7 @@ struct ceph_fs_client {
        struct ceph_mds_client *mdsc;
 
        atomic_long_t writeback_count;
+       bool write_congested;
 
        struct workqueue_struct *inode_wq;
        struct workqueue_struct *cap_wq;