]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bcachefs: Don't stack allocate bch_writepage_state
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 26 May 2025 20:16:17 +0000 (16:16 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 30 May 2025 05:21:12 +0000 (01:21 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fs-io-buffered.c

index e3a75dcca60c819f1d3cf8a9726ac6ff0c2d6029..66bacdd49f789b97c4805f9c3c383ab86cd3a92d 100644 (file)
@@ -394,17 +394,9 @@ struct bch_writepage_state {
        struct bch_io_opts      opts;
        struct bch_folio_sector *tmp;
        unsigned                tmp_sectors;
+       struct blk_plug         plug;
 };
 
-static inline struct bch_writepage_state bch_writepage_state_init(struct bch_fs *c,
-                                                                 struct bch_inode_info *inode)
-{
-       struct bch_writepage_state ret = { 0 };
-
-       bch2_inode_opts_get(&ret.opts, c, &inode->ei_inode);
-       return ret;
-}
-
 /*
  * Determine when a writepage io is full. We have to limit writepage bios to a
  * single page per bvec (i.e. 1MB with 4k pages) because that is the limit to
@@ -666,17 +658,17 @@ do_io:
 int bch2_writepages(struct address_space *mapping, struct writeback_control *wbc)
 {
        struct bch_fs *c = mapping->host->i_sb->s_fs_info;
-       struct bch_writepage_state w =
-               bch_writepage_state_init(c, to_bch_ei(mapping->host));
-       struct blk_plug plug;
-       int ret;
+       struct bch_writepage_state *w = kzalloc(sizeof(*w), GFP_NOFS|__GFP_NOFAIL);
 
-       blk_start_plug(&plug);
-       ret = write_cache_pages(mapping, wbc, __bch2_writepage, &w);
-       if (w.io)
-               bch2_writepage_do_io(&w);
-       blk_finish_plug(&plug);
-       kfree(w.tmp);
+       bch2_inode_opts_get(&w->opts, c, &to_bch_ei(mapping->host)->ei_inode);
+
+       blk_start_plug(&w->plug);
+       int ret = write_cache_pages(mapping, wbc, __bch2_writepage, w);
+       if (w->io)
+               bch2_writepage_do_io(w);
+       blk_finish_plug(&w->plug);
+       kfree(w->tmp);
+       kfree(w);
        return bch2_err_class(ret);
 }