]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm: make snapshotting pages for stable writes a per-bio operation
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 26 Mar 2013 23:24:37 +0000 (10:24 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 2 Apr 2013 07:29:08 +0000 (18:29 +1100)
Walking a bio's page mappings has proved problematic, so create a new bio
flag to indicate that a bio's data needs to be snapshotted in order to
guarantee stable pages during writeback.  Next, for the one user
(ext3/jbd) of snapshotting, hook all the places where writes can be
initiated without PG_writeback set, and set BIO_SNAP_STABLE there.
Finally, the MS_SNAP_STABLE mount flag (only used by ext3) is now
superfluous, so get rid of it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/buffer.c
fs/ext3/super.c
fs/jbd/commit.c
include/linux/blk_types.h
include/linux/buffer_head.h
include/uapi/linux/fs.h
mm/bounce.c
mm/page-writeback.c

index ecd3792ae0e9f886429cace691d68d8284662741..10377c023f834c2042eb8061087d0e678b289e36 100644 (file)
@@ -2949,7 +2949,7 @@ static void guard_bh_eod(int rw, struct bio *bio, struct buffer_head *bh)
        }
 }
 
-int submit_bh(int rw, struct buffer_head * bh)
+int _submit_bh(int rw, struct buffer_head * bh, unsigned long flags)
 {
        struct bio *bio;
        int ret = 0;
@@ -2983,6 +2983,7 @@ int submit_bh(int rw, struct buffer_head * bh)
 
        bio->bi_end_io = end_bio_bh_io_sync;
        bio->bi_private = bh;
+       bio->bi_flags |= flags;
 
        /* Take care of bh's that straddle the end of the device */
        guard_bh_eod(rw, bio, bh);
@@ -2996,6 +2997,12 @@ int submit_bh(int rw, struct buffer_head * bh)
        bio_put(bio);
        return ret;
 }
+EXPORT_SYMBOL_GPL(_submit_bh);
+
+int submit_bh(int rw, struct buffer_head * bh)
+{
+       return _submit_bh(rw, bh, 0);
+}
 EXPORT_SYMBOL(submit_bh);
 
 /**
index fb5120a5505c055b9de9e7b948713256329cf690..3dc48cc8b6eb318cfd5d8fdfce551c9d3808b728 100644 (file)
@@ -2067,7 +2067,6 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
                test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA ? "journal":
                test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered":
                "writeback");
-       sb->s_flags |= MS_SNAP_STABLE;
 
        return 0;
 
index 86b39b167c23645261ae2b3a0a248711a1f33122..b91b688987a962ea778c50b3a7a8bab2f76fec18 100644 (file)
@@ -163,7 +163,7 @@ static void journal_do_submit_data(struct buffer_head **wbuf, int bufs,
        for (i = 0; i < bufs; i++) {
                wbuf[i]->b_end_io = end_buffer_write_sync;
                /* We use-up our safety reference in submit_bh() */
-               submit_bh(write_op, wbuf[i]);
+               _submit_bh(write_op, wbuf[i], 1 << BIO_SNAP_STABLE);
        }
 }
 
@@ -667,7 +667,7 @@ start_journal_io:
                                clear_buffer_dirty(bh);
                                set_buffer_uptodate(bh);
                                bh->b_end_io = journal_end_buffer_io_sync;
-                               submit_bh(write_op, bh);
+                               _submit_bh(write_op, bh, 1 << BIO_SNAP_STABLE);
                        }
                        cond_resched();
 
index e8de67053cd4b15264c599644e1dc012273604fd..137f637ad6fc9aaf0bfb53a7fd82fe5cfb2cbc52 100644 (file)
@@ -111,13 +111,13 @@ struct bio {
 #define BIO_FS_INTEGRITY 9     /* fs owns integrity data, not block layer */
 #define BIO_QUIET      10      /* Make BIO Quiet */
 #define BIO_MAPPED_INTEGRITY 11/* integrity metadata has been remapped */
-
+#define BIO_SNAP_STABLE        12      /* bio data must be snapshotted during write */
 /*
  * Flags starting here get preserved by bio_reset() - this includes
  * BIO_POOL_IDX()
  */
-#define BIO_RESET_BITS 12
-#define BIO_OWNS_VEC   12      /* bio_free() should free bvec */
+#define BIO_RESET_BITS 13
+#define BIO_OWNS_VEC   13      /* bio_free() should free bvec */
 
 #define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag)))
 
index 5afc4f94d110f67590e8a7924c09b006f1e711c8..714d5d97a8d1fdffac822cbed2097a30f19e6c9d 100644 (file)
@@ -181,6 +181,7 @@ void ll_rw_block(int, int, struct buffer_head * bh[]);
 int sync_dirty_buffer(struct buffer_head *bh);
 int __sync_dirty_buffer(struct buffer_head *bh, int rw);
 void write_dirty_buffer(struct buffer_head *bh, int rw);
+int _submit_bh(int, struct buffer_head *, unsigned long);
 int submit_bh(int, struct buffer_head *);
 void write_boundary_block(struct block_device *bdev,
                        sector_t bblock, unsigned blocksize);
index c7fc1e6517c3d21c5f9ad717ab36ed4956bfd0fe..a4ed56cf0eac5f1e5c1b90edf2a1d3b6093d9e02 100644 (file)
@@ -88,7 +88,6 @@ struct inodes_stat_t {
 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
 
 /* These sb flags are internal to the kernel */
-#define MS_SNAP_STABLE (1<<27) /* Snapshot pages during writeback, if needed */
 #define MS_NOSEC       (1<<28)
 #define MS_BORN                (1<<29)
 #define MS_ACTIVE      (1<<30)
index f5326b24d65d88c1051ee9547b0a66373372940c..c9f0a4339a7dafc2ba7295e49ad8fcdda8fa13de 100644 (file)
@@ -181,32 +181,13 @@ static void bounce_end_io_read_isa(struct bio *bio, int err)
 #ifdef CONFIG_NEED_BOUNCE_POOL
 static int must_snapshot_stable_pages(struct request_queue *q, struct bio *bio)
 {
-       struct page *page;
-       struct backing_dev_info *bdi;
-       struct address_space *mapping;
-       struct bio_vec *from;
-       int i;
-
        if (bio_data_dir(bio) != WRITE)
                return 0;
 
        if (!bdi_cap_stable_pages_required(&q->backing_dev_info))
                return 0;
 
-       /*
-        * Based on the first page that has a valid mapping, decide whether or
-        * not we have to employ bounce buffering to guarantee stable pages.
-        */
-       bio_for_each_segment(from, bio, i) {
-               page = from->bv_page;
-               mapping = page_mapping(page);
-               if (!mapping)
-                       continue;
-               bdi = mapping->backing_dev_info;
-               return mapping->host->i_sb->s_flags & MS_SNAP_STABLE;
-       }
-
-       return 0;
+       return test_bit(BIO_SNAP_STABLE, &bio->bi_flags);
 }
 #else
 static int must_snapshot_stable_pages(struct request_queue *q, struct bio *bio)
index efe68148f621959beb28987dd9430fff289f583f..4514ad7415c327bfbbe9837f3a7955291f3a172d 100644 (file)
@@ -2311,10 +2311,6 @@ void wait_for_stable_page(struct page *page)
 
        if (!bdi_cap_stable_pages_required(bdi))
                return;
-#ifdef CONFIG_NEED_BOUNCE_POOL
-       if (mapping->host->i_sb->s_flags & MS_SNAP_STABLE)
-               return;
-#endif /* CONFIG_NEED_BOUNCE_POOL */
 
        wait_on_page_writeback(page);
 }