From: Chandan Rajendra <chandan@linux.ibm.com>
To: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-fscrypt@vger.kernel.org
Cc: hch@infradead.org, tytso@mit.edu, ebiggers@kernel.org,
Chandan Rajendra <chandan@linux.ibm.com>,
adilger.kernel@dilger.ca, chandanrmail@gmail.com,
jaegeuk@kernel.org
Subject: [f2fs-dev] [PATCH V4 1/8] buffer_head: Introduce BH_Read_Cb flag
Date: Fri, 16 Aug 2019 11:47:57 +0530 [thread overview]
Message-ID: <20190816061804.14840-2-chandan@linux.ibm.com> (raw)
In-Reply-To: <20190816061804.14840-1-chandan@linux.ibm.com>
Decryption of file content encrypted using fscrypt relies on
bio->bi_private holding a pointer to an encryption context
i.e. Decryption operation is not performed for bios having a NULL value
at bio->bi_private.
The same logic cannot be used on buffer heads because,
1. In Btrfs, write_dev_supers() sets bh->b_private to 'struct
btrfs_device' pointer and submits the buffer head for a write
operation.
1. In btrfs/146 test, the write operation fails and hence the
endio function clears the BH_Uptodate flag.
2. A read operation initiated later will submit the buffer head to
the block layer. During endio processing, bh_>b_private would have a
non-NULL value.
2. Another instance is when an Ext4 metadata block with BH_Uptodate set and
also part of the in-memory JBD list undergoes the following,
1. A sync() syscall is invoked by the userspace and the write
operation on the metadata block is initiated.
2. Due to an I/O failure, the BH_Uptodate flag is cleared by
end_buffer_async_write(). The bh->b_private member would be
pointing to a journal head structure.
3. In such a case, a read operation invoked on the block mapped by the
buffer head will initiate a read from the disk since the buffer head is
missing the BH_Uptodate flag.
4. After the read I/O request is submitted, end_buffer_async_read()
will find a non-NULL value at bh->b_private.
This scenario was observed when executing generic/475 test case.
Hence this commit introduces a new buffer head flag to reliably check for
decryption of a buffer head's contents after the block has been read
from the disk.
Signed-off-by: Chandan Rajendra <chandan@linux.ibm.com>
---
include/linux/buffer_head.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index 7b73ef7f902d..08f217ba8114 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -38,6 +38,7 @@ enum bh_state_bits {
BH_Meta, /* Buffer contains metadata */
BH_Prio, /* Buffer should be submitted with REQ_PRIO */
BH_Defer_Completion, /* Defer AIO completion to workqueue */
+ BH_Read_Cb, /* Block's contents needs to be decrypted */
BH_PrivateStart,/* not a state bit, but the first bit available
* for private allocation by other entities
@@ -134,6 +135,7 @@ BUFFER_FNS(Unwritten, unwritten)
BUFFER_FNS(Meta, meta)
BUFFER_FNS(Prio, prio)
BUFFER_FNS(Defer_Completion, defer_completion)
+BUFFER_FNS(Read_Cb, read_cb)
#define bh_offset(bh) ((unsigned long)(bh)->b_data & ~PAGE_MASK)
--
2.19.1
_______________________________________________
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-16 6:17 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-16 6:17 [f2fs-dev] [PATCH V4 0/8] Consolidate FS read I/O callbacks code Chandan Rajendra
2019-08-16 6:17 ` Chandan Rajendra [this message]
2019-08-16 6:17 ` [f2fs-dev] [PATCH V4 2/8] FS: Introduce read callbacks Chandan Rajendra
2019-08-16 6:17 ` [f2fs-dev] [PATCH V4 3/8] fs/mpage.c: Integrate " Chandan Rajendra
2019-08-16 6:18 ` [f2fs-dev] [PATCH V4 4/8] fs/buffer.c: add decryption support via read_callbacks Chandan Rajendra
2019-08-16 6:18 ` [f2fs-dev] [PATCH V4 5/8] f2fs: Use read_callbacks for decrypting file data Chandan Rajendra
2019-08-18 13:45 ` Chao Yu
2019-08-19 13:33 ` Chandan Rajendra
2019-08-20 7:43 ` Chao Yu
2019-08-20 5:05 ` Chandan Rajendra
2019-08-20 5:12 ` Gao Xiang
2019-08-20 5:16 ` Gao Xiang
2019-08-20 16:25 ` Theodore Y. Ts'o
2019-08-20 17:07 ` Gao Xiang via Linux-f2fs-devel
2019-08-20 16:38 ` Theodore Y. Ts'o
2019-08-20 17:31 ` Jaegeuk Kim
2019-08-21 2:04 ` Chandan Rajendra
2019-08-16 6:18 ` [f2fs-dev] [PATCH V4 6/8] ext4: Wire up ext4_readpage[s] to use mpage_readpage[s] Chandan Rajendra
2019-08-16 6:18 ` [f2fs-dev] [PATCH V4 7/8] ext4: Enable encryption for subpage-sized blocks Chandan Rajendra
2019-08-16 6:18 ` [f2fs-dev] [PATCH V4 8/8] fscrypt: remove struct fscrypt_ctx 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=20190816061804.14840-2-chandan@linux.ibm.com \
--to=chandan@linux.ibm.com \
--cc=adilger.kernel@dilger.ca \
--cc=chandanrmail@gmail.com \
--cc=ebiggers@kernel.org \
--cc=hch@infradead.org \
--cc=jaegeuk@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@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).