* [PATCH] btrfs-progs: ins: print c/o/s/r time of ROOT_ITEM
@ 2017-10-31 5:40 Misono, Tomohiro
2017-10-31 5:58 ` Qu Wenruo
0 siblings, 1 reply; 3+ messages in thread
From: Misono, Tomohiro @ 2017-10-31 5:40 UTC (permalink / raw)
To: linux-btrfs
Currently c/o/s/r time of ROOT_ITEM is not printed in print_root_item().
Fix this and print them if the values are not zero. print_timespec()
is moved forward to reuse.
Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
---
ctree.h | 32 ++++++++++++++++++++++++++++++++
print-tree.c | 52 ++++++++++++++++++++++++++++++++--------------------
2 files changed, 64 insertions(+), 20 deletions(-)
diff --git a/ctree.h b/ctree.h
index 2280659..54a85fd 100644
--- a/ctree.h
+++ b/ctree.h
@@ -2072,6 +2072,38 @@ BTRFS_SETGET_STACK_FUNCS(root_stransid, struct btrfs_root_item,
BTRFS_SETGET_STACK_FUNCS(root_rtransid, struct btrfs_root_item,
rtransid, 64);
+static inline struct btrfs_timespec *
+btrfs_root_ctime(struct btrfs_root_item *root_item)
+{
+ unsigned long ptr = (unsigned long)root_item;
+ ptr += offsetof(struct btrfs_root_item, ctime);
+ return (struct btrfs_timespec *)ptr;
+}
+
+static inline struct btrfs_timespec *
+btrfs_root_otime(struct btrfs_root_item *root_item)
+{
+ unsigned long ptr = (unsigned long)root_item;
+ ptr += offsetof(struct btrfs_root_item, otime);
+ return (struct btrfs_timespec *)ptr;
+}
+
+static inline struct btrfs_timespec *
+btrfs_root_stime(struct btrfs_root_item *root_item)
+{
+ unsigned long ptr = (unsigned long)root_item;
+ ptr += offsetof(struct btrfs_root_item, stime);
+ return (struct btrfs_timespec *)ptr;
+}
+
+static inline struct btrfs_timespec *
+btrfs_root_rtime(struct btrfs_root_item *root_item)
+{
+ unsigned long ptr = (unsigned long)root_item;
+ ptr += offsetof(struct btrfs_root_item, rtime);
+ return (struct btrfs_timespec *)ptr;
+}
+
/* struct btrfs_root_backup */
BTRFS_SETGET_STACK_FUNCS(backup_tree_root, struct btrfs_root_backup,
tree_root, 64);
diff --git a/print-tree.c b/print-tree.c
index 9d1b862..62f3163 100644
--- a/print-tree.c
+++ b/print-tree.c
@@ -551,6 +551,26 @@ static void root_flags_to_str(u64 flags, char *ret)
strcat(ret, "none");
}
+static void print_timespec(struct extent_buffer *eb,
+ struct btrfs_timespec *timespec, const char *prefix,
+ const char *suffix)
+{
+ struct tm tm;
+ u64 tmp_u64;
+ u32 tmp_u32;
+ time_t tmp_time;
+ char timestamp[256];
+
+ tmp_u64 = btrfs_timespec_sec(eb, timespec);
+ tmp_u32 = btrfs_timespec_nsec(eb, timespec);
+ tmp_time = tmp_u64;
+ localtime_r(&tmp_time, &tm);
+ strftime(timestamp, sizeof(timestamp),
+ "%Y-%m-%d %H:%M:%S", &tm);
+ printf("%s%llu.%u (%s)%s", prefix, (unsigned long long)tmp_u64, tmp_u32,
+ timestamp, suffix);
+}
+
static void print_root_item(struct extent_buffer *leaf, int slot)
{
struct btrfs_root_item *ri;
@@ -600,6 +620,18 @@ static void print_root_item(struct extent_buffer *leaf, int slot)
btrfs_root_stransid(&root_item),
btrfs_root_rtransid(&root_item));
}
+ if (btrfs_timespec_sec(leaf, btrfs_root_ctime(ri)))
+ print_timespec(leaf, btrfs_root_ctime(ri),
+ "\t\tctime ", "\n");
+ if (btrfs_timespec_sec(leaf, btrfs_root_otime(ri)))
+ print_timespec(leaf, btrfs_root_otime(ri),
+ "\t\totime ", "\n");
+ if (btrfs_timespec_sec(leaf, btrfs_root_stime(ri)))
+ print_timespec(leaf, btrfs_root_stime(ri),
+ "\t\tstime ", "\n");
+ if (btrfs_timespec_sec(leaf, btrfs_root_rtime(ri)))
+ print_timespec(leaf, btrfs_root_rtime(ri),
+ "\t\trtime ", "\n");
}
btrfs_disk_key_to_cpu(&drop_key, &root_item.drop_progress);
@@ -858,26 +890,6 @@ static void inode_flags_to_str(u64 flags, char *ret)
strcat(ret, "none");
}
-static void print_timespec(struct extent_buffer *eb,
- struct btrfs_timespec *timespec, const char *prefix,
- const char *suffix)
-{
- struct tm tm;
- u64 tmp_u64;
- u32 tmp_u32;
- time_t tmp_time;
- char timestamp[256];
-
- tmp_u64 = btrfs_timespec_sec(eb, timespec);
- tmp_u32 = btrfs_timespec_nsec(eb, timespec);
- tmp_time = tmp_u64;
- localtime_r(&tmp_time, &tm);
- strftime(timestamp, sizeof(timestamp),
- "%Y-%m-%d %H:%M:%S", &tm);
- printf("%s%llu.%u (%s)%s", prefix, (unsigned long long)tmp_u64, tmp_u32,
- timestamp, suffix);
-}
-
static void print_inode_item(struct extent_buffer *eb,
struct btrfs_inode_item *ii)
{
--
2.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] btrfs-progs: ins: print c/o/s/r time of ROOT_ITEM
2017-10-31 5:40 [PATCH] btrfs-progs: ins: print c/o/s/r time of ROOT_ITEM Misono, Tomohiro
@ 2017-10-31 5:58 ` Qu Wenruo
2017-11-20 18:09 ` David Sterba
0 siblings, 1 reply; 3+ messages in thread
From: Qu Wenruo @ 2017-10-31 5:58 UTC (permalink / raw)
To: Misono, Tomohiro, linux-btrfs
[-- Attachment #1.1: Type: text/plain, Size: 4615 bytes --]
On 2017年10月31日 13:40, Misono, Tomohiro wrote:
> Currently c/o/s/r time of ROOT_ITEM is not printed in print_root_item().
> Fix this and print them if the values are not zero. print_timespec()
> is moved forward to reuse.
>
> Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> ctree.h | 32 ++++++++++++++++++++++++++++++++
> print-tree.c | 52 ++++++++++++++++++++++++++++++++--------------------
> 2 files changed, 64 insertions(+), 20 deletions(-)
>
> diff --git a/ctree.h b/ctree.h
> index 2280659..54a85fd 100644
> --- a/ctree.h
> +++ b/ctree.h
> @@ -2072,6 +2072,38 @@ BTRFS_SETGET_STACK_FUNCS(root_stransid, struct btrfs_root_item,
> BTRFS_SETGET_STACK_FUNCS(root_rtransid, struct btrfs_root_item,
> rtransid, 64);
>
> +static inline struct btrfs_timespec *
> +btrfs_root_ctime(struct btrfs_root_item *root_item)
> +{
> + unsigned long ptr = (unsigned long)root_item;
> + ptr += offsetof(struct btrfs_root_item, ctime);
> + return (struct btrfs_timespec *)ptr;
> +}
> +
> +static inline struct btrfs_timespec *
> +btrfs_root_otime(struct btrfs_root_item *root_item)
> +{
> + unsigned long ptr = (unsigned long)root_item;
> + ptr += offsetof(struct btrfs_root_item, otime);
> + return (struct btrfs_timespec *)ptr;
> +}
> +
> +static inline struct btrfs_timespec *
> +btrfs_root_stime(struct btrfs_root_item *root_item)
> +{
> + unsigned long ptr = (unsigned long)root_item;
> + ptr += offsetof(struct btrfs_root_item, stime);
> + return (struct btrfs_timespec *)ptr;
> +}
> +
> +static inline struct btrfs_timespec *
> +btrfs_root_rtime(struct btrfs_root_item *root_item)
> +{
> + unsigned long ptr = (unsigned long)root_item;
> + ptr += offsetof(struct btrfs_root_item, rtime);
> + return (struct btrfs_timespec *)ptr;
> +}
> +
> /* struct btrfs_root_backup */
> BTRFS_SETGET_STACK_FUNCS(backup_tree_root, struct btrfs_root_backup,
> tree_root, 64);
> diff --git a/print-tree.c b/print-tree.c
> index 9d1b862..62f3163 100644
> --- a/print-tree.c
> +++ b/print-tree.c
> @@ -551,6 +551,26 @@ static void root_flags_to_str(u64 flags, char *ret)
> strcat(ret, "none");
> }
>
> +static void print_timespec(struct extent_buffer *eb,
> + struct btrfs_timespec *timespec, const char *prefix,
> + const char *suffix)
> +{
> + struct tm tm;
> + u64 tmp_u64;
> + u32 tmp_u32;
> + time_t tmp_time;
> + char timestamp[256];
> +
> + tmp_u64 = btrfs_timespec_sec(eb, timespec);
> + tmp_u32 = btrfs_timespec_nsec(eb, timespec);
> + tmp_time = tmp_u64;
> + localtime_r(&tmp_time, &tm);
> + strftime(timestamp, sizeof(timestamp),
> + "%Y-%m-%d %H:%M:%S", &tm);
> + printf("%s%llu.%u (%s)%s", prefix, (unsigned long long)tmp_u64, tmp_u32,
> + timestamp, suffix);
> +}
> +
> static void print_root_item(struct extent_buffer *leaf, int slot)
> {
> struct btrfs_root_item *ri;
> @@ -600,6 +620,18 @@ static void print_root_item(struct extent_buffer *leaf, int slot)
> btrfs_root_stransid(&root_item),
> btrfs_root_rtransid(&root_item));
> }
> + if (btrfs_timespec_sec(leaf, btrfs_root_ctime(ri)))
> + print_timespec(leaf, btrfs_root_ctime(ri),
> + "\t\tctime ", "\n");
> + if (btrfs_timespec_sec(leaf, btrfs_root_otime(ri)))
> + print_timespec(leaf, btrfs_root_otime(ri),
> + "\t\totime ", "\n");
> + if (btrfs_timespec_sec(leaf, btrfs_root_stime(ri)))
> + print_timespec(leaf, btrfs_root_stime(ri),
> + "\t\tstime ", "\n");
> + if (btrfs_timespec_sec(leaf, btrfs_root_rtime(ri)))
> + print_timespec(leaf, btrfs_root_rtime(ri),
> + "\t\trtime ", "\n");
> }
>
> btrfs_disk_key_to_cpu(&drop_key, &root_item.drop_progress);
> @@ -858,26 +890,6 @@ static void inode_flags_to_str(u64 flags, char *ret)
> strcat(ret, "none");
> }
>
> -static void print_timespec(struct extent_buffer *eb,
> - struct btrfs_timespec *timespec, const char *prefix,
> - const char *suffix)
> -{
> - struct tm tm;
> - u64 tmp_u64;
> - u32 tmp_u32;
> - time_t tmp_time;
> - char timestamp[256];
> -
> - tmp_u64 = btrfs_timespec_sec(eb, timespec);
> - tmp_u32 = btrfs_timespec_nsec(eb, timespec);
> - tmp_time = tmp_u64;
> - localtime_r(&tmp_time, &tm);
> - strftime(timestamp, sizeof(timestamp),
> - "%Y-%m-%d %H:%M:%S", &tm);
> - printf("%s%llu.%u (%s)%s", prefix, (unsigned long long)tmp_u64, tmp_u32,
> - timestamp, suffix);
> -}
> -
> static void print_inode_item(struct extent_buffer *eb,
> struct btrfs_inode_item *ii)
> {
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 504 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] btrfs-progs: ins: print c/o/s/r time of ROOT_ITEM
2017-10-31 5:58 ` Qu Wenruo
@ 2017-11-20 18:09 ` David Sterba
0 siblings, 0 replies; 3+ messages in thread
From: David Sterba @ 2017-11-20 18:09 UTC (permalink / raw)
To: Qu Wenruo; +Cc: Misono, Tomohiro, linux-btrfs
On Tue, Oct 31, 2017 at 01:58:04PM +0800, Qu Wenruo wrote:
>
>
> On 2017年10月31日 13:40, Misono, Tomohiro wrote:
> > Currently c/o/s/r time of ROOT_ITEM is not printed in print_root_item().
> > Fix this and print them if the values are not zero. print_timespec()
> > is moved forward to reuse.
> >
> > Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
>
> Reviewed-by: Qu Wenruo <wqu@suse.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-20 18:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-31 5:40 [PATCH] btrfs-progs: ins: print c/o/s/r time of ROOT_ITEM Misono, Tomohiro
2017-10-31 5:58 ` Qu Wenruo
2017-11-20 18:09 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox