]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
gfs2: Remove ordered write mode handling from gfs2_trans_add_data
authorAndreas Gruenbacher <agruenba@redhat.com>
Mon, 4 Jun 2018 12:50:16 +0000 (07:50 -0500)
committerBob Peterson <rpeterso@redhat.com>
Mon, 4 Jun 2018 12:50:16 +0000 (07:50 -0500)
In journaled data mode, we need to add each buffer head to the current
transaction.  In ordered write mode, we only need to add the inode to
the ordered inode list.  So far, both cases are handled in
gfs2_trans_add_data.  This makes the code look misleading and is
inefficient for small block sizes as well.  Handle both cases separately
instead.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
fs/gfs2/aops.c
fs/gfs2/bmap.c
fs/gfs2/log.h
fs/gfs2/quota.c
fs/gfs2/trans.c

index 69f25e3c97ce0b8d30ade8249a72dc973882a8ea..35f5ee23566d6af25a5c8b3e62508aea2fe7cc69 100644 (file)
@@ -54,8 +54,7 @@ static void gfs2_page_add_databufs(struct gfs2_inode *ip, struct page *page,
                        continue;
                if (start >= to)
                        break;
-               if (gfs2_is_jdata(ip))
-                       set_buffer_uptodate(bh);
+               set_buffer_uptodate(bh);
                gfs2_trans_add_data(ip->i_gl, bh);
        }
 }
@@ -894,8 +893,10 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
                goto out2;
        }
 
-       if (!gfs2_is_writeback(ip))
+       if (gfs2_is_jdata(ip))
                gfs2_page_add_databufs(ip, page, pos & ~PAGE_MASK, len);
+       else
+               gfs2_ordered_add_inode(ip);
 
        ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata);
        page = NULL;
index 69f846418ad591a7cffcc85cde47cea7fe5ba5b4..5226c3bfbcf724370e004a4138b4c51989882751 100644 (file)
@@ -89,10 +89,12 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
                map_bh(bh, inode->i_sb, block);
 
        set_buffer_uptodate(bh);
-       if (!gfs2_is_jdata(ip))
-               mark_buffer_dirty(bh);
-       if (!gfs2_is_writeback(ip))
+       if (gfs2_is_jdata(ip))
                gfs2_trans_add_data(ip->i_gl, bh);
+       else {
+               mark_buffer_dirty(bh);
+               gfs2_ordered_add_inode(ip);
+       }
 
        if (release) {
                unlock_page(page);
@@ -1028,8 +1030,10 @@ static int gfs2_block_zero_range(struct inode *inode, loff_t from,
                err = 0;
        }
 
-       if (!gfs2_is_writeback(ip))
+       if (gfs2_is_jdata(ip))
                gfs2_trans_add_data(ip->i_gl, bh);
+       else
+               gfs2_ordered_add_inode(ip);
 
        zero_user(page, offset, length);
        mark_buffer_dirty(bh);
index 1862e310a067c7182b6d1540999ea9f7fb0c1ccc..20241436126da6112925009e2adc9b4158699007 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/spinlock.h>
 #include <linux/writeback.h>
 #include "incore.h"
+#include "inode.h"
 
 /**
  * gfs2_log_lock - acquire the right to mess with the log manager
@@ -50,8 +51,12 @@ static inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp,
 
 static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip)
 {
-       struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
+       struct gfs2_sbd *sdp;
 
+       if (!gfs2_is_ordered(ip))
+               return;
+
+       sdp = GFS2_SB(&ip->i_inode);
        if (!test_bit(GIF_ORDERED, &ip->i_flags)) {
                spin_lock(&sdp->sd_ordered_lock);
                if (!test_and_set_bit(GIF_ORDERED, &ip->i_flags))
index 7a98abd340ee96bdc4ce1cc7816e9c437700b0cc..e8585dfd209f5b8174b6fb8d892de7b4e28270fe 100644 (file)
@@ -735,7 +735,10 @@ static int gfs2_write_buf_to_page(struct gfs2_inode *ip, unsigned long index,
                        if (!buffer_uptodate(bh))
                                goto unlock_out;
                }
-               gfs2_trans_add_data(ip->i_gl, bh);
+               if (gfs2_is_jdata(ip))
+                       gfs2_trans_add_data(ip->i_gl, bh);
+               else
+                       gfs2_ordered_add_inode(ip);
 
                /* If we need to write to the next block as well */
                if (to_write > (bsize - boff)) {
index c75cacaa349b1d11d5b2b2c92e6cf13af4f896b1..064c9a0ef046068cd2547af5b5578d5bc65a4fe6 100644 (file)
@@ -143,32 +143,21 @@ static struct gfs2_bufdata *gfs2_alloc_bufdata(struct gfs2_glock *gl,
  * @gl: The inode glock associated with the buffer
  * @bh: The buffer to add
  *
- * This is used in two distinct cases:
- * i) In ordered write mode
- *    We put the data buffer on a list so that we can ensure that it's
- *    synced to disk at the right time
- * ii) In journaled data mode
- *    We need to journal the data block in the same way as metadata in
- *    the functions above. The difference is that here we have a tag
- *    which is two __be64's being the block number (as per meta data)
- *    and a flag which says whether the data block needs escaping or
- *    not. This means we need a new log entry for each 251 or so data
- *    blocks, which isn't an enormous overhead but twice as much as
- *    for normal metadata blocks.
+ * This is used in journaled data mode.
+ * We need to journal the data block in the same way as metadata in
+ * the functions above. The difference is that here we have a tag
+ * which is two __be64's being the block number (as per meta data)
+ * and a flag which says whether the data block needs escaping or
+ * not. This means we need a new log entry for each 251 or so data
+ * blocks, which isn't an enormous overhead but twice as much as
+ * for normal metadata blocks.
  */
 void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh)
 {
        struct gfs2_trans *tr = current->journal_info;
        struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
-       struct address_space *mapping = bh->b_page->mapping;
-       struct gfs2_inode *ip = GFS2_I(mapping->host);
        struct gfs2_bufdata *bd;
 
-       if (!gfs2_is_jdata(ip)) {
-               gfs2_ordered_add_inode(ip);
-               return;
-       }
-
        lock_buffer(bh);
        if (buffer_pinned(bh)) {
                set_bit(TR_TOUCHED, &tr->tr_flags);