From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63F8432E144; Fri, 17 Oct 2025 15:45:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760715906; cv=none; b=pCqQ25QkZWJ9r7iMVxedS9fNK79u4ivKUJ560vdHj7X/L9i9A0Ik1/kmN9fHznmjd0l4/kGA6Zcuf7XfaDtNLP07+BUg7mVTPJvx4PHlZ/+38zYKSZrrztnhde3KRTlB6W1qSdSSqehpUezSmmJ4meaSobEqDfHArwP5PJ0qbH8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760715906; c=relaxed/simple; bh=hsyaCroZlOpyDIPtwc0w/ZFBWjk/QkbVl30D1Hma/F8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uoN2+GwSYfLf6MaDvHZPH9jko4c3xOB8rTt91PZjMrpt5QxBki+oRhQdvID2MAC/UF3cksvtFREzGmEqNggDj8ICppEZ7RbMvaj06MgPqTKGbgvFe8AE7O9LDeDy8l/SrwzXhCozLLkKXM0rtfNwMILeUgNdpc9lNTDZ03uBWFo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Kym3Qj/1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Kym3Qj/1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17664C4CEE7; Fri, 17 Oct 2025 15:45:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760715906; bh=hsyaCroZlOpyDIPtwc0w/ZFBWjk/QkbVl30D1Hma/F8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Kym3Qj/1oqjNnBDMDOACUt16lqnELIDADwAxk+3t/U1kOC8GbtA+5DL8fdqFb8mCV 3OTmnKNuU/eMWWUmPt5dJXe/TpD7eBOyMFKFxMJGqSP4+ztRVP7EPp9ptY9vYagCmY qco02GBiZXkDgYVL/iMcgrlh3o+vsM6T+RcnUAi+gzkPZxidI/a3/5fDhWVcJje5YL m+XEa9bLIjdI1tNIwcFarMeMtqY6b0wUnu0UuSCnY3UY4me6QKUvLFZ+xu77BJtHBw 4eGZTLs/5p+ErJLOaf0q+x/3hoa1TyhfGPFKbsRy0MIMLBGTXW2LcLPJzru4NmuZY8 Q7g532pVrbEmQ== Date: Fri, 17 Oct 2025 08:45:05 -0700 From: "Darrick J. Wong" To: Christoph Hellwig Cc: Christian Brauner , Jan Kara , Carlos Maiolino , Andrew Morton , willy@infradead.org, dlemoal@kernel.org, hans.holmberg@wdc.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: Re: [PATCH 2/3] writeback: allow the file system to override MIN_WRITEBACK_PAGES Message-ID: <20251017154505.GE6174@frogsfrogsfrogs> References: <20251017034611.651385-1-hch@lst.de> <20251017034611.651385-3-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251017034611.651385-3-hch@lst.de> On Fri, Oct 17, 2025 at 05:45:48AM +0200, Christoph Hellwig wrote: > The relatively low minimal writeback size of 4MiB means that written back > inodes on rotational media are switched a lot. Besides introducing > additional seeks, this also can lead to extreme file fragmentation on > zoned devices when a lot of files are cached relative to the available > writeback bandwidth. > > Add a superblock field that allows the file system to override the > default size. > > Signed-off-by: Christoph Hellwig The comment in the next patch satisfies me sufficiently, so Reviewed-by: "Darrick J. Wong" --D > --- > fs/fs-writeback.c | 14 +++++--------- > fs/super.c | 1 + > include/linux/fs.h | 1 + > include/linux/writeback.h | 5 +++++ > 4 files changed, 12 insertions(+), 9 deletions(-) > > diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c > index 11fd08a0efb8..6d50b02cdab6 100644 > --- a/fs/fs-writeback.c > +++ b/fs/fs-writeback.c > @@ -31,11 +31,6 @@ > #include > #include "internal.h" > > -/* > - * 4MB minimal write chunk size > - */ > -#define MIN_WRITEBACK_PAGES (4096UL >> (PAGE_SHIFT - 10)) > - > /* > * Passed into wb_writeback(), essentially a subset of writeback_control > */ > @@ -1874,8 +1869,8 @@ static int writeback_single_inode(struct inode *inode, > return ret; > } > > -static long writeback_chunk_size(struct bdi_writeback *wb, > - struct wb_writeback_work *work) > +static long writeback_chunk_size(struct super_block *sb, > + struct bdi_writeback *wb, struct wb_writeback_work *work) > { > long pages; > > @@ -1898,7 +1893,8 @@ static long writeback_chunk_size(struct bdi_writeback *wb, > pages = min(wb->avg_write_bandwidth / 2, > global_wb_domain.dirty_limit / DIRTY_SCOPE); > pages = min(pages, work->nr_pages); > - return round_down(pages + MIN_WRITEBACK_PAGES, MIN_WRITEBACK_PAGES); > + return round_down(pages + sb->s_min_writeback_pages, > + sb->s_min_writeback_pages); > } > > /* > @@ -2000,7 +1996,7 @@ static long writeback_sb_inodes(struct super_block *sb, > inode->i_state |= I_SYNC; > wbc_attach_and_unlock_inode(&wbc, inode); > > - write_chunk = writeback_chunk_size(wb, work); > + write_chunk = writeback_chunk_size(inode->i_sb, wb, work); > wbc.nr_to_write = write_chunk; > wbc.pages_skipped = 0; > > diff --git a/fs/super.c b/fs/super.c > index 5bab94fb7e03..599c1d2641fe 100644 > --- a/fs/super.c > +++ b/fs/super.c > @@ -389,6 +389,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, > goto fail; > if (list_lru_init_memcg(&s->s_inode_lru, s->s_shrink)) > goto fail; > + s->s_min_writeback_pages = MIN_WRITEBACK_PAGES; > return s; > > fail: > diff --git a/include/linux/fs.h b/include/linux/fs.h > index c895146c1444..ae6f37c6eaa4 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -1583,6 +1583,7 @@ struct super_block { > > spinlock_t s_inode_wblist_lock; > struct list_head s_inodes_wb; /* writeback inodes */ > + long s_min_writeback_pages; > } __randomize_layout; > > static inline struct user_namespace *i_user_ns(const struct inode *inode) > diff --git a/include/linux/writeback.h b/include/linux/writeback.h > index 22dd4adc5667..49e1dd96f43e 100644 > --- a/include/linux/writeback.h > +++ b/include/linux/writeback.h > @@ -374,4 +374,9 @@ bool redirty_page_for_writepage(struct writeback_control *, struct page *); > void sb_mark_inode_writeback(struct inode *inode); > void sb_clear_inode_writeback(struct inode *inode); > > +/* > + * 4MB minimal write chunk size > + */ > +#define MIN_WRITEBACK_PAGES (4096UL >> (PAGE_SHIFT - 10)) > + > #endif /* WRITEBACK_H */ > -- > 2.47.3 > >