linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: jeff.liu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org
To: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: tytso-3s7WtUTddSA@public.gmane.org,
	jack-AlSwsSmVLrQ@public.gmane.org,
	david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org,
	hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
	bpm-sJ/iWh9BUns@public.gmane.org,
	christopher.jones-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	tm-d1IQDZat3X0@public.gmane.org,
	linux-ext4-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	chris.mason-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
	tinguely-sJ/iWh9BUns@public.gmane.org
Subject: [PATCH 11/11] container quota: bill container disk blocks alloc/free on ext4.
Date: Wed, 30 May 2012 22:59:05 +0800	[thread overview]
Message-ID: <1338389946-13711-12-git-send-email-jeff.liu@oracle.com> (raw)
In-Reply-To: <1338389946-13711-1-git-send-email-jeff.liu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

Bill up container disk blocks allocation and free on ext4.

Signed-off-by: Jie Liu <jeff.liu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
 fs/ext4/balloc.c  |    4 ++++
 fs/ext4/mballoc.c |   17 ++++++++++++++---
 fs/ext4/xattr.c   |    7 +++++++
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index c45c411..417d1de 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -21,6 +21,8 @@
 #include "ext4_jbd2.h"
 #include "mballoc.h"
 
+#include "../ns_quotaops.h"
+
 #include <trace/events/ext4.h>
 
 static unsigned ext4_num_base_meta_clusters(struct super_block *sb,
@@ -547,6 +549,8 @@ ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode,
 		spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
 		dquot_alloc_block_nofail(inode,
 				EXT4_C2B(EXT4_SB(inode->i_sb), ar.len));
+		ns_dquot_alloc_block_nofail(inode,
+				EXT4_C2B(EXT4_SB(inode->i_sb), ar.len));
 	}
 	return ret;
 }
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 99ab428..a373a9a 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -27,6 +27,8 @@
 #include <linux/slab.h>
 #include <trace/events/ext4.h>
 
+#include "../ns_quotaops.h"
+
 /*
  * MUSTDO:
  *   - test ext4_ext_search_left() and ext4_ext_search_right()
@@ -4271,10 +4273,14 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
 		if (ar->flags & EXT4_MB_USE_ROOT_BLOCKS) {
 			dquot_alloc_block_nofail(ar->inode,
 						 EXT4_C2B(sbi, ar->len));
+			ns_dquot_alloc_block_nofail(ar->inode,
+						 EXT4_C2B(sbi, ar->len));
 		} else {
 			while (ar->len &&
 				dquot_alloc_block(ar->inode,
-						  EXT4_C2B(sbi, ar->len))) {
+						  EXT4_C2B(sbi, ar->len)) &&
+				ns_dquot_alloc_block(ar->inode,
+						     EXT4_C2B(sbi, ar->len))) {
 
 				ar->flags |= EXT4_MB_HINT_NOPREALLOC;
 				ar->len--;
@@ -4353,8 +4359,11 @@ repeat:
 out:
 	if (ac)
 		kmem_cache_free(ext4_ac_cachep, ac);
-	if (inquota && ar->len < inquota)
+	if (inquota && ar->len < inquota) {
 		dquot_free_block(ar->inode, EXT4_C2B(sbi, inquota - ar->len));
+		ns_dquot_free_block(ar->inode,
+				    EXT4_C2B(sbi, inquota - ar->len));
+	}
 	if (!ar->len) {
 		if (!ext4_test_inode_state(ar->inode,
 					   EXT4_STATE_DELALLOC_RESERVED))
@@ -4673,8 +4682,10 @@ do_more:
 
 	freed += count;
 
-	if (!(flags & EXT4_FREE_BLOCKS_NO_QUOT_UPDATE))
+	if (!(flags & EXT4_FREE_BLOCKS_NO_QUOT_UPDATE)) {
 		dquot_free_block(inode, EXT4_C2B(sbi, count_clusters));
+		ns_dquot_free_block(inode, EXT4_C2B(sbi, count_clusters));
+	}
 
 	/* We dirtied the bitmap block */
 	BUFFER_TRACE(bitmap_bh, "dirtied bitmap block");
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index e88748e..1d6bc49 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -61,6 +61,8 @@
 #include "xattr.h"
 #include "acl.h"
 
+#include "../ns_quotaops.h"
+
 #define BHDR(bh) ((struct ext4_xattr_header *)((bh)->b_data))
 #define ENTRY(ptr) ((struct ext4_xattr_entry *)(ptr))
 #define BFIRST(bh) ENTRY(BHDR(bh)+1)
@@ -496,6 +498,7 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode,
 		if (IS_SYNC(inode))
 			ext4_handle_sync(handle);
 		dquot_free_block(inode, 1);
+		ns_dquot_free_block(inode, 1);
 		ea_bdebug(bh, "refcount now=%d; releasing",
 			  le32_to_cpu(BHDR(bh)->h_refcount));
 	}
@@ -787,6 +790,9 @@ inserted:
 				error = dquot_alloc_block(inode, 1);
 				if (error)
 					goto cleanup;
+				error = ns_dquot_alloc_block(inode, 1);
+				if (error)
+					goto cleanup;
 				error = ext4_journal_get_write_access(handle,
 								      new_bh);
 				if (error)
@@ -881,6 +887,7 @@ cleanup:
 
 cleanup_dquot:
 	dquot_free_block(inode, 1);
+	ns_dquot_free_block(inode, 1);
 	goto cleanup;
 
 bad_block:
-- 
1.7.9

  parent reply	other threads:[~2012-05-30 14:59 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-30 14:58 container disk quota jeff.liu-QHcLZuEGTsvQT0dZR+AlfA
     [not found] ` <1338389946-13711-1-git-send-email-jeff.liu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-05-30 14:58   ` [PATCH 01/12] container quota: add kernel configuration for container quota jeff.liu-QHcLZuEGTsvQT0dZR+AlfA
     [not found]     ` <1338389946-13711-2-git-send-email-jeff.liu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-05-31  9:00       ` Glauber Costa
2012-05-31  9:01         ` Glauber Costa
2012-05-30 14:58   ` [PATCH 02/12] container quota: lock/unlock mount namespace when performing quotactl jeff.liu-QHcLZuEGTsvQT0dZR+AlfA
     [not found]     ` <1338389946-13711-3-git-send-email-jeff.liu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-05-31  9:04       ` Glauber Costa
     [not found]         ` <4FC73418.1040402-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-31 12:40           ` Jeff Liu
2012-05-30 14:58   ` [PATCH 03/12] container quota: introduce container quota format identifier jeff.liu-QHcLZuEGTsvQT0dZR+AlfA
2012-05-30 14:58   ` [PATCH 04/12] container quota: introduce container disk quota data header file jeff.liu-QHcLZuEGTsvQT0dZR+AlfA
2012-05-31  9:10     ` Glauber Costa
     [not found]       ` <4FC735A2.4040400-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-31 12:53         ` Jeff Liu
2012-05-30 14:58   ` [PATCH 05/12] container quota: bind disk quota stuff on mount namespace jeff.liu-QHcLZuEGTsvQT0dZR+AlfA
2012-05-30 14:59   ` [PATCH 06/12] container quota: implementations and header for block/inode bill up jeff.liu-QHcLZuEGTsvQT0dZR+AlfA
2012-05-30 14:59   ` [PATCH 07/12] container quota: add quota control source file jeff.liu-QHcLZuEGTsvQT0dZR+AlfA
2012-05-30 14:59   ` [PATCH 08/12] container quota: let quotactl(2) works for container jeff.liu-QHcLZuEGTsvQT0dZR+AlfA
2012-05-30 14:59   ` [PATCH 09/12] container quota: add container disk quota entry to Makefile jeff.liu-QHcLZuEGTsvQT0dZR+AlfA
2012-05-30 14:59   ` [PATCH 10/12] container quota: bill container inodes alloc/free on ext4 jeff.liu-QHcLZuEGTsvQT0dZR+AlfA
     [not found]     ` <1338389946-13711-11-git-send-email-jeff.liu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-05-30 15:55       ` Ted Ts'o
     [not found]         ` <20120530155543.GB13236-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2012-05-31  1:43           ` Jeff Liu
     [not found]             ` <4FC6CCB6.4090908-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-05-31  1:54               ` Ted Ts'o
     [not found]                 ` <20120531015453.GA6759-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2012-05-31  2:37                   ` Jeff Liu
     [not found]                     ` <4FC6D94D.6040106-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-05-31  3:24                       ` Jeff Liu
2012-05-31  9:15       ` Glauber Costa
     [not found]         ` <4FC736AD.2070404-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-31 12:58           ` Jeff Liu
     [not found]             ` <4FC76B0D.6020804-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-05-31 13:14               ` Glauber Costa
     [not found]                 ` <4FC76ECA.3070301-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-31 13:43                   ` Jeff Liu
2012-06-05  0:03                 ` Dave Chinner
2012-05-30 14:59   ` jeff.liu-QHcLZuEGTsvQT0dZR+AlfA [this message]
2012-05-30 14:59   ` [PATCH 12/12] container quota: init/destroy container dqinfo on mount namespace jeff.liu-QHcLZuEGTsvQT0dZR+AlfA
2012-05-31  8:54   ` container disk quota Glauber Costa
     [not found]     ` <4FC731C1.5000903-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-31  9:19       ` Glauber Costa
     [not found]         ` <4FC7378B.2030707-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-05-31 13:04           ` Jeff Liu
2012-05-31 12:31       ` Jeff Liu
2012-06-01 15:54   ` Jan Kara
     [not found]     ` <20120601155457.GA30909-+0h/O2h83AeN3ZZ/Hiejyg@public.gmane.org>
2012-06-01 16:04       ` Serge Hallyn
2012-06-02  5:59         ` Jeff Liu
2012-06-02  6:06           ` Kirill Korotaev
     [not found]             ` <01FED15D-15A3-4542-B95B-1166F0A309E6-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-06-02  6:24               ` Jeff Liu
     [not found]                 ` <4FC9B183.10605-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-06-02 15:21                   ` Kirill Korotaev
     [not found]                     ` <8660DDAA-D7A7-4C03-8CBB-9DB7E94C80CB-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-06-03  4:23                       ` Jeff Liu
     [not found]                         ` <4FCAE6CB.8060208-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-06-03  5:47                           ` Kirill Korotaev
     [not found]                             ` <81DE9C10-649B-4D13-86B0-200944AE8767-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-06-03  6:02                               ` Jeff Liu
2012-06-03  9:48                             ` Glauber Costa
2012-06-04  2:57           ` Serge Hallyn
2012-06-04  4:46             ` Jeff Liu
     [not found]               ` <4FCC3DB9.40105-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-06-04  9:42                 ` Jan Kara
     [not found]                   ` <20120604094224.GA7670-+0h/O2h83AeN3ZZ/Hiejyg@public.gmane.org>
2012-06-04 13:35                     ` Jeff Liu
2012-06-04 13:56                       ` Jan Kara
     [not found]                         ` <20120604135615.GD11010-+0h/O2h83AeN3ZZ/Hiejyg@public.gmane.org>
2012-06-04 14:55                           ` Jeff Liu
     [not found]                             ` <4FCCCC64.5060301-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-06-04 15:50                               ` Jeff Liu
2012-06-02  5:42       ` Jeff Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1338389946-13711-12-git-send-email-jeff.liu@oracle.com \
    --to=jeff.liu-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=bpm-sJ/iWh9BUns@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=chris.mason-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=christopher.jones-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org \
    --cc=hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=jack-AlSwsSmVLrQ@public.gmane.org \
    --cc=linux-ext4-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=tinguely-sJ/iWh9BUns@public.gmane.org \
    --cc=tm-d1IQDZat3X0@public.gmane.org \
    --cc=tytso-3s7WtUTddSA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).