Commit 178ba1e0 authored by Bobi Jam's avatar Bobi Jam Committed by Greg Kroah-Hartman

staging/lustre/llite: deadlock 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: default avatarBobi Jam <bobijam.xu@intel.com>
Reviewed-on: http://review.whamcloud.com/9267
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4627Reviewed-by: default avatarLai Siyao <lai.siyao@intel.com>
Signed-off-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8d97deb9
...@@ -1449,7 +1449,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) ...@@ -1449,7 +1449,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
if (attr->ia_valid & ATTR_SIZE) if (attr->ia_valid & ATTR_SIZE)
inode_dio_write_done(inode); inode_dio_write_done(inode);
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
down_write(&lli->lli_trunc_sem);
} }
memcpy(&op_data->op_attr, attr, sizeof(*attr)); memcpy(&op_data->op_attr, attr, sizeof(*attr));
...@@ -1513,7 +1512,11 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) ...@@ -1513,7 +1512,11 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
* excessive to send mtime/atime updates to OSTs when not * excessive to send mtime/atime updates to OSTs when not
* setting times to past, but it is necessary due to possible * setting times to past, but it is necessary due to possible
* time de-synchronization between MDT inode and OST objects */ * 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); rc = ll_setattr_ost(inode, attr);
if (attr->ia_valid & ATTR_SIZE)
up_write(&lli->lli_trunc_sem);
out: out:
if (op_data) { if (op_data) {
if (op_data->op_ioepoch) { if (op_data->op_ioepoch) {
...@@ -1524,7 +1527,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) ...@@ -1524,7 +1527,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
ll_finish_md_op_data(op_data); ll_finish_md_op_data(op_data);
} }
if (!S_ISDIR(inode->i_mode)) { if (!S_ISDIR(inode->i_mode)) {
up_write(&lli->lli_trunc_sem);
mutex_lock(&inode->i_mutex); mutex_lock(&inode->i_mutex);
if ((attr->ia_valid & ATTR_SIZE) && !hsm_import) if ((attr->ia_valid & ATTR_SIZE) && !hsm_import)
inode_dio_wait(inode); inode_dio_wait(inode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment