From: Ritesh Harjani <riteshh@linux.ibm.com>
To: tytso@mit.edu, jack@suse.cz, linux-ext4@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, mbobrowski@mbobrowski.org,
riteshh@linux.ibm.com
Subject: [RFC 2/5] ext4: Add API to bring in support for unwritten io_end_vec conversion
Date: Wed, 16 Oct 2019 13:07:08 +0530 [thread overview]
Message-ID: <20191016073711.4141-3-riteshh@linux.ibm.com> (raw)
In-Reply-To: <20191016073711.4141-1-riteshh@linux.ibm.com>
This patch just brings in the API for conversion of unwritten io_end_vec
extents which will be required for blocksize < pagesize support
for dioread_nolock feature.
No functional changes in this patch.
Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
---
fs/ext4/ext4.h | 2 ++
fs/ext4/extents.c | 42 +++++++++++++++++++++++++++---------------
fs/ext4/page-io.c | 7 +++----
3 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 03db3e71676c..8d924bd19ca7 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3264,6 +3264,8 @@ extern long ext4_fallocate(struct file *file, int mode, loff_t offset,
loff_t len);
extern int ext4_convert_unwritten_extents(handle_t *handle, struct inode *inode,
loff_t offset, ssize_t len);
+extern int ext4_convert_unwritten_io_end_vec(handle_t *handle,
+ ext4_io_end_t *io_end);
extern int ext4_map_blocks(handle_t *handle, struct inode *inode,
struct ext4_map_blocks *map, int flags);
extern int ext4_ext_calc_metadata_amount(struct inode *inode,
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index fb0f99dc8c22..731e67ccab22 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4962,23 +4962,13 @@ int ext4_convert_unwritten_extents(handle_t *handle, struct inode *inode,
int ret = 0;
int ret2 = 0;
struct ext4_map_blocks map;
- unsigned int credits, blkbits = inode->i_blkbits;
+ unsigned int blkbits = inode->i_blkbits;
+ unsigned int credits = 0;
map.m_lblk = offset >> blkbits;
max_blocks = EXT4_MAX_BLOCKS(len, offset, blkbits);
- /*
- * This is somewhat ugly but the idea is clear: When transaction is
- * reserved, everything goes into it. Otherwise we rather start several
- * smaller transactions for conversion of each extent separately.
- */
- if (handle) {
- handle = ext4_journal_start_reserved(handle,
- EXT4_HT_EXT_CONVERT);
- if (IS_ERR(handle))
- return PTR_ERR(handle);
- credits = 0;
- } else {
+ if (!handle) {
/*
* credits to insert 1 extent into extent tree
*/
@@ -5009,11 +4999,33 @@ int ext4_convert_unwritten_extents(handle_t *handle, struct inode *inode,
if (ret <= 0 || ret2)
break;
}
- if (!credits)
- ret2 = ext4_journal_stop(handle);
return ret > 0 ? ret2 : ret;
}
+int ext4_convert_unwritten_io_end_vec(handle_t *handle, ext4_io_end_t *io_end)
+{
+ int ret, err = 0;
+
+ /*
+ * This is somewhat ugly but the idea is clear: When transaction is
+ * reserved, everything goes into it. Otherwise we rather start several
+ * smaller transactions for conversion of each extent separately.
+ */
+ if (handle) {
+ handle = ext4_journal_start_reserved(handle,
+ EXT4_HT_EXT_CONVERT);
+ if (IS_ERR(handle))
+ return PTR_ERR(handle);
+ }
+
+ ret = ext4_convert_unwritten_extents(handle, io_end->inode,
+ io_end->offset, io_end->size);
+ if (handle)
+ err = ext4_journal_stop(handle);
+
+ return ret < 0 ? ret : err;
+}
+
/*
* If newes is not existing extent (newes->ec_pblk equals zero) find
* delayed extent at start of newes and update newes accordingly and
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index d9b96fc976a3..3ccf54a380b2 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -149,7 +149,7 @@ static int ext4_end_io_end(ext4_io_end_t *io_end)
io_end, inode->i_ino, io_end->list.next, io_end->list.prev);
io_end->handle = NULL; /* Following call will use up the handle */
- ret = ext4_convert_unwritten_extents(handle, inode, offset, size);
+ ret = ext4_convert_unwritten_io_end_vec(handle, io_end);
if (ret < 0 && !ext4_forced_shutdown(EXT4_SB(inode->i_sb))) {
ext4_msg(inode->i_sb, KERN_EMERG,
"failed to convert unwritten extents to written "
@@ -269,9 +269,8 @@ int ext4_put_io_end(ext4_io_end_t *io_end)
if (atomic_dec_and_test(&io_end->count)) {
if (io_end->flag & EXT4_IO_END_UNWRITTEN) {
- err = ext4_convert_unwritten_extents(io_end->handle,
- io_end->inode, io_end->offset,
- io_end->size);
+ err = ext4_convert_unwritten_io_end_vec(io_end->handle,
+ io_end);
io_end->handle = NULL;
ext4_clear_io_unwritten_flag(io_end);
}
--
2.21.0
next prev parent reply other threads:[~2019-10-16 7:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-16 7:37 [RFC 0/5] Ext4: Add support for blocksize < pagesize for dioread_nolock Ritesh Harjani
2019-10-16 7:37 ` [RFC 1/5] ext4: keep uniform naming convention for io & io_end variables Ritesh Harjani
2019-10-25 13:07 ` Jan Kara
2019-10-16 7:37 ` Ritesh Harjani [this message]
2019-10-16 7:37 ` [RFC 3/5] ext4: Refactor mpage_map_and_submit_buffers function Ritesh Harjani
2019-10-16 7:37 ` [RFC 4/5] ext4: Add support for blocksize < pagesize in dioread_nolock Ritesh Harjani
2019-10-16 7:37 ` [RFC 5/5] ext4: Enable blocksize < pagesize for dioread_nolock Ritesh Harjani
2019-10-23 23:26 ` [RFC 0/5] Ext4: Add support for " Theodore Y. Ts'o
2019-10-24 1:12 ` Ritesh Harjani
2019-10-29 7:19 ` Ritesh Harjani
2019-11-03 19:16 ` Theodore Y. Ts'o
2019-11-04 10:16 ` Matthew Bobrowski
2019-11-04 10:37 ` Ritesh Harjani
2019-11-04 10:49 ` Matthew Bobrowski
2019-11-04 16:08 ` Theodore Y. Ts'o
2019-11-04 10:43 ` Ritesh Harjani
2019-11-04 11:59 ` Ritesh Harjani
2019-11-06 17:23 ` Jan Kara
2019-11-07 11:15 ` Ritesh Harjani
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=20191016073711.4141-3-riteshh@linux.ibm.com \
--to=riteshh@linux.ibm.com \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mbobrowski@mbobrowski.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).