From: Carlos Maiolino <cmaiolino@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: sandeen@redhat.com, hch@lst.de, david@fromorbit.com,
darrick.wong@oracle.com
Subject: [PATCH 07/20] fiemap: Move fiemap flags to fiemap_ctx
Date: Tue, 30 Oct 2018 14:18:10 +0100 [thread overview]
Message-ID: <20181030131823.29040-8-cmaiolino@redhat.com> (raw)
In-Reply-To: <20181030131823.29040-1-cmaiolino@redhat.com>
struct fiemap_extent_info, will be gone in a later patch, but we still need the flags.
So, move the fiemap flags up to the new context structure fiemap_ctx.
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
fs/btrfs/inode.c | 2 +-
fs/ext4/extents.c | 6 +++---
fs/f2fs/data.c | 6 +++---
fs/ioctl.c | 23 +++++++++++------------
fs/iomap.c | 4 ++--
fs/nilfs2/inode.c | 2 +-
fs/ocfs2/extent_map.c | 2 +-
fs/overlayfs/inode.c | 3 +--
fs/xfs/xfs_iops.c | 5 ++---
include/linux/fs.h | 5 ++---
10 files changed, 27 insertions(+), 31 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ebe5aae69c44..77fd8587b8e7 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8619,7 +8619,7 @@ static int btrfs_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
u64 len = f_ctx->fc_len;
int ret;
- ret = fiemap_check_flags(fieinfo, BTRFS_FIEMAP_FLAGS);
+ ret = fiemap_check_flags(f_ctx, BTRFS_FIEMAP_FLAGS);
if (ret)
return ret;
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index beccae768dac..d52aafc34e25 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -5063,7 +5063,7 @@ int ext4_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
return error;
}
- if (fieinfo->fi_flags & FIEMAP_FLAG_CACHE) {
+ if (f_ctx->fc_flags & FIEMAP_FLAG_CACHE) {
error = ext4_ext_precache(inode);
if (error)
return error;
@@ -5073,10 +5073,10 @@ int ext4_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
return generic_block_fiemap(inode, f_ctx, ext4_get_block);
- if (fiemap_check_flags(fieinfo, EXT4_FIEMAP_FLAGS))
+ if (fiemap_check_flags(f_ctx, EXT4_FIEMAP_FLAGS))
return -EBADR;
- if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) {
+ if (f_ctx->fc_flags & FIEMAP_FLAG_XATTR) {
error = ext4_xattr_fiemap(inode, fieinfo);
} else {
ext4_lblk_t len_blks;
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 0f57403feb92..c552e2d1dfbb 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1409,19 +1409,19 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
u32 flags = 0;
int ret = 0;
- if (fieinfo->fi_flags & FIEMAP_FLAG_CACHE) {
+ if (f_ctx->fc_flags & FIEMAP_FLAG_CACHE) {
ret = f2fs_precache_extents(inode);
if (ret)
return ret;
}
- ret = fiemap_check_flags(fieinfo, FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR);
+ ret = fiemap_check_flags(f_ctx, FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR);
if (ret)
return ret;
inode_lock(inode);
- if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) {
+ if (f_ctx->fc_flags & FIEMAP_FLAG_XATTR) {
ret = f2fs_xattr_fiemap(inode, fieinfo);
goto out;
}
diff --git a/fs/ioctl.c b/fs/ioctl.c
index ddcc4f9a9cf1..77af3b116972 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -139,13 +139,13 @@ EXPORT_SYMBOL(fiemap_fill_next_extent);
*
* Returns 0 on success, -EBADR on bad flags.
*/
-int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags)
+int fiemap_check_flags(struct fiemap_ctx *f_ctx, u32 fs_flags)
{
u32 incompat_flags;
- incompat_flags = fieinfo->fi_flags & ~(FIEMAP_FLAGS_COMPAT & fs_flags);
+ incompat_flags = f_ctx->fc_flags & ~(FIEMAP_FLAGS_COMPAT & fs_flags);
if (incompat_flags) {
- fieinfo->fi_flags = incompat_flags;
+ f_ctx->fc_flags = incompat_flags;
return -EBADR;
}
return 0;
@@ -199,25 +199,24 @@ static int ioctl_fiemap(struct file *filp, unsigned long arg)
if (error)
return error;
- fieinfo.fi_flags = fiemap.fm_flags;
fieinfo.fi_extents_max = fiemap.fm_extent_count;
fieinfo.fi_extents_start = ufiemap->fm_extents;
+ f_ctx.fc_flags = fiemap.fm_flags;
+ f_ctx.fc_data = &fieinfo;
+ f_ctx.fc_start = fiemap.fm_start;
+ f_ctx.fc_len = len;
+
if (fiemap.fm_extent_count != 0 &&
!access_ok(VERIFY_WRITE, fieinfo.fi_extents_start,
fieinfo.fi_extents_max * sizeof(struct fiemap_extent)))
return -EFAULT;
- if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC)
+ if (f_ctx.fc_flags & FIEMAP_FLAG_SYNC)
filemap_write_and_wait(inode->i_mapping);
- f_ctx.fc_flags = fieinfo.fi_flags;
- f_ctx.fc_data = &fieinfo;
- f_ctx.fc_start = fiemap.fm_start;
- f_ctx.fc_len = len;
-
error = inode->i_op->fiemap(inode, &f_ctx);
- fiemap.fm_flags = fieinfo.fi_flags;
+ fiemap.fm_flags = f_ctx.fc_flags;
fiemap.fm_mapped_extents = fieinfo.fi_extents_mapped;
if (copy_to_user(ufiemap, &fiemap, sizeof(fiemap)))
error = -EFAULT;
@@ -298,7 +297,7 @@ int __generic_block_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx,
bool past_eof = false, whole_file = false;
int ret = 0;
- ret = fiemap_check_flags(fieinfo, FIEMAP_FLAG_SYNC);
+ ret = fiemap_check_flags(f_ctx, FIEMAP_FLAG_SYNC);
if (ret)
return ret;
diff --git a/fs/iomap.c b/fs/iomap.c
index 42b131e1c955..5afca566c2a9 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -1166,11 +1166,11 @@ int iomap_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx,
ctx.fi = fi;
ctx.prev.type = IOMAP_HOLE;
- ret = fiemap_check_flags(fi, FIEMAP_FLAG_SYNC);
+ ret = fiemap_check_flags(f_ctx, FIEMAP_FLAG_SYNC);
if (ret)
return ret;
- if (fi->fi_flags & FIEMAP_FLAG_SYNC) {
+ if (f_ctx->fc_flags & FIEMAP_FLAG_SYNC) {
ret = filemap_write_and_wait(inode->i_mapping);
if (ret)
return ret;
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 529262f0ab7d..a8040ed52bd5 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -1007,7 +1007,7 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
unsigned int blkbits = inode->i_blkbits;
int ret, n;
- ret = fiemap_check_flags(fieinfo, FIEMAP_FLAG_SYNC);
+ ret = fiemap_check_flags(f_ctx, FIEMAP_FLAG_SYNC);
if (ret)
return ret;
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
index 1944f5659267..5ba98d7a7a42 100644
--- a/fs/ocfs2/extent_map.c
+++ b/fs/ocfs2/extent_map.c
@@ -762,7 +762,7 @@ int ocfs2_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
struct buffer_head *di_bh = NULL;
struct ocfs2_extent_rec rec;
- ret = fiemap_check_flags(fieinfo, OCFS2_FIEMAP_FLAGS);
+ ret = fiemap_check_flags(f_ctx, OCFS2_FIEMAP_FLAGS);
if (ret)
return ret;
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index e56606c1ba92..3cef3b9b1854 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -458,7 +458,6 @@ int ovl_update_time(struct inode *inode, struct timespec64 *ts, int flags)
static int ovl_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
{
- struct fiemap_extent_info *fieinfo = f_ctx->fc_data;
int err;
struct inode *realinode = ovl_inode_real(inode);
const struct cred *old_cred;
@@ -468,7 +467,7 @@ static int ovl_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
old_cred = ovl_override_creds(inode->i_sb);
- if (fieinfo->fi_flags & FIEMAP_FLAG_SYNC)
+ if (f_ctx->fc_flags & FIEMAP_FLAG_SYNC)
filemap_write_and_wait(realinode->i_mapping);
err = realinode->i_op->fiemap(realinode, f_ctx);
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 22c479862ba6..d859558de2fe 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -1095,14 +1095,13 @@ xfs_vn_fiemap(
struct inode *inode,
struct fiemap_ctx *f_ctx)
{
- struct fiemap_extent_info *fieinfo = f_ctx->fc_data;
u64 start = f_ctx->fc_start;
u64 length = f_ctx->fc_len;
int error;
xfs_ilock(XFS_I(inode), XFS_IOLOCK_SHARED);
- if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) {
- fieinfo->fi_flags &= ~FIEMAP_FLAG_XATTR;
+ if (f_ctx->fc_flags & FIEMAP_FLAG_XATTR) {
+ f_ctx->fc_flags &= ~FIEMAP_FLAG_XATTR;
error = iomap_fiemap(inode, f_ctx, start, length,
&xfs_xattr_iomap_ops);
} else {
diff --git a/include/linux/fs.h b/include/linux/fs.h
index bd8e8a7dfd59..fb060123acff 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1692,7 +1692,6 @@ extern bool may_open_dev(const struct path *path);
struct fiemap_ctx;
struct fiemap_extent_info {
- unsigned int fi_flags; /* Flags as passed from user */
unsigned int fi_extents_mapped; /* Number of mapped extents */
unsigned int fi_extents_max; /* Size of fiemap_extent array */
struct fiemap_extent __user *fi_extents_start; /* Start of
@@ -1703,7 +1702,7 @@ typedef int (*fiemap_fill_cb)(struct fiemap_ctx *f_ctx, u64 logical,
u64 phys, u64 len, u32 flags);
struct fiemap_ctx {
- unsigned int fc_flags;
+ unsigned int fc_flags; /* Flags as passed from user */
void *fc_data;
fiemap_fill_cb fc_cb; /* Unused by now */
u64 fc_start;
@@ -1712,7 +1711,7 @@ struct fiemap_ctx {
int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical,
u64 phys, u64 len, u32 flags);
-int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags);
+int fiemap_check_flags(struct fiemap_ctx *f_ctx, u32 fs_flags);
/*
* File types
--
2.17.1
next prev parent reply other threads:[~2018-10-30 22:12 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-30 13:18 [PATCH 00/20] New ->fiemap infrastructure and ->bmap removal Carlos Maiolino
2018-10-30 13:18 ` [PATCH 01/20] fs: Enable bmap() function to properly return errors Carlos Maiolino
2018-10-30 13:18 ` [PATCH 02/20] cachefiles: drop direct usage of ->bmap method Carlos Maiolino
2018-10-30 13:18 ` [PATCH 03/20] ecryptfs: drop direct calls to ->bmap Carlos Maiolino
2018-11-16 15:40 ` Christoph Hellwig
2018-10-30 13:18 ` [PATCH 04/20] iomap: Rename fiemap_ctx to fiemap_iomap_ctx Carlos Maiolino
2018-11-16 15:44 ` Christoph Hellwig
2018-10-30 13:18 ` [PATCH 05/20] fs: Introduce fiemap_ctx data structure Carlos Maiolino
2018-11-16 15:46 ` Christoph Hellwig
2018-10-30 13:18 ` [PATCH 06/20] iomap: Update iomap_fiemap to use new fiemap_ctx structure Carlos Maiolino
2018-11-16 15:48 ` Christoph Hellwig
2018-10-30 13:18 ` Carlos Maiolino [this message]
2018-11-05 22:12 ` [PATCH 07/20] fiemap: Move fiemap flags to fiemap_ctx Andreas Dilger
2018-11-06 8:37 ` Carlos Maiolino
2018-11-16 15:50 ` Christoph Hellwig
2018-11-16 15:51 ` Christoph Hellwig
2018-10-30 13:18 ` [PATCH 08/20] ext4: Remove direct usage of fiemap_extent_info Carlos Maiolino
2018-11-05 22:13 ` Andreas Dilger
2018-11-06 8:49 ` Carlos Maiolino
2018-10-30 13:18 ` [PATCH 09/20] f2fs: " Carlos Maiolino
2018-10-31 6:10 ` Chao Yu
2018-10-30 13:18 ` [PATCH 10/20] Btrfs: " Carlos Maiolino
2018-10-30 13:18 ` [PATCH 11/20] nilfs2: " Carlos Maiolino
2018-10-30 13:18 ` [PATCH 12/20] ocfs2: " Carlos Maiolino
2018-10-30 13:18 ` [PATCH 13/20] iomap: " Carlos Maiolino
2018-10-30 13:18 ` [PATCH 14/20] fiemap: Use fiemap_ctx as fiemap_fill_next_extent argument Carlos Maiolino
2018-11-16 15:54 ` Christoph Hellwig
2018-10-30 13:18 ` [PATCH 15/20] fiemap: Start using new callback from fiemap_ctx Carlos Maiolino
2018-11-05 22:14 ` Andreas Dilger
2018-11-06 8:52 ` Carlos Maiolino
2018-11-16 15:55 ` Christoph Hellwig
2018-11-19 12:26 ` Carlos Maiolino
2018-11-16 15:57 ` Christoph Hellwig
2018-11-19 12:37 ` Carlos Maiolino
2018-10-30 13:18 ` [PATCH 16/20] fibmap: Use bmap instead of ->bmap method in ioctl_fibmap Carlos Maiolino
2018-11-16 15:58 ` Christoph Hellwig
2018-11-19 12:41 ` Carlos Maiolino
2018-10-30 13:18 ` [PATCH 17/20] fiemap: Get rid of fiemap_extent_info Carlos Maiolino
2018-11-05 22:14 ` Andreas Dilger
2018-11-06 8:56 ` Carlos Maiolino
2018-11-16 16:04 ` Christoph Hellwig
2018-11-19 12:47 ` Carlos Maiolino
2018-10-30 13:18 ` [PATCH 18/20] Use FIEMAP for FIBMAP calls Carlos Maiolino
2018-11-05 22:15 ` Andreas Dilger
2018-11-06 9:11 ` Carlos Maiolino
2018-11-16 16:06 ` Christoph Hellwig
2018-11-19 12:50 ` Carlos Maiolino
2018-11-20 8:53 ` Christoph Hellwig
2018-10-30 13:18 ` [PATCH 19/20] xfs: Get rid of ->bmap Carlos Maiolino
2018-10-30 13:18 ` [PATCH 20/20] ext4: Get rid of ->bmap interface Carlos Maiolino
2018-11-16 16:07 ` Christoph Hellwig
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=20181030131823.29040-8-cmaiolino@redhat.com \
--to=cmaiolino@redhat.com \
--cc=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=sandeen@redhat.com \
/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).