From: James Simmons <jsimmons@infradead.org>
To: Andreas Dilger <adilger@whamcloud.com>,
Oleg Drokin <green@whamcloud.com>, NeilBrown <neilb@suse.de>
Cc: Mikhail Pershin <mpershin@whamcloud.com>,
Lustre Development List <lustre-devel@lists.lustre.org>
Subject: [lustre-devel] [PATCH 24/29] lustre: llite: do fallocate() size checks under lock
Date: Sun, 25 Apr 2021 16:08:31 -0400 [thread overview]
Message-ID: <1619381316-7719-25-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1619381316-7719-1-git-send-email-jsimmons@infradead.org>
From: Mikhail Pershin <mpershin@whamcloud.com>
Check about fallocate() range vs file size in vvp_io_setattr_start()
instead of ll_fallocate() so inode size cannot be changed by pending
write or truncate. This implies that IO is initialized already and
requires changes in LOV to update sub-IOs with proper inode size and
valid size attribute values
Fix also vvp_io_setattr_lock() to don't include fallocate_end in
lock range
WC-bug-id: https://jira.whamcloud.com/browse/LU-14433
Luste-commit: f23ac22c4c79750fe ("LU-14433 llite: do fallocate() size checks under lock")
Signed-off-by: Mikhail Pershin <mpershin@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/41668
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
fs/lustre/llite/file.c | 5 -----
fs/lustre/llite/vvp_io.c | 22 +++++++++++++++++++---
fs/lustre/lov/lov_io.c | 28 ++++++++++++++++++++++++++--
3 files changed, 45 insertions(+), 10 deletions(-)
diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c
index 1ca4589..c049433 100644
--- a/fs/lustre/llite/file.c
+++ b/fs/lustre/llite/file.c
@@ -5028,11 +5028,6 @@ int cl_falloc(struct inode *inode, int mode, loff_t offset, loff_t len)
rc = -EFBIG;
goto out;
}
- io->u.ci_setattr.sa_attr.lvb_size = sa_falloc_end;
- if (!(mode & FALLOC_FL_KEEP_SIZE))
- io->u.ci_setattr.sa_avalid |= ATTR_SIZE;
- } else {
- io->u.ci_setattr.sa_attr.lvb_size = size;
}
again:
diff --git a/fs/lustre/llite/vvp_io.c b/fs/lustre/llite/vvp_io.c
index cb59e94..38a9430 100644
--- a/fs/lustre/llite/vvp_io.c
+++ b/fs/lustre/llite/vvp_io.c
@@ -41,6 +41,8 @@
#include <obd.h>
#include <linux/pagevec.h>
#include <linux/memcontrol.h>
+#include <linux/falloc.h>
+
#include "llite_internal.h"
#include "vvp_internal.h"
@@ -647,7 +649,7 @@ static int vvp_io_setattr_lock(const struct lu_env *env,
enqflags = CEF_DISCARD_DATA;
} else if (cl_io_is_fallocate(io)) {
lock_start = io->u.ci_setattr.sa_falloc_offset;
- lock_end = io->u.ci_setattr.sa_falloc_end;
+ lock_end = io->u.ci_setattr.sa_falloc_end - 1;
} else {
unsigned int valid = io->u.ci_setattr.sa_avalid;
@@ -715,14 +717,27 @@ static int vvp_io_setattr_start(const struct lu_env *env,
struct cl_io *io = ios->cis_io;
struct inode *inode = vvp_object_inode(io->ci_obj);
struct ll_inode_info *lli = ll_i2info(inode);
+ int mode = io->u.ci_setattr.sa_falloc_mode;
if (cl_io_is_trunc(io)) {
trunc_sem_down_write(&lli->lli_trunc_sem);
mutex_lock(&lli->lli_setattr_mutex);
inode_dio_wait(inode);
} else if (cl_io_is_fallocate(io)) {
- inode_lock(inode);
+ loff_t size;
+
+ trunc_sem_down_write(&lli->lli_trunc_sem);
+ mutex_lock(&lli->lli_setattr_mutex);
inode_dio_wait(inode);
+
+ ll_merge_attr(env, inode);
+ size = i_size_read(inode);
+ if (io->u.ci_setattr.sa_falloc_end > size &&
+ !(mode & FALLOC_FL_KEEP_SIZE)) {
+ size = io->u.ci_setattr.sa_falloc_end;
+ io->u.ci_setattr.sa_avalid |= ATTR_SIZE;
+ }
+ io->u.ci_setattr.sa_attr.lvb_size = size;
} else {
mutex_lock(&lli->lli_setattr_mutex);
}
@@ -748,7 +763,8 @@ static void vvp_io_setattr_end(const struct lu_env *env,
mutex_unlock(&lli->lli_setattr_mutex);
trunc_sem_up_write(&lli->lli_trunc_sem);
} else if (cl_io_is_fallocate(io)) {
- inode_unlock(inode);
+ mutex_unlock(&lli->lli_setattr_mutex);
+ trunc_sem_up_write(&lli->lli_trunc_sem);
} else {
mutex_unlock(&lli->lli_setattr_mutex);
}
diff --git a/fs/lustre/lov/lov_io.c b/fs/lustre/lov/lov_io.c
index ae9d547..7da0047 100644
--- a/fs/lustre/lov/lov_io.c
+++ b/fs/lustre/lov/lov_io.c
@@ -681,7 +681,7 @@ static void lov_io_sub_inherit(struct lov_io_sub *sub, struct lov_io *lio,
io->u.ci_setattr.sa_falloc_offset = start;
io->u.ci_setattr.sa_falloc_end = end;
}
- if (cl_io_is_trunc(io) || cl_io_is_fallocate(io)) {
+ if (cl_io_is_trunc(io)) {
loff_t new_size = parent->u.ci_setattr.sa_attr.lvb_size;
new_size = lov_size_to_stripe(lsm, index, new_size,
@@ -1441,6 +1441,30 @@ static int lov_io_fault_start(const struct lu_env *env,
return lov_io_start(env, ios);
}
+static int lov_io_setattr_start(const struct lu_env *env,
+ const struct cl_io_slice *ios)
+{
+ struct lov_io *lio = cl2lov_io(env, ios);
+ struct cl_io *parent = ios->cis_io;
+ struct lov_io_sub *sub;
+ struct lov_stripe_md *lsm = lio->lis_object->lo_lsm;
+
+ if (cl_io_is_fallocate(parent)) {
+ list_for_each_entry(sub, &lio->lis_active, sub_linkage) {
+ loff_t size = parent->u.ci_setattr.sa_attr.lvb_size;
+ int index = lov_comp_entry(sub->sub_subio_index);
+ int stripe = lov_comp_stripe(sub->sub_subio_index);
+
+ size = lov_size_to_stripe(lsm, index, size, stripe);
+ sub->sub_io.u.ci_setattr.sa_attr.lvb_size = size;
+ sub->sub_io.u.ci_setattr.sa_avalid =
+ parent->u.ci_setattr.sa_avalid;
+ }
+ }
+
+ return lov_io_start(env, ios);
+}
+
static void lov_io_fsync_end(const struct lu_env *env,
const struct cl_io_slice *ios)
{
@@ -1577,7 +1601,7 @@ static void lov_io_lseek_end(const struct lu_env *env,
.cio_iter_fini = lov_io_iter_fini,
.cio_lock = lov_io_lock,
.cio_unlock = lov_io_unlock,
- .cio_start = lov_io_start,
+ .cio_start = lov_io_setattr_start,
.cio_end = lov_io_end
},
[CIT_DATA_VERSION] = {
--
1.8.3.1
_______________________________________________
lustre-devel mailing list
lustre-devel@lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
next prev parent reply other threads:[~2021-04-25 20:09 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-25 20:08 [lustre-devel] [PATCH 00/29] lustre: Update to OpenSFS tree as of April 25, 2020 James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 01/29] lnet: socklnd: use sockaddr instead of u32 addresses James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 02/29] lnet: allow creation of IPv6 socket James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 03/29] lnet: allow lnet_connect() to use IPv6 addresses James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 04/29] lnet: handle possiblity of IPv6 being unavailable James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 05/29] lnet: socklnd: remove tcp bonding James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 06/29] lnet: socklnd: replace route construct James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 07/29] lustre: readahead: limit over reservation James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 08/29] lustre: clio: fix hang on urgent cached pages James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 09/29] lustre: uapi: add mdt_hash_name James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 10/29] lustre: mdc: set fid2path RPC interruptible James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 11/29] lustre: include: remove references to Sun Trademark James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 12/29] lnet: o2iblnd: Use REMOTE_DROPPED for ECONNREFUSED James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 13/29] lustre: lmv: reduce struct lmv_obd size James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 14/29] lustre: uapi: remove obsolete ioctls James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 15/29] lustre: lmv: don't include struct lu_qos_rr in client James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 16/29] lnet: libcfs: fix setting of debug_path James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 17/29] lnet: Use lr_hops for avoid_asym_router_failure James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 18/29] lnet: Leverage peer aliveness more efficiently James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 19/29] lustre: mdt: mkdir should return -EEXIST if exists James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 20/29] lnet: o2iblnd: don't resend if there's no listener James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 21/29] lnet: obi2lnd: don't try to reconnect " James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 22/29] lustre: osc: fall back to vmalloc for large RPCs James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 23/29] lustre: ldlm: discard l_lock from struct ldlm_lock James Simmons
2021-04-25 20:08 ` James Simmons [this message]
2021-04-25 20:08 ` [lustre-devel] [PATCH 25/29] lustre: misc: limit CDEBUG console message frequency James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 26/29] lustre: fallocate: Add punch mode to fallocate James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 27/29] lustre: various: only use wake_up_all() on exclusive waitqs James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 28/29] lnet: remove references to Sun Trademark James Simmons
2021-04-25 20:08 ` [lustre-devel] [PATCH 29/29] lustre: " James Simmons
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=1619381316-7719-25-git-send-email-jsimmons@infradead.org \
--to=jsimmons@infradead.org \
--cc=adilger@whamcloud.com \
--cc=green@whamcloud.com \
--cc=lustre-devel@lists.lustre.org \
--cc=mpershin@whamcloud.com \
--cc=neilb@suse.de \
/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).