From: Kirill Tkhai <ktkhai@virtuozzo.com>
To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-ext4@vger.kernel.org
Cc: axboe@kernel.dk, tytso@mit.edu, adilger.kernel@dilger.ca,
ming.lei@redhat.com, osandov@fb.com, jthumshirn@suse.de,
minwoo.im.dev@gmail.com, damien.lemoal@wdc.com,
ktkhai@virtuozzo.com, andrea.parri@amarulasolutions.com,
hare@suse.com, tj@kernel.org, ajay.joshi@wdc.com,
sagi@grimberg.me, dsterba@suse.com, chaitanya.kulkarni@wdc.com,
bvanassche@acm.org, dhowells@redhat.com, asml.silence@gmail.com
Subject: [PATCH RFC 3/3] ext4: Notify block device about fallocate(0)-assigned blocks
Date: Tue, 10 Dec 2019 19:56:19 +0300 [thread overview]
Message-ID: <157599697948.12112.3846364542350011691.stgit@localhost.localdomain> (raw)
In-Reply-To: <157599668662.12112.10184894900037871860.stgit@localhost.localdomain>
Call sb_issue_assign_range() after extent range was allocated
on user request. Hopeful, this helps block device to maintain
its internals in the best way, if this is appliable.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
fs/ext4/ext4.h | 1 +
fs/ext4/extents.c | 11 +++++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index f8578caba40d..fe2263c00c0e 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -622,6 +622,7 @@ enum {
* allows jbd2 to avoid submitting data before commit. */
#define EXT4_GET_BLOCKS_IO_SUBMIT 0x0400
+#define EXT4_GET_BLOCKS_SUBMIT_ALLOC 0x0800
/*
* The bit position of these flags must not overlap with any of the
* EXT4_GET_BLOCKS_*. They are used by ext4_find_extent(),
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 0e8708b77da6..5f4fc660cbb1 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4490,6 +4490,13 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
ar.len = allocated;
got_allocated_blocks:
+ if ((flags & EXT4_GET_BLOCKS_SUBMIT_ALLOC) && sbi->fallocate) {
+ err = sb_issue_assign_range(inode->i_sb, newblock,
+ EXT4_C2B(sbi, allocated_clusters), GFP_NOFS);
+ if (err)
+ goto free_on_err;
+ }
+
/* try to insert new extent into found leaf and return */
ext4_ext_store_pblock(&newex, newblock + offset);
newex.ee_len = cpu_to_le16(ar.len);
@@ -4506,7 +4513,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
if (!err)
err = ext4_ext_insert_extent(handle, inode, &path,
&newex, flags);
-
+free_on_err:
if (err && free_on_err) {
int fb_flags = flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE ?
EXT4_FREE_BLOCKS_NO_QUOT_UPDATE : 0;
@@ -4926,7 +4933,7 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
lblk = offset >> blkbits;
max_blocks = EXT4_MAX_BLOCKS(len, offset, blkbits);
- flags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT;
+ flags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT | EXT4_GET_BLOCKS_SUBMIT_ALLOC;
if (mode & FALLOC_FL_KEEP_SIZE)
flags |= EXT4_GET_BLOCKS_KEEP_SIZE;
next prev parent reply other threads:[~2019-12-10 16:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-10 16:56 [PATCH RFC 0/3] block,ext4: Introduce REQ_OP_ASSIGN_RANGE to reflect extents allocation in block device internals Kirill Tkhai
2019-12-10 16:56 ` [PATCH RFC 1/3] block: Add support for REQ_OP_ASSIGN_RANGE operation Kirill Tkhai
2019-12-19 3:03 ` Martin K. Petersen
2019-12-19 11:07 ` Kirill Tkhai
2019-12-19 22:03 ` Chaitanya Kulkarni
2019-12-19 22:37 ` Martin K. Petersen
2019-12-20 1:53 ` Darrick J. Wong
2019-12-20 2:22 ` Martin K. Petersen
2019-12-20 11:55 ` Kirill Tkhai
2019-12-21 18:54 ` Martin K. Petersen
2019-12-23 8:51 ` Kirill Tkhai
2020-01-07 3:24 ` Martin K. Petersen
2020-01-07 13:59 ` Kirill Tkhai
2020-01-08 2:49 ` Martin K. Petersen
2020-01-09 9:43 ` Kirill Tkhai
2019-12-10 16:56 ` [PATCH RFC 2/3] loop: Forward REQ_OP_ASSIGN_RANGE into fallocate(0) Kirill Tkhai
2019-12-10 16:56 ` Kirill Tkhai [this message]
2019-12-11 12:55 ` [PATCH RFC v2 3/3] ext4: Notify block device about fallocate(0)-assigned blocks Kirill Tkhai
2019-12-11 7:42 ` [PATCH RFC 0/3] block,ext4: Introduce REQ_OP_ASSIGN_RANGE to reflect extents allocation in block device internals Chaitanya Kulkarni
2019-12-11 8:50 ` Kirill Tkhai
2019-12-17 14:16 ` Kirill Tkhai
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=157599697948.12112.3846364542350011691.stgit@localhost.localdomain \
--to=ktkhai@virtuozzo.com \
--cc=adilger.kernel@dilger.ca \
--cc=ajay.joshi@wdc.com \
--cc=andrea.parri@amarulasolutions.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=chaitanya.kulkarni@wdc.com \
--cc=damien.lemoal@wdc.com \
--cc=dhowells@redhat.com \
--cc=dsterba@suse.com \
--cc=hare@suse.com \
--cc=jthumshirn@suse.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=minwoo.im.dev@gmail.com \
--cc=osandov@fb.com \
--cc=sagi@grimberg.me \
--cc=tj@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).