linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] quota: merge __dquot_transfer into dquot_transfer
@ 2010-03-06 13:17 Christoph Hellwig
  2010-03-08 17:11 ` Jan Kara
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2010-03-06 13:17 UTC (permalink / raw)
  To: jack; +Cc: linux-fsdevel

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/fs/quota/dquot.c
===================================================================
--- linux-2.6.orig/fs/quota/dquot.c	2010-03-06 12:47:10.086024843 +0100
+++ linux-2.6/fs/quota/dquot.c	2010-03-06 12:47:42.171272853 +0100
@@ -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);
 
 /*

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] quota: merge __dquot_transfer into dquot_transfer
  2010-03-06 13:17 [PATCH 1/2] quota: merge __dquot_transfer into dquot_transfer Christoph Hellwig
@ 2010-03-08 17:11 ` Jan Kara
  2010-03-08 17:13   ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kara @ 2010-03-08 17:11 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: jack, linux-fsdevel, dmonakhov

On Sat 06-03-10 08:17:53, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch@lst.de>
  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
> 
> Index: linux-2.6/fs/quota/dquot.c
> ===================================================================
> --- linux-2.6.orig/fs/quota/dquot.c	2010-03-06 12:47:10.086024843 +0100
> +++ linux-2.6/fs/quota/dquot.c	2010-03-06 12:47:42.171272853 +0100
> @@ -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);
>  
>  /*
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] quota: merge __dquot_transfer into dquot_transfer
  2010-03-08 17:11 ` Jan Kara
@ 2010-03-08 17:13   ` Christoph Hellwig
  2010-03-08 17:39     ` Jan Kara
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2010-03-08 17:13 UTC (permalink / raw)
  To: Jan Kara; +Cc: Christoph Hellwig, linux-fsdevel, dmonakhov

On Mon, Mar 08, 2010 at 06:11:34PM +0100, Jan Kara wrote:
> On Sat 06-03-10 08:17:53, Christoph Hellwig wrote:
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
>   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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] quota: merge __dquot_transfer into dquot_transfer
  2010-03-08 17:13   ` Christoph Hellwig
@ 2010-03-08 17:39     ` Jan Kara
  2010-03-08 17:42       ` Christoph Hellwig
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Kara @ 2010-03-08 17:39 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Jan Kara, linux-fsdevel, dmonakhov

On Mon 08-03-10 12:13:08, Christoph Hellwig wrote:
> On Mon, Mar 08, 2010 at 06:11:34PM +0100, Jan Kara wrote:
> > On Sat 06-03-10 08:17:53, Christoph Hellwig wrote:
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> >   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.
  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

-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] quota: merge __dquot_transfer into dquot_transfer
  2010-03-08 17:39     ` Jan Kara
@ 2010-03-08 17:42       ` Christoph Hellwig
  2010-03-08 18:04         ` Jan Kara
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2010-03-08 17:42 UTC (permalink / raw)
  To: Jan Kara; +Cc: Christoph Hellwig, linux-fsdevel, dmonakhov

On Mon, Mar 08, 2010 at 06:39:28PM +0100, Jan Kara wrote:
> > 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.

> 
> 								Honza
> 
> -- 
> Jan Kara <jack@suse.cz>
> SUSE Labs, CR
---end quoted text---

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] quota: merge __dquot_transfer into dquot_transfer
  2010-03-08 17:42       ` Christoph Hellwig
@ 2010-03-08 18:04         ` Jan Kara
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Kara @ 2010-03-08 18:04 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Jan Kara, linux-fsdevel, dmonakhov

On Mon 08-03-10 12:42:07, Christoph Hellwig wrote:
> On Mon, Mar 08, 2010 at 06:39:28PM +0100, Jan Kara wrote:
> > > 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
  OK, that would make sence.

> 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
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-03-08 18:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-06 13:17 [PATCH 1/2] quota: merge __dquot_transfer into dquot_transfer Christoph Hellwig
2010-03-08 17:11 ` Jan Kara
2010-03-08 17:13   ` Christoph Hellwig
2010-03-08 17:39     ` Jan Kara
2010-03-08 17:42       ` Christoph Hellwig
2010-03-08 18:04         ` Jan Kara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).