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]
Message-Id: <1359668994-13433-4-git-send-email-jack@suse.cz>
Date:	Thu, 31 Jan 2013 22:49:51 +0100
From:	Jan Kara <jack@...e.cz>
To:	LKML <linux-kernel@...r.kernel.org>
Cc:	linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
	Jan Kara <jack@...e.cz>
Subject: [PATCH 3/6] fs: Provide function to take mapping lock in buffered write path

Add a flag to grab_cache_page_write_begin() which makes the function grab
mapping range lock while creating the page in page cache. Callers that don't
need special lock ordering for the mapping range lock (e.g. xfs) can use
this flag.

Signed-off-by: Jan Kara <jack@...e.cz>
---
 include/linux/fs.h |    2 ++
 mm/filemap.c       |    7 +++++++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2027d25..1e0a1e4 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -281,6 +281,8 @@ enum positive_aop_returns {
 #define AOP_FLAG_NOFS			0x0004 /* used by filesystem to direct
 						* helper code (eg buffer layer)
 						* to clear GFP_FS from alloc */
+#define AOP_FLAG_LOCK_MAPPING		0x0008 /* Lock mapping range where
+						* page is create */
 
 /*
  * oh the beauties of C type declarations.
diff --git a/mm/filemap.c b/mm/filemap.c
index 4826cb4..f4a9e9a 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2266,6 +2266,7 @@ struct page *grab_cache_page_write_begin(struct address_space *mapping,
 	gfp_t gfp_mask;
 	struct page *page;
 	gfp_t gfp_notmask = 0;
+	struct range_lock mapping_lock;
 
 	gfp_mask = mapping_gfp_mask(mapping);
 	if (mapping_cap_account_dirty(mapping))
@@ -2280,8 +2281,14 @@ repeat:
 	page = __page_cache_alloc(gfp_mask & ~gfp_notmask);
 	if (!page)
 		return NULL;
+	if (flags & AOP_FLAG_LOCK_MAPPING) {
+		range_lock_init(&mapping_lock, index, index);
+		range_lock(&mapping->mapping_lock, &mapping_lock);
+	}
 	status = add_to_page_cache_lru(page, mapping, index,
 						GFP_KERNEL & ~gfp_notmask);
+	if (flags & AOP_FLAG_LOCK_MAPPING)
+		range_unlock(&mapping->mapping_lock, &mapping_lock);
 	if (unlikely(status)) {
 		page_cache_release(page);
 		if (status == -EEXIST)
-- 
1.7.1

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ