From 85c6c099d83b19480dd4160de57e7ffac5b312af Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Fri, 7 Aug 2015 13:13:03 +0800 Subject: [PATCH] LU-7045 osd: enough credits for single indirect block write For single indirect block case, if the i_data[LDISKFS_IND_BLOCK] block is not allocated, the osd_calc_bkmap_credits() should declare additional three blocks for subsequent write operation; otherwise, preserve another single block for that. Test-Parameters: alwaysuploadlogs envdefinitions=SLOW=yes,ENABLE_QUOTA=yes,CONF_SANITY_EXCEPT=45 mdtfilesystemtype=ldiskfs mdsfilesystemtype=ldiskfs ostfilesystemtype=ldiskfs clientdistro=el7 ossdistro=el7 mdsdistro=el7 mdtcount=1 testlist=conf-sanity,conf-sanity,conf-sanity,conf-sanity,conf-sanity Test-Parameters: alwaysuploadlogs envdefinitions=SLOW=yes,ENABLE_QUOTA=yes,CONF_SANITY_EXCEPT=45 mdtfilesystemtype=ldiskfs mdsfilesystemtype=ldiskfs ostfilesystemtype=ldiskfs clientdistro=el7 ossdistro=el7 mdsdistro=el7 mdscount=2 mdtcount=4 testlist=conf-sanity,conf-sanity,conf-sanity,conf-sanity,conf-sanity Signed-off-by: Fan Yong Change-Id: I76b50cef8df56b49dae7afe4d759a55599548479 Reviewed-on: http://review.whamcloud.com/16330 Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Andreas Dilger --- lustre/osd-ldiskfs/osd_io.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 98da270..83c72ff 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -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; -- 1.8.3.1