From: Nikolay Borisov <nborisov@suse.com>
To: linux-xfs@vger.kernel.org
Cc: fstests@vger.kernel.org, eguan@redhat.com, david@fromorbit.com,
darrick.wong@oracle.com, Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH v4 1/2] fiemap: Factor out actual fiemap call code
Date: Wed, 15 Nov 2017 14:10:20 +0200 [thread overview]
Message-ID: <1510747821-13270-1-git-send-email-nborisov@suse.com> (raw)
This will be needed to in a subsequent patch to avoid code duplication
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
io/fiemap.c | 39 ++++++++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 11 deletions(-)
diff --git a/io/fiemap.c b/io/fiemap.c
index e6fd66da753d..08391f69d9bd 100644
--- a/io/fiemap.c
+++ b/io/fiemap.c
@@ -211,6 +211,31 @@ calc_print_format(
}
}
+static int
+__fiemap(
+ struct fiemap * fiemap,
+ int mapsize,
+ __u32 flags,
+ __u64 start,
+ __u64 length) {
+
+ int ret;
+
+ memset(fiemap, 0, mapsize);
+ fiemap->fm_flags = flags;
+ fiemap->fm_start = start;
+ fiemap->fm_length = length;
+ fiemap->fm_extent_count = EXTENT_BATCH;
+ ret = ioctl(file->fd, FS_IOC_FIEMAP, fiemap);
+ if (ret < 0) {
+ fprintf(stderr, "%s: ioctl(FS_IOC_FIEMAP) [\"%s\"]: "
+ "%s\n", progname, file->name, strerror(errno));
+ return ret;
+ }
+
+ return 0;
+}
+
int
fiemap_f(
int argc,
@@ -266,19 +291,11 @@ fiemap_f(
while (!last && (cur_extent != max_extents)) {
- memset(fiemap, 0, map_size);
- fiemap->fm_flags = fiemap_flags;
- fiemap->fm_start = last_logical;
- fiemap->fm_length = -1LL;
- fiemap->fm_extent_count = EXTENT_BATCH;
-
- ret = ioctl(file->fd, FS_IOC_FIEMAP, (unsigned long)fiemap);
+ ret = __fiemap(fiemap, map_size, fiemap_flags, last_logical,
+ -1LL);
if (ret < 0) {
- fprintf(stderr, "%s: ioctl(FS_IOC_FIEMAP) [\"%s\"]: "
- "%s\n", progname, file->name, strerror(errno));
- free(fiemap);
exitcode = 1;
- return 0;
+ goto out;
}
/* No more extents to map, exit */
--
2.7.4
next reply other threads:[~2017-11-15 12:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-15 12:10 Nikolay Borisov [this message]
2017-11-15 12:10 ` [PATCH v4 2/2] fiemap: Implement ranged query Nikolay Borisov
2017-11-17 2:47 ` Eric Sandeen
2017-11-17 9:39 ` Nikolay Borisov
2017-11-15 12:11 ` [PATCH v4 1/3] generic: Adjust generic test outputs for new fiemap imeplementation Nikolay Borisov
2017-11-15 12:11 ` [PATCH v4 2/3] common: Implement fiemap's range query check Nikolay Borisov
2017-11-21 5:39 ` Eryu Guan
2017-11-15 12:11 ` [PATCH v4 3/3] xfs: initial fiemap range query test Nikolay Borisov
2017-11-21 5:45 ` Eryu Guan
2017-11-21 15:10 ` Nikolay Borisov
2017-11-21 5:29 ` [PATCH v4 1/3] generic: Adjust generic test outputs for new fiemap imeplementation Eryu Guan
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=1510747821-13270-1-git-send-email-nborisov@suse.com \
--to=nborisov@suse.com \
--cc=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=eguan@redhat.com \
--cc=fstests@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/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).