Whamcloud - gitweb
LU-4627 llite: deed taking lli_trunc_sem during file write 67/9267/4
authorBobi Jam <bobijam.xu@intel.com>
Thu, 13 Feb 2014 15:27:41 +0000 (23:27 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 10 Mar 2014 23:40:56 +0000 (23:40 +0000)
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 <bobijam.xu@intel.com>
Change-Id: Ic7f9cfb6d76dcf7ad08635efab154e7cdc392ce8
Reviewed-on: http://review.whamcloud.com/9267
Tested-by: Jenkins
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>

index 7d2054c..e744390 100644 (file)
@@ -1695,7 +1695,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
                if (attr->ia_valid & ATTR_SIZE)
-               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);
@@ -1776,7 +1779,6 @@ out:
        if (!S_ISDIR(inode->i_mode)) {
-               up_write(&lli->lli_trunc_sem);
                if ((attr->ia_valid & ATTR_SIZE) && !hsm_import)