Whamcloud - gitweb
LU-9740 ldiskfs: more credits for non-append write 29/28229/2
authorFan Yong <fan.yong@intel.com>
Thu, 6 Jul 2017 00:49:32 +0000 (08:49 +0800)
committerJohn L. Hammond <john.hammond@intel.com>
Mon, 7 Aug 2017 18:49:42 +0000 (18:49 +0000)
As code comment explained: for not append write, the split
may need to modify existing blocks moving entries into the
new ones. That needs more journal credits. The old logic
handled it as append case by typo.

Lustre-change: https://review.whamcloud.com/27947
Lustre-commit: c668a8d405a9d8819bf9b96e0c610ccc5353d77d

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: I277f144ec056bb2f07ffd5e5ce19d9a6eee8e0ef
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Minh Diep <minh.diep@intel.com>
Reviewed-on: https://review.whamcloud.com/28229
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/osd-ldiskfs/osd_io.c

index 13b40c6..c3545a4 100644 (file)
@@ -1616,7 +1616,7 @@ static ssize_t osd_declare_write(const struct lu_env *env, struct dt_object *dt,
                credits = depth;
                /* if not append, then split may need to modify
                 * existing blocks moving entries into the new ones */
-               if (_pos == -1)
+               if (_pos != -1)
                        credits += depth;
                /* blocks to store data: bitmap,gd,itself */
                credits += blocks * 3;
@@ -1680,9 +1680,12 @@ int osd_ldiskfs_write_record(struct inode *inode, void *buf, int bufsize,
                ((char *)buf)[bufsize] = '\0';
                ++bufsize;
        }
-        while (bufsize > 0) {
-                if (bh != NULL)
-                        brelse(bh);
+
+       while (bufsize > 0) {
+               int credits = handle->h_buffer_credits;
+
+               if (bh)
+                       brelse(bh);
 
                block = offset >> inode->i_blkbits;
                boffs = offset & (blocksize - 1);
@@ -1695,9 +1698,11 @@ int osd_ldiskfs_write_record(struct inode *inode, void *buf, int bufsize,
                                err = PTR_ERR(bh);
                                bh = NULL;
                        }
-                        CERROR("%s: error reading offset %llu (block %lu): "
-                               "rc = %d\n",
-                               inode->i_sb->s_id, offset, block, err);
+
+                       CERROR("%s: error reading offset %llu (block %lu, "
+                              "size %d, offs %llu), credits %d/%d: rc = %d\n",
+                              inode->i_sb->s_id, offset, block, bufsize, *offs,
+                              credits, handle->h_buffer_credits, err);
                         break;
                 }