From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 2/2] ext4: fix seek_data for indirect layout
Date: Thu, 18 Dec 2014 19:59:06 +0400 [thread overview]
Message-ID: <1418918346-9546-2-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1418918346-9546-1-git-send-email-dmonakhov@openvz.org>
We obtain block mapping info via fiemap, in case of indirect inodes
it handled via generic_block_fiemap(). That function does not care
about delayed allocation. So we have to lookup delayed blocks explicitly.
*XFSTEST*
MKFS_OPTIONS: -- -q -O ^extents,^flex_bg,^uninit_bg /dev/vdc
MOUNT_OPTIONS: -- -o acl,user_xattr -o block_validity,nodelalloc /dev/vdc /vdc
TEST: generic/285
tested on following configurations: 4k, 1k, ext3, ext3-1k, ext3-1k-da
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
fs/ext4/file.c | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 8ec48a4..b0dc982 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -407,14 +407,26 @@ static loff_t ext4_seek_data(struct file *file, loff_t offset, loff_t maxsize)
struct inode *inode = file->f_mapping->host;
struct fiemap_extent_info fie;
struct fiemap_extent ext[2];
- loff_t next;
+ loff_t next, delayed = offset;
int i, ret = 0;
+ bool has_delay = false;
mutex_lock(&inode->i_mutex);
if (offset >= inode->i_size) {
mutex_unlock(&inode->i_mutex);
return -ENXIO;
}
+ /* Explicitly search for delayed blocks for indirect layout because
+ * generic_block_fiemap() can not do it for us. */
+ if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS) &&
+ test_opt(inode->i_sb, DELALLOC) &&
+ ext4_find_delayed_pgoff(inode, SEEK_DATA, maxsize, &delayed)) {
+ if (delayed == offset)
+ goto out;
+ maxsize = delayed;
+ has_delay = true;
+ }
+
fie.fi_flags = 0;
fie.fi_extents_max = 2;
fie.fi_extents_start = (struct fiemap_extent __user *) &ext;
@@ -432,7 +444,10 @@ static loff_t ext4_seek_data(struct file *file, loff_t offset, loff_t maxsize)
/* No extents found, EOF */
if (!fie.fi_extents_mapped) {
- ret = -ENXIO;
+ if (has_delay)
+ offset = delayed;
+ else
+ ret = -ENXIO;
break;
}
for (i = 0; i < fie.fi_extents_mapped; i++) {
@@ -496,6 +511,13 @@ static loff_t ext4_seek_hole(struct file *file, loff_t offset, loff_t maxsize)
while (1) {
mm_segment_t old_fs = get_fs();
+ /* Explicitly search for delayed blocks for indirect layout
+ because generic_block_fiemap() can not do it for us. */
+ if (!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS) &&
+ test_opt(inode->i_sb, DELALLOC))
+ ext4_find_delayed_pgoff(inode, SEEK_HOLE, maxsize,
+ &offset);
+
fie.fi_extents_mapped = 0;
memset(ext, 0, sizeof(*ext));
--
1.7.1
prev parent reply other threads:[~2014-12-18 15:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-18 15:59 [PATCH 1/2] ext4: fix seek_data cleanup Dmitry Monakhov
2014-12-18 15:59 ` Dmitry Monakhov [this message]
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=1418918346-9546-2-git-send-email-dmonakhov@openvz.org \
--to=dmonakhov@openvz.org \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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).