From: Andreas Rohner <andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
To: linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Andreas Rohner <andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
Subject: [PATCH v3 3/4] nilfs-utils: add suport for NILFS_IOCTL_SET_SUINFO ioctl
Date: Mon, 27 Jan 2014 10:58:55 +0100 [thread overview]
Message-ID: <a69dc4d73e1e247740dd0ffedba7261b58437f77.1390813175.git.andreas.rohner@gmx.net> (raw)
In-Reply-To: <cover.1390813175.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
In-Reply-To: <cover.1390813175.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
This patch adds library support for the NILFS_IOCTL_SET_SUINFO
ioctl. A new function nilfs_set_suinfo and the structure
nilfs_suinfo_update, which contains the update information, are
added.
With this function the segment usage information can be updated
from userspace, which can be used as a shortcut for certain GC
operations.
Signed-off-by: Andreas Rohner <andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
---
include/nilfs.h | 2 ++
include/nilfs2_fs.h | 43 +++++++++++++++++++++++++++++++++++++++++++
lib/nilfs.c | 32 ++++++++++++++++++++++++++++++++
3 files changed, 77 insertions(+)
diff --git a/include/nilfs.h b/include/nilfs.h
index b5f85d3..af4735d 100644
--- a/include/nilfs.h
+++ b/include/nilfs.h
@@ -304,6 +304,8 @@ int nilfs_delete_checkpoint(struct nilfs *, nilfs_cno_t);
int nilfs_get_cpstat(const struct nilfs *, struct nilfs_cpstat *);
ssize_t nilfs_get_suinfo(const struct nilfs *, __u64, struct nilfs_suinfo *,
size_t);
+ssize_t nilfs_set_suinfo(const struct nilfs *, struct nilfs_suinfo_update *,
+ size_t);
int nilfs_get_sustat(const struct nilfs *, struct nilfs_sustat *);
ssize_t nilfs_get_vinfo(const struct nilfs *, struct nilfs_vinfo *, size_t);
ssize_t nilfs_get_bdescs(const struct nilfs *, struct nilfs_bdesc *, size_t);
diff --git a/include/nilfs2_fs.h b/include/nilfs2_fs.h
index e674f44..45de858 100644
--- a/include/nilfs2_fs.h
+++ b/include/nilfs2_fs.h
@@ -713,6 +713,47 @@ static inline int nilfs_suinfo_clean(const struct nilfs_suinfo *si)
return !si->sui_flags;
}
+/**
+ * nilfs_suinfo_update - segment usage information update
+ * @sup_segnum: segment number
+ * @sup_flags: flags for which fields are active in sup_sui
+ * @sup_reserved: reserved necessary for alignment
+ * @sup_sui: segment usage information
+ */
+struct nilfs_suinfo_update {
+ __u64 sup_segnum;
+ __u32 sup_flags;
+ __u32 sup_reserved;
+ struct nilfs_suinfo sup_sui;
+};
+
+enum {
+ NILFS_SUINFO_UPDATE_LASTMOD,
+ NILFS_SUINFO_UPDATE_NBLOCKS,
+ NILFS_SUINFO_UPDATE_FLAGS,
+};
+
+#define NILFS_SUINFO_UPDATE_FNS(flag, name) \
+static inline void \
+nilfs_suinfo_update_set_##name(struct nilfs_suinfo_update *sup) \
+{ \
+ sup->sup_flags |= 1UL << NILFS_SUINFO_UPDATE_##flag; \
+} \
+static inline void \
+nilfs_suinfo_update_clear_##name(struct nilfs_suinfo_update *sup) \
+{ \
+ sup->sup_flags &= ~(1UL << NILFS_SUINFO_UPDATE_##flag); \
+} \
+static inline int \
+nilfs_suinfo_update_##name(const struct nilfs_suinfo_update *sup) \
+{ \
+ return !!(sup->sup_flags & (1UL << NILFS_SUINFO_UPDATE_##flag));\
+}
+
+NILFS_SUINFO_UPDATE_FNS(LASTMOD, lastmod)
+NILFS_SUINFO_UPDATE_FNS(NBLOCKS, nblocks)
+NILFS_SUINFO_UPDATE_FNS(FLAGS, flags)
+
/* ioctl */
enum {
NILFS_CHECKPOINT,
@@ -867,5 +908,7 @@ struct nilfs_bdesc {
_IOW(NILFS_IOCTL_IDENT, 0x8B, __u64)
#define NILFS_IOCTL_SET_ALLOC_RANGE \
_IOW(NILFS_IOCTL_IDENT, 0x8C, __u64[2])
+#define NILFS_IOCTL_SET_SUINFO \
+ _IOW(NILFS_IOCTL_IDENT, 0x8D, struct nilfs_argv)
#endif /* _LINUX_NILFS_FS_H */
diff --git a/lib/nilfs.c b/lib/nilfs.c
index 93822de..25664e1 100644
--- a/lib/nilfs.c
+++ b/lib/nilfs.c
@@ -596,6 +596,38 @@ ssize_t nilfs_get_suinfo(const struct nilfs *nilfs, __u64 segnum,
}
/**
+ * nilfs_set_suinfo - sets segment usage info
+ * @nilfs: nilfs object
+ * @sup: an array of nilfs_suinfo_update structs
+ * @nsup: number of elements in sup
+ *
+ * Description: Takes an array of nilfs_suinfo_update structs and updates
+ * segment usage info accordingly. Only the fields indicated by sup_flags
+ * are updated.
+ *
+ * Return Value: On success, 0 is returned. On error, -1 is returned.
+ */
+ssize_t nilfs_set_suinfo(const struct nilfs *nilfs,
+ struct nilfs_suinfo_update *sup, size_t nsup)
+{
+ struct nilfs_argv argv;
+
+ if (nilfs->n_iocfd < 0) {
+ errno = EBADF;
+ return -1;
+ }
+
+ argv.v_base = (unsigned long)sup;
+ argv.v_nmembs = nsup;
+ argv.v_size = sizeof(struct nilfs_suinfo_update);
+ argv.v_index = 0;
+ argv.v_flags = 0;
+ if (ioctl(nilfs->n_iocfd, NILFS_IOCTL_SET_SUINFO, &argv) < 0)
+ return -1;
+ return 0;
+}
+
+/**
* nilfs_get_sustat - get segment usage statistics
* @nilfs: nilfs object
* @sustat: buffer of a nilfs_sustat struct to store statistics in
--
1.8.5.3
--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-01-27 9:58 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-27 9:58 [PATCH v3 0/4] nilfs-utils: shortcut for certain GC operations Andreas Rohner
[not found] ` <cover.1390813175.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-01-27 9:58 ` [PATCH v3 1/4] nilfs-utils: cldconfig add an option to set min. reclaimable blocks Andreas Rohner
2014-01-27 9:58 ` [PATCH v3 2/4] nilfs-utils: nilfs-clean add cmdline param min-reclaimable-blocks Andreas Rohner
2014-01-27 9:58 ` Andreas Rohner [this message]
2014-01-27 9:58 ` [PATCH v3 4/4] nilfs-utils: add optimized version of nilfs_reclaim_segments Andreas Rohner
2014-01-27 9:59 ` [PATCH v3 1/3] nilfs2: add struct nilfs_suinfo_update and flags Andreas Rohner
[not found] ` <bb721a6255f199eb4a3fdfe2b34e0bdaa5f870a7.1390816620.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-01-27 9:59 ` [PATCH v3 2/3] nilfs2: add nilfs_sufile_set_suinfo to update segment usage Andreas Rohner
[not found] ` <93a209490951530b1b9eb03be4e3b309d36740f4.1390816620.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-01-27 19:07 ` Ryusuke Konishi
[not found] ` <20140128.040735.413842146.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2014-01-27 23:42 ` Andreas Rohner
[not found] ` <52E6EEEB.4080303-hi6Y0CQ0nG0@public.gmane.org>
2014-01-28 1:03 ` Ryusuke Konishi
[not found] ` <20140128.100304.163656186.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2014-01-28 4:26 ` Andreas Rohner
[not found] ` <52E7315D.4040909-hi6Y0CQ0nG0@public.gmane.org>
2014-01-28 7:39 ` Ryusuke Konishi
[not found] ` <20140128.163924.157483560.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2014-01-30 7:57 ` Ryusuke Konishi
[not found] ` <20140130.165734.221580541.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2014-01-30 8:09 ` Andreas Rohner
2014-01-27 9:59 ` [PATCH v3 3/3] nilfs2: implementation of NILFS_IOCTL_SET_SUINFO ioctl Andreas Rohner
[not found] ` <ce24b310783bf1a501408eeb0dfa268155c07444.1390816620.git.andreas.rohner-hi6Y0CQ0nG0@public.gmane.org>
2014-01-27 16:26 ` Ryusuke Konishi
2014-01-27 15:29 ` [PATCH v3 1/3] nilfs2: add struct nilfs_suinfo_update and flags Ryusuke Konishi
2014-01-27 15:03 ` [PATCH v3 0/4] nilfs-utils: shortcut for certain GC operations Ryusuke Konishi
[not found] ` <20140128.000336.27790167.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2014-01-27 15:47 ` Andreas Rohner
[not found] ` <52E67F94.9010208-hi6Y0CQ0nG0@public.gmane.org>
2014-01-27 16:40 ` Ryusuke Konishi
2014-01-27 16:35 ` Andreas Rohner
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=a69dc4d73e1e247740dd0ffedba7261b58437f77.1390813175.git.andreas.rohner@gmx.net \
--to=andreas.rohner-hi6y0cq0ng0@public.gmane.org \
--cc=linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.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