Skip to contentSkip to conversation

quota: merge __dquot_transfer into dquot_transfer

PATCH In review Christoph Hellwig 2 participants 6 messages Mar 6, 2010 – Mar 8, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 quota: merge __dquot_transfer into dquot_transfer

fs/quota/dquot.c +13 -29
Index: linux-2.6/fs/quota/dquot.c
===================================================================
@@ -1676,8 +1676,10 @@ EXPORT_SYMBOL(dquot_free_inode);
  *
  * This operation can block, but only after everything is updated
  * A transaction must be started when entering this function.
+ *
+ * Called from ->setattr.
  */
-static int __dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask)
+int dquot_transfer(struct inode *inode, struct iattr *iattr)
 {
 	qsize_t space, cur_space;
 	qsize_t rsv_space = 0;
@@ -1689,18 +1691,23 @@ static int __dquot_transfer(struct inode
 
 	/* First test before acquiring mutex - solves deadlocks when we
          * re-enter the quota code and are already holding the mutex */
-	if (IS_NOQUOTA(inode))
+	if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
 		return 0;
+
+	dquot_initialize(inode);
+
 	/* Initialize the arrays */
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
 		transfer_from[cnt] = NULL;
 		transfer_to[cnt] = NULL;
 		warntype_to[cnt] = QUOTA_NL_NOWARN;
 	}
-	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
-		if (mask & (1 << cnt))
-			transfer_to[cnt] = dqget(inode->i_sb, chid[cnt], cnt);
-	}
+
+	if (iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid)
+		transfer_to[USRQUOTA] = dqget(inode->i_sb, iattr->ia_uid, cnt);
+	if (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)
+		transfer_to[GRPQUOTA] = dqget(inode->i_sb, iattr->ia_gid, cnt);
+
 	down_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
 	if (IS_NOQUOTA(inode)) {	/* File without quota accounting? */
 		up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1775,29 +1782,6 @@ over_quota:
 		transfer_from[cnt] = NULL;
 	goto warn_put_all;
 }
-
-/* Wrapper for transferring ownership of an inode for uid/gid only
- * Called from FSXXX_setattr()
- */
-int dquot_transfer(struct inode *inode, struct iattr *iattr)
-{
-	qid_t chid[MAXQUOTAS];
-	unsigned long mask = 0;
-
-	if (iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) {
-		mask |= 1 << USRQUOTA;
-		chid[USRQUOTA] = iattr->ia_uid;
-	}
-	if (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) {
-		mask |= 1 << GRPQUOTA;
-		chid[GRPQUOTA] = iattr->ia_gid;
-	}
-	if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode)) {
-		dquot_initialize(inode);
-		return __dquot_transfer(inode, chid, mask);
-	}
-	return 0;
-}
 EXPORT_SYMBOL(dquot_transfer);
 
 /*
reviewer
#1 lore raw
Quoted 1 line · Christoph Hellwig

Christoph, I see that you have removed the 'mask' argument of
dquot_transfer. Actually, this has been added a short time ago as a preparation for the project_id patches of Dmitry. Since his patches seem to be getting in a good shape, I'd prefer not to make his life harder and leave __dquot_transfer as is for now so that he can hook into it.

Honza

Quoted 76 lines

Index: linux-2.6/fs/quota/dquot.c
===================================================================

fs/quota/dquot.c +13 -29
@@ -1676,8 +1676,10 @@ EXPORT_SYMBOL(dquot_free_inode);
  *
  * This operation can block, but only after everything is updated
  * A transaction must be started when entering this function.
+ *
+ * Called from ->setattr.
  */
-static int __dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask)
+int dquot_transfer(struct inode *inode, struct iattr *iattr)
 {
 	qsize_t space, cur_space;
 	qsize_t rsv_space = 0;
@@ -1689,18 +1691,23 @@ static int __dquot_transfer(struct inode
 
 	/* First test before acquiring mutex - solves deadlocks when we
          * re-enter the quota code and are already holding the mutex */
-	if (IS_NOQUOTA(inode))
+	if (!sb_any_quota_active(inode->i_sb) || IS_NOQUOTA(inode))
 		return 0;
+
+	dquot_initialize(inode);
+
 	/* Initialize the arrays */
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
 		transfer_from[cnt] = NULL;
 		transfer_to[cnt] = NULL;
 		warntype_to[cnt] = QUOTA_NL_NOWARN;
 	}
-	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
-		if (mask & (1 << cnt))
-			transfer_to[cnt] = dqget(inode->i_sb, chid[cnt], cnt);
-	}
+
+	if (iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid)
+		transfer_to[USRQUOTA] = dqget(inode->i_sb, iattr->ia_uid, cnt);
+	if (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)
+		transfer_to[GRPQUOTA] = dqget(inode->i_sb, iattr->ia_gid, cnt);
+
 	down_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
 	if (IS_NOQUOTA(inode)) {	/* File without quota accounting? */
 		up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1775,29 +1782,6 @@ over_quota:
 		transfer_from[cnt] = NULL;
 	goto warn_put_all;
 }
-
-/* Wrapper for transferring ownership of an inode for uid/gid only
- * Called from FSXXX_setattr()
- */
-int dquot_transfer(struct inode *inode, struct iattr *iattr)
-{
-	qid_t chid[MAXQUOTAS];
-	unsigned long mask = 0;
-
-	if (iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) {
-		mask |= 1 << USRQUOTA;
-		chid[USRQUOTA] = iattr->ia_uid;
-	}
-	if (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) {
-		mask |= 1 << GRPQUOTA;
-		chid[GRPQUOTA] = iattr->ia_gid;
-	}
-	if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode)) {
-		dquot_initialize(inode);
-		return __dquot_transfer(inode, chid, mask);
-	}
-	return 0;
-}
 EXPORT_SYMBOL(dquot_transfer);
 
 /*
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#2 lore raw
Quoted 8 lines · Jan Kara
Quoted 1 line · Christoph Hellwig

Christoph, I see that you have removed the 'mask' argument of
dquot_transfer. Actually, this has been added a short time ago as a preparation for the project_id patches of Dmitry. Since his patches seem to be getting in a good shape, I'd prefer not to make his life harder and leave __dquot_transfer as is for now so that he can hook into it.

Dmitri will have to add code to grab the project ID somewhere. His patch made that easier when the two functions were split over an indirect call boundary, but now that this is gone it's not needed anymore. One line still needs to be added, and that's in the ne dquot_transfer.

reviewer
#3 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 8 lines · Jan Kara
Quoted 1 line · Christoph Hellwig

Christoph, I see that you have removed the 'mask' argument of
dquot_transfer. Actually, this has been added a short time ago as a preparation for the project_id patches of Dmitry. Since his patches seem to be getting in a good shape, I'd prefer not to make his life harder and leave __dquot_transfer as is for now so that he can hook into it.

Quoted 5 lines

Dmitri will have to add code to grab the project ID somewhere. His patch made that easier when the two functions were split over an indirect call boundary, but now that this is gone it's not needed anymore. One line still needs to be added, and that's in the ne dquot_transfer.

Hmm, but dquot_transfer gets new uid/gid from struct iattr. So either
we have to extend struct iattr to accompany also project_id changes (fine with me) or we have to keep interface similar to __dquot_transfer. Do you have any preference?

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#4 lore raw
Quoted 9 lines · Jan Kara
Quoted 5 lines

Dmitri will have to add code to grab the project ID somewhere. His patch made that easier when the two functions were split over an indirect call boundary, but now that this is gone it's not needed anymore. One line still needs to be added, and that's in the ne dquot_transfer.

Hmm, but dquot_transfer gets new uid/gid from struct iattr. So either
we have to extend struct iattr to accompany also project_id changes (fine with me) or we have to keep interface similar to __dquot_transfer. Do you have any preference?

If we promote the project ID to a first level VFS object like the last series does we should also add it to struct iattr. Anyway, I need to look through the project ID patches in more detail, I'm not quite happy yet with what I saw from quickly skipping over them. I'll try to get back to it tomorrow.

Quoted 6 lines

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR

---end quoted text---

reviewer
#5 lore raw
Quoted 6 lines · Christoph Hellwig
Quoted 5 lines · Jan Kara
Quoted 5 lines

Dmitri will have to add code to grab the project ID somewhere. His patch made that easier when the two functions were split over an indirect call boundary, but now that this is gone it's not needed anymore. One line still needs to be added, and that's in the ne dquot_transfer.

Quoted 7 lines
Quoted 4 lines

Hmm, but dquot_transfer gets new uid/gid from struct iattr. So either
we have to extend struct iattr to accompany also project_id changes (fine with me) or we have to keep interface similar to __dquot_transfer. Do you have any preference?

If we promote the project ID to a first level VFS object like the last series does we should also add it to struct iattr. Anyway, I need

OK, that would make sence.

Quoted 3 lines

to look through the project ID patches in more detail, I'm not quite happy yet with what I saw from quickly skipping over them. I'll try to get back to it tomorrow.

OK, I'll wait for a few days to see what you and Dmitry to agree on
before merging the patch. We are not in any hurry now...

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR