lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 30 May 2012 22:59:05 +0800
From:	jeff.liu@...cle.com
To:	containers@...ts.linux-foundation.org
Cc:	cgroups@...r.kernel.org, jack@...e.cz, glommer@...allels.com,
	daniel.lezcano@...e.fr, tytso@....edu, bpm@....com,
	chris.mason@...cle.com, hch@...radead.org,
	christopher.jones@...cle.com, david@...morbit.com,
	tinguely@....com, tm@....ma, linux-ext4@...r.kernel.org,
	linux-fsdevel@...r.kernel.org, Jie Liu <jeff.liu@...cle.com>
Subject: [PATCH 11/11] container quota: bill container disk blocks alloc/free on ext4.

Bill up container disk blocks allocation and free on ext4.

Signed-off-by: Jie Liu <jeff.liu@...cle.com>
---
 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

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ