Whamcloud - gitweb
LU-7045 osd: enough credits for single indirect block write
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_io.c
index 98da270..83c72ff 100644 (file)
@@ -1527,9 +1527,12 @@ static inline int osd_calc_bkmap_credits(struct super_block *sb,
        } else if (pos + size <= (LDISKFS_NDIR_BLOCKS + 1024) * bs) {
                /* single indirect */
                credits = blocks * 3;
-               /* probably indirect block has been allocated already */
-               if (!inode || LDISKFS_I(inode)->i_data[LDISKFS_IND_BLOCK])
+               if (inode == NULL ||
+                   LDISKFS_I(inode)->i_data[LDISKFS_IND_BLOCK] == 0)
                        credits += 3;
+               else
+                       /* The indirect block may be modified. */
+                       credits += 1;
        }
 
        return credits;