Re: [PATCH 6/6] [RFC] ext4: super: extend timestamps to 40 bits
From: Arnd Bergmann <arnd@arndb.de>
Date: 2018-06-21 20:17:47
Also in:
lkml
On Thu, Jun 21, 2018 at 7:46 PM, Andreas Dilger [off-list ref] wrote:
quoted
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 0c4c2201b3aa..2063d4e5ed08 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c@@ -312,6 +312,20 @@ void ext4_itable_unused_set(struct super_block *sb, bg->bg_itable_unused_hi = cpu_to_le16(count >> 16);} +static void ext4_update_tstamp(__le32 *lo, __u8 *hi)Would it be better to wrap this in a macro, something like: #define ext4_update_tstamp(es, tstamp) \ __ext4_update_tstamp(&(es)->tstamp, &(es)->tstamp ## _hi) #define ext4_get_tstamp(es, tstamp) \ __ext4_get_tstamp(&(es)->tstamp, &(es)->tstamp ## _hi) So that it can be used in the callers more easily: ext4_update_tstamp(es, s_last_error_time); time = ext4_get_tstamp(es, s_last_error_time);
I generally try to avoid concatenating identifiers like this, as it makes it much harder to grep for where a particular symbol or struct member gets used.
quoted
+{ + time64_t now = ktime_get_real_seconds(); + + now = clamp_val(now, 0, 0xffffffffffull);Long strings of "0xfff..." are hard to get correct. This looks right, but it may be easier to be sure it is correct with something like: /* timestamps have a 32-bit low field and 8-bit high field */ now = clamp_val(now, 0, (1ULL << 40) - 1);
Yes, good idea. I'm surprised we don't have a generic macro for that yet (or maybe I just couldn't find it)
quoted
@@ -249,6 +251,12 @@ static void *calc_ptr(struct ext4_attr *a, struct ext4_sb_info *sbi) return NULL;} +static ssize_t print_time(char *buf, __le32 lo, __u8 hi)It would probably be more consistent to name this "print_tstamp()" since it isn't strictly a "time" as one would expect.
Ok.
quoted
+{ + return snprintf(buf, PAGE_SIZE, "%lld", + ((time64_t)hi << 32) + le32_to_cpu(lo)); +}Similarly, wrap this with: #define print_tstamp(buf, es, tstamp) \ __print_tstamp(buf, &(es)->tstamp, &(es)->tstamp ## _hi)
Ok. I'll integrate all of the above and post as a non-RFC patch then
after some testing.
Arnd