From 8bd064273746bc51826af4a795be79a5cedef265 Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Fri, 6 Apr 2012 04:08:28 -0700 Subject: [PATCH] LU-1290 quota: transfer quota in osd_attr_set() Move the ll_vfs_dquot_transfer() out of the osd_inode_setattr(), since ll_vfs_dquot_transfer() will hold the dqptr_sem, whereas the osd_inode_setattr() is protected by spin lock oo_guard. Signed-off-by: Niu Yawei Change-Id: Ib36231fb30eabfd39fe0baf16e982357113c6121 Reviewed-on: http://review.whamcloud.com/2463 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Johann Lombardi Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- lustre/osd-ldiskfs/osd_handler.c | 50 +++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 299b204..f3ea487 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -1324,28 +1324,6 @@ static int osd_inode_setattr(const struct lu_env *env, LASSERT(!(bits & LA_TYPE)); /* Huh? You want too much. */ -#ifdef HAVE_QUOTA_SUPPORT - if ((bits & LA_UID && attr->la_uid != inode->i_uid) || - (bits & LA_GID && attr->la_gid != inode->i_gid)) { - struct osd_ctxt *save = &osd_oti_get(env)->oti_ctxt; - struct iattr iattr; - int rc; - - iattr.ia_valid = 0; - if (bits & LA_UID) - iattr.ia_valid |= ATTR_UID; - if (bits & LA_GID) - iattr.ia_valid |= ATTR_GID; - iattr.ia_uid = attr->la_uid; - iattr.ia_gid = attr->la_gid; - osd_push_ctxt(env, save); - rc = ll_vfs_dq_transfer(inode, &iattr) ? -EDQUOT : 0; - osd_pop_ctxt(save); - if (rc != 0) - return rc; - } -#endif - if (bits & LA_ATIME) inode->i_atime = *osd_inode_time(env, inode, attr->la_atime); if (bits & LA_CTIME) @@ -1390,6 +1368,7 @@ static int osd_attr_set(const struct lu_env *env, struct lustre_capa *capa) { struct osd_object *obj = osd_dt_obj(dt); + struct inode *inode; int rc; LASSERT(handle != NULL); @@ -1401,12 +1380,35 @@ static int osd_attr_set(const struct lu_env *env, OSD_EXEC_OP(handle, attr_set); + inode = obj->oo_inode; +#ifdef HAVE_QUOTA_SUPPORT + if ((attr->la_valid & LA_UID && attr->la_uid != inode->i_uid) || + (attr->la_valid & LA_GID && attr->la_gid != inode->i_gid)) { + struct osd_ctxt *save = &osd_oti_get(env)->oti_ctxt; + struct iattr iattr; + int rc; + + iattr.ia_valid = 0; + if (attr->la_valid & LA_UID) + iattr.ia_valid |= ATTR_UID; + if (attr->la_valid & LA_GID) + iattr.ia_valid |= ATTR_GID; + iattr.ia_uid = attr->la_uid; + iattr.ia_gid = attr->la_gid; + osd_push_ctxt(env, save); + rc = ll_vfs_dq_transfer(inode, &iattr) ? -EDQUOT : 0; + osd_pop_ctxt(save); + if (rc != 0) + return rc; + } +#endif + cfs_spin_lock(&obj->oo_guard); - rc = osd_inode_setattr(env, obj->oo_inode, attr); + rc = osd_inode_setattr(env, inode, attr); cfs_spin_unlock(&obj->oo_guard); if (!rc) - obj->oo_inode->i_sb->s_op->dirty_inode(obj->oo_inode); + inode->i_sb->s_op->dirty_inode(inode); return rc; } -- 1.8.3.1