From: Eric Biggers <ebiggers@kernel.org>
To: linux-fscrypt@vger.kernel.org
Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH 2/6] ext4: skip truncate when verity in progress in ->write_begin()
Date: Sun, 11 Aug 2019 14:35:53 -0700 [thread overview]
Message-ID: <20190811213557.1970-3-ebiggers@kernel.org> (raw)
In-Reply-To: <20190811213557.1970-1-ebiggers@kernel.org>
From: Eric Biggers <ebiggers@google.com>
When an error (e.g. ENOSPC) occurs during ext4_write_begin() when called
from ext4_write_merkle_tree_block(), skip truncating the file. i_size
is not meaningful in this case, and the truncation is handled by
ext4_end_enable_verity() instead. Also, this was triggering the
WARN_ON(!inode_is_locked(inode)) in ext4_truncate().
Fixes: ea54d7e4c0f8 ("ext4: add basic fs-verity support")
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
fs/ext4/inode.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index b2c8d09acf652..cf0fce1173a4c 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1340,6 +1340,9 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
}
if (ret) {
+ bool extended = (pos + len > inode->i_size) &&
+ !ext4_verity_in_progress(inode);
+
unlock_page(page);
/*
* __block_write_begin may have instantiated a few blocks
@@ -1349,11 +1352,11 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
* Add inode to orphan list in case we crash before
* truncate finishes
*/
- if (pos + len > inode->i_size && ext4_can_truncate(inode))
+ if (extended && ext4_can_truncate(inode))
ext4_orphan_add(handle, inode);
ext4_journal_stop(handle);
- if (pos + len > inode->i_size) {
+ if (extended) {
ext4_truncate_failed_write(inode);
/*
* If truncate failed early the inode might
--
2.22.0
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2019-08-11 21:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-11 21:35 [f2fs-dev] [PATCH 0/6] fs-verity fixups Eric Biggers
2019-08-11 21:35 ` [f2fs-dev] [PATCH 1/6] fs-verity: fix crash on read error in build_merkle_tree_level() Eric Biggers
2019-08-11 21:35 ` Eric Biggers [this message]
2019-08-11 21:35 ` [f2fs-dev] [PATCH 3/6] f2fs: skip truncate when verity in progress in ->write_begin() Eric Biggers
2019-08-12 12:25 ` Chao Yu
2019-08-12 22:58 ` Eric Biggers
2019-08-13 2:40 ` Chao Yu
2019-08-18 20:24 ` Eric Biggers
2019-08-11 21:35 ` [f2fs-dev] [PATCH 4/6] ext4: remove ext4_bio_encrypted() Eric Biggers
2019-08-11 21:35 ` [f2fs-dev] [PATCH 5/6] ext4: fix comment in ext4_end_enable_verity() Eric Biggers
2019-08-11 21:35 ` [f2fs-dev] [PATCH 6/6] f2fs: use EFSCORRUPTED in f2fs_get_verity_descriptor() Eric Biggers
2019-08-12 12:26 ` Chao Yu
2019-08-18 20:23 ` [f2fs-dev] [PATCH 0/6] fs-verity fixups Eric Biggers
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=20190811213557.1970-3-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fscrypt@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 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).