* [PATCH 6/6] Btrfs: add send_stream_version attribute to sysfs [not found] <1397659726-30615-6-git-send-email-fdmanana@gmail.com> @ 2014-04-20 14:07 ` Filipe David Borba Manana 2014-04-20 21:40 ` [PATCH 6/6 v2] " Filipe David Borba Manana 2014-06-23 12:01 ` [PATCH 6/6 v5] " Filipe David Borba Manana 0 siblings, 2 replies; 5+ messages in thread From: Filipe David Borba Manana @ 2014-04-20 14:07 UTC (permalink / raw) To: linux-btrfs; +Cc: Filipe David Borba Manana So that applications can find out what's the highest send stream version supported/implemented by the running kernel: $ cat /sys/fs/btrfs/send_stream_version 2 Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> --- fs/btrfs/send.h | 1 + fs/btrfs/sysfs.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/fs/btrfs/send.h b/fs/btrfs/send.h index 987936c..047fd6d 100644 --- a/fs/btrfs/send.h +++ b/fs/btrfs/send.h @@ -22,6 +22,7 @@ #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream" #define BTRFS_SEND_STREAM_VERSION_1 1 #define BTRFS_SEND_STREAM_VERSION_2 2 +#define BTRFS_SEND_STREAM_VERSION_LATEST BTRFS_SEND_STREAM_VERSION_2 #define BTRFS_SEND_BUF_SIZE (1024 * 64) #define BTRFS_SEND_READ_SIZE (1024 * 48) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 58a1dd1..2f8fff6 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -31,6 +31,7 @@ #include "transaction.h" #include "sysfs.h" #include "volumes.h" +#include "send.h" static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj); @@ -662,6 +663,36 @@ static int btrfs_init_debugfs(void) return 0; } +static ssize_t send_stream_version_show(struct kobject *kobj, + struct kobj_attribute *a, + char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", + BTRFS_SEND_STREAM_VERSION_LATEST); +} + +BTRFS_ATTR(send_stream_version, 0444, send_stream_version_show); + +static const struct attribute *btrfs_root_attrs[] = { + BTRFS_ATTR_PTR(send_stream_version), + NULL +}; + +static int add_root_attrs(struct kobject *kobj) +{ + int error = 0; + int i; + + for (i = 0; btrfs_root_attrs[i]; i++) { + const struct attribute *a = btrfs_root_attrs[i]; + + error = sysfs_add_file_to_group(kobj->parent, a, kobj->name); + if (error) + break; + } + return error; +} + int btrfs_init_sysfs(void) { int ret; @@ -678,8 +709,13 @@ int btrfs_init_sysfs(void) ret = sysfs_create_group(&btrfs_kset->kobj, &btrfs_feature_attr_group); if (ret) goto out2; + ret = add_root_attrs(&btrfs_kset->kobj); + if (ret) + goto out3; return 0; +out3: + sysfs_remove_group(&btrfs_kset->kobj, &btrfs_feature_attr_group); out2: debugfs_remove_recursive(btrfs_debugfs_root_dentry); out1: -- 1.9.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 6/6 v2] Btrfs: add send_stream_version attribute to sysfs 2014-04-20 14:07 ` [PATCH 6/6] Btrfs: add send_stream_version attribute to sysfs Filipe David Borba Manana @ 2014-04-20 21:40 ` Filipe David Borba Manana 2014-05-02 15:46 ` David Sterba 2014-06-23 12:01 ` [PATCH 6/6 v5] " Filipe David Borba Manana 1 sibling, 1 reply; 5+ messages in thread From: Filipe David Borba Manana @ 2014-04-20 21:40 UTC (permalink / raw) To: linux-btrfs; +Cc: Filipe David Borba Manana So that applications can find out what's the highest send stream version supported/implemented by the running kernel: $ cat /sys/fs/btrfs/send/stream_version 2 Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> --- V2: Renamed /sys/fs/btrfs/send_stream_version to /sys/fs/btrfs/send/stream_version, as in the future it might be useful to add other sysfs attrbutes related to send (other ro information or tunables like internal buffer sizes, etc). fs/btrfs/send.h | 1 + fs/btrfs/sysfs.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/fs/btrfs/send.h b/fs/btrfs/send.h index 987936c..047fd6d 100644 --- a/fs/btrfs/send.h +++ b/fs/btrfs/send.h @@ -22,6 +22,7 @@ #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream" #define BTRFS_SEND_STREAM_VERSION_1 1 #define BTRFS_SEND_STREAM_VERSION_2 2 +#define BTRFS_SEND_STREAM_VERSION_LATEST BTRFS_SEND_STREAM_VERSION_2 #define BTRFS_SEND_BUF_SIZE (1024 * 64) #define BTRFS_SEND_READ_SIZE (1024 * 48) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 58a1dd1..d93c0b5 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -31,6 +31,7 @@ #include "transaction.h" #include "sysfs.h" #include "volumes.h" +#include "send.h" static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj); @@ -662,6 +663,26 @@ static int btrfs_init_debugfs(void) return 0; } +static ssize_t send_stream_version_show(struct kobject *kobj, + struct kobj_attribute *a, + char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", + BTRFS_SEND_STREAM_VERSION_LATEST); +} + +BTRFS_ATTR(stream_version, 0444, send_stream_version_show); + +static struct attribute *btrfs_send_attrs[] = { + BTRFS_ATTR_PTR(stream_version), + NULL +}; + +static const struct attribute_group btrfs_send_attr_group = { + .name = "send", + .attrs = btrfs_send_attrs, +}; + int btrfs_init_sysfs(void) { int ret; @@ -678,8 +699,13 @@ int btrfs_init_sysfs(void) ret = sysfs_create_group(&btrfs_kset->kobj, &btrfs_feature_attr_group); if (ret) goto out2; + ret = sysfs_create_group(&btrfs_kset->kobj, &btrfs_send_attr_group); + if (ret) + goto out3; return 0; +out3: + sysfs_remove_group(&btrfs_kset->kobj, &btrfs_feature_attr_group); out2: debugfs_remove_recursive(btrfs_debugfs_root_dentry); out1: @@ -691,6 +717,7 @@ out1: void btrfs_exit_sysfs(void) { sysfs_remove_group(&btrfs_kset->kobj, &btrfs_feature_attr_group); + sysfs_remove_group(&btrfs_kset->kobj, &btrfs_send_attr_group); kset_unregister(btrfs_kset); debugfs_remove_recursive(btrfs_debugfs_root_dentry); } -- 1.9.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 6/6 v2] Btrfs: add send_stream_version attribute to sysfs 2014-04-20 21:40 ` [PATCH 6/6 v2] " Filipe David Borba Manana @ 2014-05-02 15:46 ` David Sterba 2014-05-02 16:10 ` Filipe David Manana 0 siblings, 1 reply; 5+ messages in thread From: David Sterba @ 2014-05-02 15:46 UTC (permalink / raw) To: Filipe David Borba Manana; +Cc: linux-btrfs On Sun, Apr 20, 2014 at 10:40:03PM +0100, Filipe David Borba Manana wrote: > So that applications can find out what's the highest send stream > version supported/implemented by the running kernel: > > $ cat /sys/fs/btrfs/send/stream_version > 2 > > Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> > --- > > V2: Renamed /sys/fs/btrfs/send_stream_version to /sys/fs/btrfs/send/stream_version, > as in the future it might be useful to add other sysfs attrbutes related to > send (other ro information or tunables like internal buffer sizes, etc). Sounds good, I don't see any issue with the separate directory. Mixing it with /sys/fs/btrfs/features does not seem suitable for that if you intend adding more entries. Reviewed-by: David Sterba <dsterba@suse.cz> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 6/6 v2] Btrfs: add send_stream_version attribute to sysfs 2014-05-02 15:46 ` David Sterba @ 2014-05-02 16:10 ` Filipe David Manana 0 siblings, 0 replies; 5+ messages in thread From: Filipe David Manana @ 2014-05-02 16:10 UTC (permalink / raw) To: dsterba@suse.cz, Filipe David Borba Manana, linux-btrfs@vger.kernel.org On Fri, May 2, 2014 at 4:46 PM, David Sterba <dsterba@suse.cz> wrote: > On Sun, Apr 20, 2014 at 10:40:03PM +0100, Filipe David Borba Manana wrote: >> So that applications can find out what's the highest send stream >> version supported/implemented by the running kernel: >> >> $ cat /sys/fs/btrfs/send/stream_version >> 2 >> >> Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> >> --- >> >> V2: Renamed /sys/fs/btrfs/send_stream_version to /sys/fs/btrfs/send/stream_version, >> as in the future it might be useful to add other sysfs attrbutes related to >> send (other ro information or tunables like internal buffer sizes, etc). > > Sounds good, I don't see any issue with the separate directory. Mixing > it with /sys/fs/btrfs/features does not seem suitable for that if you > intend adding more entries. Yeah, I only didn't mix it with the features subdir because that relates to features that are settable, plus there's 2 versions of it, one global and one per fs (uuid) subdirectory (and it felt odd to me to add it to one of those subdirs and not the other). Thanks David > > Reviewed-by: David Sterba <dsterba@suse.cz> -- Filipe David Manana, "Reasonable men adapt themselves to the world. Unreasonable men adapt the world to themselves. That's why all progress depends on unreasonable men." ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 6/6 v5] Btrfs: add send_stream_version attribute to sysfs 2014-04-20 14:07 ` [PATCH 6/6] Btrfs: add send_stream_version attribute to sysfs Filipe David Borba Manana 2014-04-20 21:40 ` [PATCH 6/6 v2] " Filipe David Borba Manana @ 2014-06-23 12:01 ` Filipe David Borba Manana 1 sibling, 0 replies; 5+ messages in thread From: Filipe David Borba Manana @ 2014-06-23 12:01 UTC (permalink / raw) To: linux-btrfs; +Cc: Filipe David Borba Manana So that applications can find out what's the highest send stream version supported/implemented by the running kernel: $ cat /sys/fs/btrfs/send/stream_version 2 Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Reviewed-by: David Sterba <dsterba@suse.cz> --- V1..V4: There's no v1, v2, v3 and v4. Bumped directly to v5 to make all patches in the series have the same version. V5: Rebased against latest chris/integration branch. fs/btrfs/send.h | 1 + fs/btrfs/sysfs.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/fs/btrfs/send.h b/fs/btrfs/send.h index 987936c..047fd6d 100644 --- a/fs/btrfs/send.h +++ b/fs/btrfs/send.h @@ -22,6 +22,7 @@ #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream" #define BTRFS_SEND_STREAM_VERSION_1 1 #define BTRFS_SEND_STREAM_VERSION_2 2 +#define BTRFS_SEND_STREAM_VERSION_LATEST BTRFS_SEND_STREAM_VERSION_2 #define BTRFS_SEND_BUF_SIZE (1024 * 64) #define BTRFS_SEND_READ_SIZE (1024 * 48) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 06ad529..9869d94 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -31,6 +31,7 @@ #include "transaction.h" #include "sysfs.h" #include "volumes.h" +#include "send.h" static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj); @@ -700,6 +701,26 @@ static int btrfs_init_debugfs(void) return 0; } +static ssize_t send_stream_version_show(struct kobject *kobj, + struct kobj_attribute *a, + char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", + BTRFS_SEND_STREAM_VERSION_LATEST); +} + +BTRFS_ATTR(stream_version, 0444, send_stream_version_show); + +static struct attribute *btrfs_send_attrs[] = { + BTRFS_ATTR_PTR(stream_version), + NULL +}; + +static const struct attribute_group btrfs_send_attr_group = { + .name = "send", + .attrs = btrfs_send_attrs, +}; + int btrfs_init_sysfs(void) { int ret; @@ -716,8 +737,13 @@ int btrfs_init_sysfs(void) ret = sysfs_create_group(&btrfs_kset->kobj, &btrfs_feature_attr_group); if (ret) goto out2; + ret = sysfs_create_group(&btrfs_kset->kobj, &btrfs_send_attr_group); + if (ret) + goto out3; return 0; +out3: + sysfs_remove_group(&btrfs_kset->kobj, &btrfs_feature_attr_group); out2: debugfs_remove_recursive(btrfs_debugfs_root_dentry); out1: @@ -729,6 +755,7 @@ out1: void btrfs_exit_sysfs(void) { sysfs_remove_group(&btrfs_kset->kobj, &btrfs_feature_attr_group); + sysfs_remove_group(&btrfs_kset->kobj, &btrfs_send_attr_group); kset_unregister(btrfs_kset); debugfs_remove_recursive(btrfs_debugfs_root_dentry); } -- 1.9.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-06-23 11:01 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <1397659726-30615-6-git-send-email-fdmanana@gmail.com> 2014-04-20 14:07 ` [PATCH 6/6] Btrfs: add send_stream_version attribute to sysfs Filipe David Borba Manana 2014-04-20 21:40 ` [PATCH 6/6 v2] " Filipe David Borba Manana 2014-05-02 15:46 ` David Sterba 2014-05-02 16:10 ` Filipe David Manana 2014-06-23 12:01 ` [PATCH 6/6 v5] " Filipe David Borba Manana
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).