static int filter_lock_dentry(struct obd_device *obd, struct dentry *dparent)
{
- LOCK_INODE_MUTEX_PARENT(dparent->d_inode);
- return 0;
+ mutex_lock_nested(&dparent->d_inode->i_mutex, I_MUTEX_PARENT);
+ return 0;
}
/* We never dget the object parent, so DON'T dput it either */
/* We never dget the object parent, so DON'T dput it either */
static void filter_parent_unlock(struct dentry *dparent)
{
- UNLOCK_INODE_MUTEX(dparent->d_inode);
+ mutex_unlock(&dparent->d_inode->i_mutex);
}
/* How to get files, dentries, inodes from object id's.
/* don't need dir->i_zombie for 2.4, it is for rename/unlink of dir
* itself we already hold dir->i_mutex for child create/unlink ops */
- LASSERT(dentry->d_inode != NULL);
- LASSERT(TRYLOCK_INODE_MUTEX(dir) == 0);
- LASSERT(TRYLOCK_INODE_MUTEX(dentry->d_inode) == 0);
+ LASSERT(dentry->d_inode != NULL);
+ LASSERT(mutex_trylock(&dir->i_mutex) == 0);
+ LASSERT(mutex_trylock(&dentry->d_inode->i_mutex) == 0);
/* may_delete() */
rc = dir->i_op->unlink(dir, dentry);
out:
- /* need to drop i_mutex before we lose inode reference */
- UNLOCK_INODE_MUTEX(dentry->d_inode);
- if (rc == 0)
- d_delete(dentry);
+ /* need to drop i_mutex before we lose inode reference */
+ mutex_unlock(&dentry->d_inode->i_mutex);
+ if (rc == 0)
+ d_delete(dentry);
- RETURN(rc);
+ RETURN(rc);
}
/* Caller must hold LCK_PW on parent and push us into kernel context.
if (fcc != NULL)
*fcc = oa->o_lcookie;
}
- if (ia_valid & (ATTR_SIZE | ATTR_UID | ATTR_GID)) {
- unsigned long now = jiffies;
- /* Filter truncates and writes are serialized by
- * i_alloc_sem, see the comment in
- * filter_preprw_write.*/
- if (ia_valid & ATTR_SIZE)
- down_write(&inode->i_alloc_sem);
- LOCK_INODE_MUTEX(inode);
- fsfilt_check_slow(exp->exp_obd, now, "i_alloc_sem and i_mutex");
- old_size = i_size_read(inode);
- }
+ if (ia_valid & (ATTR_SIZE | ATTR_UID | ATTR_GID)) {
+ unsigned long now = jiffies;
+ /* Filter truncates and writes are serialized by
+ * i_alloc_sem, see the comment in
+ * filter_preprw_write.*/
+ if (ia_valid & ATTR_SIZE)
+ down_write(&inode->i_alloc_sem);
+ mutex_lock(&inode->i_mutex);
+ fsfilt_check_slow(exp->exp_obd, now, "i_alloc_sem and i_mutex");
+ old_size = i_size_read(inode);
+ }
/* VBR: version recovery check */
rc = filter_version_get_check(exp, oti, inode);
if (page)
page_cache_release(page);
- if (ia_valid & (ATTR_SIZE | ATTR_UID | ATTR_GID))
- UNLOCK_INODE_MUTEX(inode);
- if (ia_valid & ATTR_SIZE)
- up_write(&inode->i_alloc_sem);
- if (fcc)
- OBD_FREE(fcc, sizeof(*fcc));
+ if (ia_valid & (ATTR_SIZE | ATTR_UID | ATTR_GID))
+ mutex_unlock(&inode->i_mutex);
+ if (ia_valid & ATTR_SIZE)
+ up_write(&inode->i_alloc_sem);
+ if (fcc)
+ OBD_FREE(fcc, sizeof(*fcc));
/* trigger quota release */
if (ia_valid & (ATTR_SIZE | ATTR_UID | ATTR_GID)) {
* between page lock, i_mutex & starting new journal handle.
* (see bug 20321) -johann
*/
- now = jiffies;
- down_write(&dchild->d_inode->i_alloc_sem);
- LOCK_INODE_MUTEX(dchild->d_inode);
- fsfilt_check_slow(exp->exp_obd, now, "i_alloc_sem and i_mutex");
+ now = jiffies;
+ down_write(&dchild->d_inode->i_alloc_sem);
+ mutex_lock(&dchild->d_inode->i_mutex);
+ fsfilt_check_slow(exp->exp_obd, now, "i_alloc_sem and i_mutex");
+
+ /* VBR: version recovery check */
+ rc = filter_version_get_check(exp, oti, dchild->d_inode);
+ if (rc) {
+ mutex_unlock(&dchild->d_inode->i_mutex);
+ up_write(&dchild->d_inode->i_alloc_sem);
+ GOTO(cleanup, rc);
+ }
- /* VBR: version recovery check */
- rc = filter_version_get_check(exp, oti, dchild->d_inode);
- if (rc) {
- UNLOCK_INODE_MUTEX(dchild->d_inode);
- up_write(&dchild->d_inode->i_alloc_sem);
- GOTO(cleanup, rc);
- }
+ handle = fsfilt_start_log(obd, dchild->d_inode, FSFILT_OP_SETATTR,
+ NULL, 1);
+ if (IS_ERR(handle)) {
+ mutex_unlock(&dchild->d_inode->i_mutex);
+ up_write(&dchild->d_inode->i_alloc_sem);
+ GOTO(cleanup, rc = PTR_ERR(handle));
+ }
- handle = fsfilt_start_log(obd, dchild->d_inode, FSFILT_OP_SETATTR,
- NULL, 1);
- if (IS_ERR(handle)) {
- UNLOCK_INODE_MUTEX(dchild->d_inode);
- up_write(&dchild->d_inode->i_alloc_sem);
- GOTO(cleanup, rc = PTR_ERR(handle));
- }
+ /* Locking order: i_mutex -> journal_lock -> dqptr_sem. LU-952 */
+ ll_vfs_dq_init(dchild->d_inode);
- /* Locking order: i_mutex -> journal_lock -> dqptr_sem. LU-952 */
- ll_vfs_dq_init(dchild->d_inode);
-
- iattr.ia_valid = ATTR_SIZE;
- iattr.ia_size = 0;
- rc = fsfilt_setattr(obd, dchild, handle, &iattr, 1);
- rc2 = fsfilt_commit(obd, dchild->d_inode, handle, 0);
- UNLOCK_INODE_MUTEX(dchild->d_inode);
- up_write(&dchild->d_inode->i_alloc_sem);
- if (rc)
- GOTO(cleanup, rc);
- if (rc2)
- GOTO(cleanup, rc = rc2);
+ iattr.ia_valid = ATTR_SIZE;
+ iattr.ia_size = 0;
+ rc = fsfilt_setattr(obd, dchild, handle, &iattr, 1);
+ rc2 = fsfilt_commit(obd, dchild->d_inode, handle, 0);
+ mutex_unlock(&dchild->d_inode->i_mutex);
+ up_write(&dchild->d_inode->i_alloc_sem);
+ if (rc)
+ GOTO(cleanup, rc);
+ if (rc2)
+ GOTO(cleanup, rc = rc2);
/* We don't actually need to lock the parent until we are unlinking
* here, and not while truncating above. That avoids holding the
GOTO(cleanup, rc = PTR_ERR(dparent));
cleanup_phase = 3; /* filter_parent_unlock */
- LOCK_INODE_MUTEX(dchild->d_inode);
- handle = fsfilt_start_log(obd, dparent->d_inode,FSFILT_OP_UNLINK,oti,1);
- if (IS_ERR(handle)) {
- UNLOCK_INODE_MUTEX(dchild->d_inode);
- GOTO(cleanup, rc = PTR_ERR(handle));
- }
- cleanup_phase = 4; /* fsfilt_commit */
+ mutex_lock(&dchild->d_inode->i_mutex);
+ handle = fsfilt_start_log(obd, dparent->d_inode,
+ FSFILT_OP_UNLINK, oti, 1);
+ if (IS_ERR(handle)) {
+ mutex_unlock(&dchild->d_inode->i_mutex);
+ GOTO(cleanup, rc = PTR_ERR(handle));
+ }
+ cleanup_phase = 4; /* fsfilt_commit */
/* Quota release need uid/gid of inode */
obdo_from_inode(oa, dchild->d_inode, OBD_MD_FLUID | OBD_MD_FLGID);
push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL);
- LOCK_INODE_MUTEX(dentry->d_inode);
+ mutex_lock(&dentry->d_inode->i_mutex);
- rc = filemap_fdatawrite(dentry->d_inode->i_mapping);
- if (rc == 0) {
- /* just any file to grab fsync method - "file" arg unused */
- struct file *file = obt->obt_rcvd_filp;
+ rc = filemap_fdatawrite(dentry->d_inode->i_mapping);
+ if (rc == 0) {
+ /* just any file to grab fsync method - "file" arg unused */
+ struct file *file = obt->obt_rcvd_filp;
- if (file->f_op && file->f_op->fsync)
- rc = file->f_op->fsync(NULL, dentry, 1);
+ if (file->f_op && file->f_op->fsync)
+ rc = file->f_op->fsync(NULL, dentry, 1);
- rc2 = filemap_fdatawait(dentry->d_inode->i_mapping);
- if (!rc)
- rc = rc2;
- }
- UNLOCK_INODE_MUTEX(dentry->d_inode);
+ rc2 = filemap_fdatawait(dentry->d_inode->i_mapping);
+ if (!rc)
+ rc = rc2;
+ }
+ mutex_unlock(&dentry->d_inode->i_mutex);
oinfo->oi_oa->o_valid = OBD_MD_FLID;
obdo_from_inode(oinfo->oi_oa, dentry->d_inode, FILTER_VALID_FLAGS);