Skip to contentSkip to conversation

quota: Add quota claim and release reserved quota blocks operations

PATCH Superseded Mingming Cao 2 participants 3 messages Dec 12, 2008 – Jan 6, 2009

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 2/3 quota: Add quota claim and release reserved quota blocks operations

quota: Add quota reservation claim and released operations

Reserved quota will be claimed at the block allocation time. Over-booked quota could be returned back with the release callback function.

---
 fs/dquot.c               |  101 +++++++++++++++++++++++++++++++++++++++++++++--
 include/linux/quota.h    |    4 +
 include/linux/quotaops.h |   53 ++++++++++++++++++++++++
 3 files changed, 153 insertions(+), 5 deletions(-)
include/linux/quota.h +3 -1
Index: linux-2.6.28-rc2/include/linux/quota.h
===================================================================
@@ -292,7 +292,9 @@ struct dquot_operations {
 	int (*release_dquot) (struct dquot *);		/* Quota is going to be deleted from disk */
 	int (*mark_dirty) (struct dquot *);		/* Dquot is marked dirty */
 	int (*write_info) (struct super_block *, int);	/* Write of quota "superblock" */
-	int (*reserve_space) (struct inode *, qsize_t, int); /* reserve quota for delayed block allocation */
+	int (*reserve_space) (struct inode *, qsize_t, int); /* reserve quota for delayed alloc */
+	int (*claim_space) (struct inode *, qsize_t); /* claim reserved quota for delayed alloc */
+	void (*release_rsv) (struct inode *, qsize_t); /* release rsved quota for delayed alloc */
 };
 
 /* Operations handling requests from userspace */
include/linux/quotaops.h +53 -0

77 lines not on this page · raw message

fs/dquot.c +97 -4

145 lines not on this page · raw message

reviewer
#1 lore raw

Hi Mingming,

sorry I spoke to soon in my previous email. You tried to resolve the
issue with dquot_transfer(). I just thought it would belong to the first patch...

Quoted 12 lines · Mingming Cao

quota: Add quota reservation claim and released operations

Reserved quota will be claimed at the block allocation time. Over-booked quota could be returned back with the release callback function.

---
 fs/dquot.c               |  101 +++++++++++++++++++++++++++++++++++++++++++++--
 include/linux/quota.h    |    4 +
 include/linux/quotaops.h |   53 ++++++++++++++++++++++++
 3 files changed, 153 insertions(+), 5 deletions(-)

<snip>

Quoted 4 lines

Index: linux-2.6.28-rc2/fs/dquot.c
===================================================================

fs/dquot.c +0 -0

<snip>

Quoted 14 lines
fs/dquot.c +2 -1
@@ -1448,7 +1532,8 @@ int dquot_free_inode(const struct inode 
  */
 int dquot_transfer(struct inode *inode, struct iattr *iattr)
 {
-	qsize_t space;
+	qsize_t space, cur_space;
+	qsize_t rsv_space = 0;
 	struct dquot *transfer_from[MAXQUOTAS];
 	struct dquot *transfer_to[MAXQUOTAS];
 	int cnt, ret = NO_QUOTA, chuid = (iattr->ia_valid & ATTR_UID) && inode->i_uid != iattr->ia_uid,
@@ -1489,12 +1574,16 @@ int dquot_transfer(struct inode *inode, 
 		}
 	}
 	spin_lock(&dq_data_lock);

fs/dquot.c int dquot_transfer(struct inode *inode, · line 1585

Quoted 10 lines
fs/dquot.c +4 -1
-	space = inode_get_bytes(inode);
+	space = cur_space = inode_get_bytes(inode);
 	/* Build the transfer_from list and check the limits */
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
 		if (transfer_to[cnt] == NODQUOT)
 			continue;
 		transfer_from[cnt] = inode->i_dquot[cnt];
+		if (!rsv_space) {
+			rsv_space = transfer_from[cnt]->dq_dqb.dqb_rsvspace;
+			space += rsv_space;

Hmm, but you cannot simply transfer all the reserved space from one user
to another. You have to transfer just the amount reserved for this inode (i.e. EXT4_I(inode)->i_reserved_data_blocks + EXT4_I(inode)->i_reserved_meta_blocks). The fact is this is not available to quota code. One possibility is to store this number in VFS inode (which I guess people would not like because it would increase every inode size by 8 bytes). So probably more plausible is to provide a callback so that quota code can find out how much space this inode has reserved. This is not a performance critical operation so the cost of the function call is acceptable here IMO.

Quoted 10 lines
fs/dquot.c +2 -1
+		}
 		if (check_idq(transfer_to[cnt], 1, warntype_to + cnt) ==
 		    NO_QUOTA || check_bdq(transfer_to[cnt], space, 0,
 		    warntype_to + cnt) == NO_QUOTA)
@@ -1518,11 +1607,13 @@ int dquot_transfer(struct inode *inode, 
 			warntype_from_space[cnt] =
 				info_bdq_free(transfer_from[cnt], space);
 			dquot_decr_inodes(transfer_from[cnt], 1);
-			dquot_decr_space(transfer_from[cnt], space);
+			dquot_decr_space(transfer_from[cnt], cur_space);

fs/dquot.c int dquot_transfer(struct inode *inode, · line 1619

Quoted 10 lines
fs/dquot.c +3 -1
+			dquot_free_reserved_space(transfer_from[cnt], rsv_space);
 		}
 
 		dquot_incr_inodes(transfer_to[cnt], 1);
-		dquot_incr_space(transfer_to[cnt], space);
+		dquot_incr_space(transfer_to[cnt], cur_space);
+		dquot_resv_space(transfer_to[cnt], rsv_space);
 
 		inode->i_dquot[cnt] = transfer_to[cnt];
 	}

Honza

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

Hi Jan,

Thanks for your comments. Sorry for the late the response while holiday in the way.

Quoted 53 lines · 在 2008-12-15一的 14:40 +0100,Jan Kara写道:

Hi Mingming,

sorry I spoke to soon in my previous email. You tried to resolve the
issue with dquot_transfer(). I just thought it would belong to the first patch...

Quoted 12 lines · Mingming Cao

quota: Add quota reservation claim and released operations

Reserved quota will be claimed at the block allocation time. Over-booked quota could be returned back with the release callback function.

---
 fs/dquot.c               |  101 +++++++++++++++++++++++++++++++++++++++++++++--
 include/linux/quota.h    |    4 +
 include/linux/quotaops.h |   53 ++++++++++++++++++++++++
 3 files changed, 153 insertions(+), 5 deletions(-)

<snip>

Quoted 4 lines

Index: linux-2.6.28-rc2/fs/dquot.c
===================================================================

fs/dquot.c +0 -0

<snip>

Quoted 14 lines
fs/dquot.c +2 -1
@@ -1448,7 +1532,8 @@ int dquot_free_inode(const struct inode 
  */
 int dquot_transfer(struct inode *inode, struct iattr *iattr)
 {
-	qsize_t space;
+	qsize_t space, cur_space;
+	qsize_t rsv_space = 0;
 	struct dquot *transfer_from[MAXQUOTAS];
 	struct dquot *transfer_to[MAXQUOTAS];
 	int cnt, ret = NO_QUOTA, chuid = (iattr->ia_valid & ATTR_UID) && inode->i_uid != iattr->ia_uid,
@@ -1489,12 +1574,16 @@ int dquot_transfer(struct inode *inode, 
 		}
 	}
 	spin_lock(&dq_data_lock);

fs/dquot.c int dquot_transfer(struct inode *inode, · line 1585

Quoted 10 lines
fs/dquot.c +4 -1
-	space = inode_get_bytes(inode);
+	space = cur_space = inode_get_bytes(inode);
 	/* Build the transfer_from list and check the limits */
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
 		if (transfer_to[cnt] == NODQUOT)
 			continue;
 		transfer_from[cnt] = inode->i_dquot[cnt];
+		if (!rsv_space) {
+			rsv_space = transfer_from[cnt]->dq_dqb.dqb_rsvspace;
+			space += rsv_space;

Hmm, but you cannot simply transfer all the reserved space from one user
to another. You have to transfer just the amount reserved for this inode

Quoted 9 lines

(i.e. EXT4_I(inode)->i_reserved_data_blocks + EXT4_I(inode)->i_reserved_meta_blocks). The fact is this is not available to quota code. One possibility is to store this number in VFS inode (which I guess people would not like because it would increase every inode size by 8 bytes). So probably more plausible is to provide a callback so that quota code can find out how much space this inode has reserved. This is not a performance critical operation so the cost of the function call is acceptable here IMO.

You are right, that's what I was misunderstand before. I will send out updated quota patches.

Mingming

Quoted 18 lines
Quoted 18 lines
fs/dquot.c +5 -2
+		}
 		if (check_idq(transfer_to[cnt], 1, warntype_to + cnt) ==
 		    NO_QUOTA || check_bdq(transfer_to[cnt], space, 0,
 		    warntype_to + cnt) == NO_QUOTA)
@@ -1518,11 +1607,13 @@ int dquot_transfer(struct inode *inode, 
 			warntype_from_space[cnt] =
 				info_bdq_free(transfer_from[cnt], space);
 			dquot_decr_inodes(transfer_from[cnt], 1);
-			dquot_decr_space(transfer_from[cnt], space);
+			dquot_decr_space(transfer_from[cnt], cur_space);
+			dquot_free_reserved_space(transfer_from[cnt], rsv_space);
 		}
 
 		dquot_incr_inodes(transfer_to[cnt], 1);
-		dquot_incr_space(transfer_to[cnt], space);
+		dquot_incr_space(transfer_to[cnt], cur_space);
+		dquot_resv_space(transfer_to[cnt], rsv_space);
 
Quoted 4 lines

fs/dquot.c int dquot_transfer(struct inode *inode, · line 1619

Quoted 2 lines
fs/dquot.c +0 -0
 		inode->i_dquot[cnt] = transfer_to[cnt];
 	}

Honza

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html