From 1601e8591c1334ee7879bb6daac09342caa4a542 Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Thu, 13 Feb 2014 23:27:41 +0800 Subject: [PATCH] LU-4627 llite: deed taking lli_trunc_sem during file write File write before io loop will take lli_trun_sem read semaphore to protect osc_extent, while after generic_file_aio_write() done, it could possible need to kill suid or sgid, which will call ll_setattr_raw() to change the inode's attribute, and it does not involve size. So the ll_truc_sem write semaphore should be constrained around ll_setattr_ost() to not come across the lli_trunc_sem read semaphore get from the normal file write path. Signed-off-by: Bobi Jam Change-Id: Ic7f9cfb6d76dcf7ad08635efab154e7cdc392ce8 Reviewed-on: http://review.whamcloud.com/9267 Tested-by: Jenkins Reviewed-by: Jinshan Xiong Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- lustre/llite/llite_lib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 7d2054c..e744390 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1695,7 +1695,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) if (attr->ia_valid & ATTR_SIZE) inode_dio_write_done(inode); mutex_unlock(&inode->i_mutex); - down_write(&lli->lli_trunc_sem); } /* truncate on a released file must failed with -ENODATA, @@ -1763,7 +1762,11 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) * excessive to send mtime/atime updates to OSTs when not * setting times to past, but it is necessary due to possible * time de-synchronization between MDT inode and OST objects */ + if (attr->ia_valid & ATTR_SIZE) + down_write(&lli->lli_trunc_sem); rc = ll_setattr_ost(inode, attr); + if (attr->ia_valid & ATTR_SIZE) + up_write(&lli->lli_trunc_sem); } EXIT; out: @@ -1776,7 +1779,6 @@ out: ll_finish_md_op_data(op_data); } if (!S_ISDIR(inode->i_mode)) { - up_write(&lli->lli_trunc_sem); mutex_lock(&inode->i_mutex); if ((attr->ia_valid & ATTR_SIZE) && !hsm_import) inode_dio_wait(inode); -- 1.8.3.1