All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chandan Rajendra <chandan@linux.vnet.ibm.com>
To: linux-btrfs@vger.kernel.org
Cc: Chandan Rajendra <chandan@linux.vnet.ibm.com>,
	jbacik@fb.com, clm@fb.com, bo.li.liu@oracle.com, dsterba@suse.cz,
	chandan@mykolab.com
Subject: [RFC PATCH V12 10/14] Btrfs: subpagesize-blocksize: btrfs_punch_hole: Use EXTENT_UPTODATE bit to check for the presence of block in page cache
Date: Mon, 16 Nov 2015 12:38:37 +0530	[thread overview]
Message-ID: <1447657721-10025-11-git-send-email-chandan@linux.vnet.ibm.com> (raw)
In-Reply-To: <1447657721-10025-1-git-send-email-chandan@linux.vnet.ibm.com>

In subpagesize-blocksize, we have multiple blocks in a page. Checking for
existence of a page in the page cache isn't a sufficient check, since we could
be truncating a subset of the blocks mapped by the page. So if the blocks that
are neighboring the truncated block exist in the page cache,
btrfs_page_exists_in_range() would always return 1. Hence check for the
existence of EXTENT_UPTODATE bit on the file range mapped by the block being
punched out.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
---
 fs/btrfs/btrfs_inode.h | 2 --
 fs/btrfs/file.c        | 4 +++-
 fs/btrfs/inode.c       | 3 ++-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 0ef5cc1..2bf8043 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -323,6 +323,4 @@ static inline void btrfs_inode_resume_unlocked_dio(struct inode *inode)
 		  &BTRFS_I(inode)->runtime_flags);
 }
 
-bool btrfs_page_exists_in_range(struct inode *inode, loff_t start, loff_t end);
-
 #endif
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 386299f..2c0fd01 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2439,7 +2439,9 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
 		if ((!ordered ||
 		    (ordered->file_offset + ordered->len <= lockstart ||
 		     ordered->file_offset > lockend)) &&
-		     !btrfs_page_exists_in_range(inode, lockstart, lockend)) {
+		     !test_range_bit(&BTRFS_I(inode)->io_tree, lockstart,
+				     lockend, EXTENT_UPTODATE, 0,
+				     cached_state)) {
 			if (ordered)
 				btrfs_put_ordered_extent(ordered);
 			break;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index fea4693..bd96bac 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7434,7 +7434,8 @@ out:
 	return ret;
 }
 
-bool btrfs_page_exists_in_range(struct inode *inode, loff_t start, loff_t end)
+static bool btrfs_page_exists_in_range(struct inode *inode, loff_t start,
+				loff_t end)
 {
 	struct radix_tree_root *root = &inode->i_mapping->page_tree;
 	int found = false;
-- 
2.1.0


  parent reply	other threads:[~2015-11-16  7:09 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-16  7:08 [RFC PATCH V12 00/14] Btrfs: Subpagesize-blocksize: Allow I/O on blocks whose size is less than page size Chandan Rajendra
2015-11-16  7:08 ` [RFC PATCH V12 01/14] Btrfs: subpagesize-blocksize: Fix whole page read Chandan Rajendra
2015-11-16  7:08 ` [RFC PATCH V12 02/14] Btrfs: subpagesize-blocksize: Fix whole page write Chandan Rajendra
2015-11-16  7:08 ` [RFC PATCH V12 03/14] Btrfs: subpagesize-blocksize: Make sure delalloc range intersects with the locked page's range Chandan Rajendra
2015-11-16  7:08 ` [RFC PATCH V12 04/14] Btrfs: subpagesize-blocksize: Define extent_buffer_head Chandan Rajendra
2015-11-16  7:08 ` [RFC PATCH V12 05/14] Btrfs: subpagesize-blocksize: Read tree blocks whose size is < PAGE_SIZE Chandan Rajendra
2015-11-16  7:08 ` [RFC PATCH V12 06/14] Btrfs: subpagesize-blocksize: Write only dirty extent buffers belonging to a page Chandan Rajendra
2015-11-16  7:08 ` [RFC PATCH V12 07/14] Btrfs: subpagesize-blocksize: Allow mounting filesystems where sectorsize != PAGE_SIZE Chandan Rajendra
2015-11-16  7:08 ` [RFC PATCH V12 08/14] Btrfs: subpagesize-blocksize: Deal with partial ordered extent allocations Chandan Rajendra
2015-11-16  7:08 ` [RFC PATCH V12 09/14] Btrfs: subpagesize-blocksize: Explicitly track I/O status of blocks of an ordered extent Chandan Rajendra
2015-11-16  7:08 ` Chandan Rajendra [this message]
2015-11-16  7:08 ` [RFC PATCH V12 11/14] Btrfs: subpagesize-blocksize: Prevent writes to an extent buffer when PG_writeback flag is set Chandan Rajendra
2015-11-16  7:08 ` [RFC PATCH V12 12/14] Revert "btrfs: fix lockups from btrfs_clear_path_blocking" Chandan Rajendra
2015-11-16  7:08 ` [RFC PATCH V12 13/14] Btrfs: subpagesize-blocksize: Fix file defragmentation code Chandan Rajendra
2015-11-16  7:08 ` [RFC PATCH V12 14/14] Btrfs: subpagesize-blocksize: extent_clear_unlock_delalloc: Prevent page from being unlocked more than once Chandan Rajendra
2015-11-16  8:01 ` [RFC PATCH V12 00/14] Btrfs: Subpagesize-blocksize: Allow I/O on blocks whose size is less than page size Chandan Rajendra
2015-11-18 13:41 ` Chandan Rajendra

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=1447657721-10025-11-git-send-email-chandan@linux.vnet.ibm.com \
    --to=chandan@linux.vnet.ibm.com \
    --cc=bo.li.liu@oracle.com \
    --cc=chandan@mykolab.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.cz \
    --cc=jbacik@fb.com \
    --cc=linux-btrfs@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.