From: Bobi Jam Date: Thu, 20 Sep 2018 07:50:45 +0000 (+0800) Subject: LU-11400 flr: add 'nosync' flag for FLR mirrors X-Git-Tag: 2.11.56~31 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=8a0554450eaaf86acbc9b6a4c8228dc32ab71b19 LU-11400 flr: add 'nosync' flag for FLR mirrors This patch allows 'nosync' flag to be set for FLR mirror components, which makes lfs mirror resync skip on mirrors with this flag unless mirror resync explicitly requested those mirrors to be resync. This flag can be cleared by set '^nosync' on any component of the mirror. Signed-off-by: Bobi Jam Change-Id: I209ad91fd9a96d82f8c83a3eb047f665ef4ccf86 Reviewed-on: https://review.whamcloud.com/33205 Tested-by: Jenkins Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu Tested-by: Maloo Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- diff --git a/lustre/doc/lfs-getstripe.1 b/lustre/doc/lfs-getstripe.1 index e8a18cc..7c4190b 100644 --- a/lustre/doc/lfs-getstripe.1 +++ b/lustre/doc/lfs-getstripe.1 @@ -112,6 +112,11 @@ before they can be accessed again. Replicated (mirrored) components that are preferred for read or write. For example, because they are located on SSD-based OSTs, or are more local on the network to clients. +.TP +.B nosync +Replicated (mirrored) components that do not resync using \fB +lfs mirror resync\fR. Files with the \fBnosync\fR flag will also +print the timestamp when the flag was set on the replica. .RE .TP .BR --component-id | --comp-id [ =\fIid ]| -I [ \fIid ] diff --git a/lustre/doc/lfs-mirror-resync.1 b/lustre/doc/lfs-mirror-resync.1 index 8ae9ba9..23d4849 100644 --- a/lustre/doc/lfs-mirror-resync.1 +++ b/lustre/doc/lfs-mirror-resync.1 @@ -12,8 +12,13 @@ name \fImirrored_file\fR. If there is no stale mirror for the \fImirrored_file(s)\fR, then the command does nothing. Otherwise, it will copy data from synced mirror to stale mirror(s), and mark all successfully copied mirror(s) as SYNC. +.br +If \fB\-\-only\fR option is not specified, the \fBnosync\fR mirror(s) (i.e. +components that have this flag set) will not be synced. +.br If \fB\-\-only\fR <\fImirror_id\fR[,...]> option is specified, then the -command will resynchronize the mirror(s) specified by the \fImirror_id\fR(s). +command will resynchronize the mirror(s) specified by the \fImirror_id\fR(s), +even nosync mirror(s) will be resynchronized as well. This option cannot be used when multiple mirrored files are specified. .SH OPTIONS .TP @@ -25,7 +30,7 @@ be used when multiple mirrored files are specified. .SH EXAMPLES .TP .B lfs mirror resync /mnt/lustre/file1 /mnt/lustre/file2 -Resynchronize all of the stale mirror(s) for /mnt/lustre/file1 and /mnt/lustre/file2. +Resynchronize all of the stale and sync-able mirror(s) for /mnt/lustre/file1 and /mnt/lustre/file2. .TP .B lfs mirror resync --only 4,5 /mnt/lustre/file1 Resynchronize mirrors with mirror ID 4 and 5 for /mnt/lustre/file1 even if they diff --git a/lustre/doc/lfs-setstripe.1 b/lustre/doc/lfs-setstripe.1 index 5009354..5118ac4 100644 --- a/lustre/doc/lfs-setstripe.1 +++ b/lustre/doc/lfs-setstripe.1 @@ -310,21 +310,27 @@ on a specific component. Allowed .I flags are: .RS -.B init\fR - component is initialized (has allocated objects). Used with +.B * init\fR - component is initialized (has allocated objects). Used with .B --component-del --component-flags ^init to find uninitialized components. .RE .RS -.B prefer\fR - component preferred for read/write in a mirrored file +.B * prefer\fR - component preferred for read/write in a mirrored file .RE .RS -.B stale\fR - component has outdated data in a mirrored file. Once a +.B * stale\fR - component has outdated data in a mirrored file. Once a component is marked .BR stale , it isn't permitted to clear this flag directly. \fBlfs-mirror-resync\fR(1) is required to clear the flag. .RE .RS +.B * nosync\fR - mirror components will not be resynched by default when the +.BR lfs-mirror-resync (1) +command is run. This option is useful to freeze a file mirror as an old +version or snapshot of the file. +.RE +.RS A leading '^' before \fIflags\fR clears the flags, or finds components not matching the flags. Multiple flags can be separated by comma(s). .RE diff --git a/lustre/include/lustre/lustreapi.h b/lustre/include/lustre/lustreapi.h index b593f7f..69b1d2e 100644 --- a/lustre/include/lustre/lustreapi.h +++ b/lustre/include/lustre/lustreapi.h @@ -869,6 +869,7 @@ static const struct comp_flag_name { { LCME_FL_STALE, "stale" }, { LCME_FL_PREF_RW, "prefer" }, { LCME_FL_OFFLINE, "offline" }, + { LCME_FL_NOSYNC, "nosync" }, }; /** diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index ab640fa..61a565f 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -594,15 +594,19 @@ enum lov_comp_md_entry_flags { LCME_FL_PREF_RW = LCME_FL_PREF_RD | LCME_FL_PREF_WR, LCME_FL_OFFLINE = 0x00000008, /* Not used */ LCME_FL_INIT = 0x00000010, /* instantiated */ + LCME_FL_NOSYNC = 0x00000020, /* FLR: no sync for the mirror */ LCME_FL_NEG = 0x80000000 /* used to indicate a negative flag, won't be stored on disk */ }; #define LCME_KNOWN_FLAGS (LCME_FL_NEG | LCME_FL_INIT | LCME_FL_STALE | \ - LCME_FL_PREF_RW) + LCME_FL_PREF_RW | LCME_FL_NOSYNC) /* The flags can be set by users at mirror creation time. */ #define LCME_USER_FLAGS (LCME_FL_PREF_RW) +/* The flags are for mirrors */ +#define LCME_MIRROR_FLAGS (LCME_FL_NOSYNC) + /* the highest bit in obdo::o_layout_version is used to mark if the file is * being resynced. */ #define LU_LAYOUT_RESYNC LCME_FL_NEG @@ -628,8 +632,8 @@ struct lov_comp_md_entry_v1 { start from lov_comp_md_v1 */ __u32 lcme_size; /* size of component blob */ __u32 lcme_layout_gen; + __u64 lcme_timestamp; /* snapshot time if applicable*/ __u32 lcme_padding_1; - __u64 lcme_padding_2; } __attribute__((packed)); #define SEQ_ID_MAX 0x0000FFFF diff --git a/lustre/lod/lod_internal.h b/lustre/lod/lod_internal.h index ed7dcf1..9d73ffa 100644 --- a/lustre/lod/lod_internal.h +++ b/lustre/lod/lod_internal.h @@ -254,6 +254,7 @@ struct lod_layout_component { __u16 llc_stripe_offset; __u16 llc_stripe_count; __u16 llc_stripes_allocated; + __u64 llc_timestamp; /* snapshot time */ char *llc_pool; /* ost list specified with LOV_USER_MAGIC_SPECIFIC lum */ struct ost_pool llc_ostlist; diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 9e25dc4..c29e9ab 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -986,6 +986,9 @@ int lod_generate_lovea(const struct lu_env *env, struct lod_object *lo, /* component could be un-inistantiated */ lcme->lcme_flags = cpu_to_le32(lod_comp->llc_flags); + if (lod_comp->llc_flags & LCME_FL_NOSYNC) + lcme->lcme_timestamp = + cpu_to_le64(lod_comp->llc_timestamp); lcme->lcme_extent.e_start = cpu_to_le64(lod_comp->llc_extent.e_start); lcme->lcme_extent.e_end = @@ -1284,6 +1287,9 @@ int lod_parse_striping(const struct lu_env *env, struct lod_object *lo, lod_comp->llc_extent.e_end = le64_to_cpu(ext->e_end); lod_comp->llc_flags = le32_to_cpu(comp_v1->lcm_entries[i].lcme_flags); + if (lod_comp->llc_flags & LCME_FL_NOSYNC) + lod_comp->llc_timestamp = le64_to_cpu( + comp_v1->lcm_entries[i].lcme_timestamp); lod_comp->llc_id = le32_to_cpu(comp_v1->lcm_entries[i].lcme_id); if (lod_comp->llc_id == LCME_ID_INVAL) diff --git a/lustre/lod/lod_object.c b/lustre/lod/lod_object.c index 0b34a43..7bab1b0 100644 --- a/lustre/lod/lod_object.c +++ b/lustre/lod/lod_object.c @@ -2793,6 +2793,8 @@ static int lod_declare_layout_set(const struct lu_env *env, for (i = 0; i < comp_v1->lcm_entry_count; i++) { __u32 id = comp_v1->lcm_entries[i].lcme_id; __u32 flags = comp_v1->lcm_entries[i].lcme_flags; + __u32 mirror_flag = flags & LCME_MIRROR_FLAGS; + bool neg = flags & LCME_FL_NEG; if (flags & LCME_FL_INIT) { if (changed) @@ -2800,16 +2802,30 @@ static int lod_declare_layout_set(const struct lu_env *env, RETURN(-EINVAL); } + flags &= ~(LCME_MIRROR_FLAGS | LCME_FL_NEG); for (j = 0; j < lo->ldo_comp_cnt; j++) { lod_comp = &lo->ldo_comp_entries[j]; - if (id != lod_comp->llc_id) + + /* lfs only put one flag in each entry */ + if ((flags && id != lod_comp->llc_id) || + (mirror_flag && mirror_id_of(id) != + mirror_id_of(lod_comp->llc_id))) continue; - if (flags & LCME_FL_NEG) { - flags &= ~LCME_FL_NEG; - lod_comp->llc_flags &= ~flags; + if (neg) { + if (flags) + lod_comp->llc_flags &= ~flags; + if (mirror_flag) + lod_comp->llc_flags &= ~mirror_flag; } else { - lod_comp->llc_flags |= flags; + if (flags) + lod_comp->llc_flags |= flags; + if (mirror_flag) { + lod_comp->llc_flags |= mirror_flag; + if (mirror_flag & LCME_FL_NOSYNC) + lod_comp->llc_timestamp = + ktime_get_real_seconds(); + } } changed = true; } diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c index cf578b54..d425460 100644 --- a/lustre/lod/lod_qos.c +++ b/lustre/lod/lod_qos.c @@ -1864,6 +1864,9 @@ int lod_use_defined_striping(const struct lu_env *env, lod_comp->llc_extent.e_end = le64_to_cpu(ext->e_end); lod_comp->llc_flags = le32_to_cpu(comp_v1->lcm_entries[i].lcme_flags); + if (lod_comp->llc_flags & LCME_FL_NOSYNC) + lod_comp->llc_timestamp = le64_to_cpu( + comp_v1->lcm_entries[i].lcme_timestamp); lod_comp->llc_id = le32_to_cpu(comp_v1->lcm_entries[i].lcme_id); if (lod_comp->llc_id == LCME_ID_INVAL) diff --git a/lustre/lov/lov_ea.c b/lustre/lov/lov_ea.c index 2ca7b99..92b00da 100644 --- a/lustre/lov/lov_ea.c +++ b/lustre/lov/lov_ea.c @@ -472,6 +472,9 @@ lsm_unpackmd_comp_md_v1(struct lov_obd *lov, void *buf, size_t buf_size) lsm->lsm_entries[i] = lsme; lsme->lsme_id = le32_to_cpu(lcme->lcme_id); lsme->lsme_flags = le32_to_cpu(lcme->lcme_flags); + if (lsme->lsme_flags & LCME_FL_NOSYNC) + lsme->lsme_timestamp = + le64_to_cpu(lcme->lcme_timestamp); lu_extent_le_to_cpu(&lsme->lsme_extent, &lcme->lcme_extent); if (i == entry_count - 1) { diff --git a/lustre/lov/lov_internal.h b/lustre/lov/lov_internal.h index 7e87fad..8454856 100644 --- a/lustre/lov/lov_internal.h +++ b/lustre/lov/lov_internal.h @@ -47,6 +47,7 @@ struct lov_stripe_md_entry { u32 lsme_magic; u32 lsme_flags; u32 lsme_pattern; + u64 lsme_timestamp; u32 lsme_stripe_size; u16 lsme_stripe_count; u16 lsme_layout_gen; diff --git a/lustre/lov/lov_pack.c b/lustre/lov/lov_pack.c index 1abf4b5..53929f6 100644 --- a/lustre/lov/lov_pack.c +++ b/lustre/lov/lov_pack.c @@ -222,6 +222,9 @@ ssize_t lov_lsm_pack(const struct lov_stripe_md *lsm, void *buf, lcme->lcme_id = cpu_to_le32(lsme->lsme_id); lcme->lcme_flags = cpu_to_le32(lsme->lsme_flags); + if (lsme->lsme_flags & LCME_FL_NOSYNC) + lcme->lcme_timestamp = + cpu_to_le64(lsme->lsme_timestamp); lcme->lcme_extent.e_start = cpu_to_le64(lsme->lsme_extent.e_start); lcme->lcme_extent.e_end = diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 216c086..20ae792 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -2220,6 +2220,9 @@ void lustre_print_user_md(unsigned int lvl, struct lov_user_md *lum, CDEBUG(lvl, "\tentry %d:\n", i); CDEBUG(lvl, "\tlcme_id: %#x\n", ent->lcme_id); CDEBUG(lvl, "\tlcme_flags: %#x\n", ent->lcme_flags); + if (ent->lcme_flags & LCME_FL_NOSYNC) + CDEBUG(lvl, "\tlcme_timestamp: %llu\n", + ent->lcme_timestamp); CDEBUG(lvl, "\tlcme_extent.e_start: %llu\n", ent->lcme_extent.e_start); CDEBUG(lvl, "\tlcme_extent.e_end: %llu\n", @@ -2308,13 +2311,13 @@ void lustre_swab_lov_comp_md_v1(struct lov_comp_md_v1 *lum) } __swab32s(&ent->lcme_id); __swab32s(&ent->lcme_flags); + __swab64s(&ent->lcme_timestamp); __swab64s(&ent->lcme_extent.e_start); __swab64s(&ent->lcme_extent.e_end); __swab32s(&ent->lcme_offset); __swab32s(&ent->lcme_size); __swab32s(&ent->lcme_layout_gen); CLASSERT(offsetof(typeof(*ent), lcme_padding_1) != 0); - CLASSERT(offsetof(typeof(*ent), lcme_padding_2) != 0); v1 = (struct lov_user_md_v1 *)((char *)lum + off); stripe_count = v1->lmm_stripe_count; diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index 1e5d97b..a7ca562 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -43,7 +43,6 @@ #include #include - void lustre_assert_wire_constants(void) { /* Wire protocol assertions generated by 'wirecheck' @@ -1728,14 +1727,14 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lov_comp_md_entry_v1, lcme_layout_gen)); LASSERTF((int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_layout_gen) == 4, "found %lld\n", (long long)(int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_layout_gen)); - LASSERTF((int)offsetof(struct lov_comp_md_entry_v1, lcme_padding_1) == 36, "found %lld\n", + LASSERTF((int)offsetof(struct lov_comp_md_entry_v1, lcme_timestamp) == 36, "found %lld\n", + (long long)(int)offsetof(struct lov_comp_md_entry_v1, lcme_timestamp)); + LASSERTF((int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_timestamp) == 8, "found %lld\n", + (long long)(int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_timestamp)); + LASSERTF((int)offsetof(struct lov_comp_md_entry_v1, lcme_padding_1) == 44, "found %lld\n", (long long)(int)offsetof(struct lov_comp_md_entry_v1, lcme_padding_1)); LASSERTF((int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding_1) == 4, "found %lld\n", (long long)(int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding_1)); - LASSERTF((int)offsetof(struct lov_comp_md_entry_v1, lcme_padding_2) == 40, "found %lld\n", - (long long)(int)offsetof(struct lov_comp_md_entry_v1, lcme_padding_2)); - LASSERTF((int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding_2) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding_2)); LASSERTF(LCME_FL_INIT == 0x00000010UL, "found 0x%.8xUL\n", (unsigned)LCME_FL_INIT); LASSERTF(LCME_FL_NEG == 0x80000000UL, "found 0x%.8xUL\n", @@ -1864,6 +1863,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct obd_statfs, os_bavail)); LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_bavail) == 8, "found %lld\n", (long long)(int)sizeof(((struct obd_statfs *)0)->os_bavail)); + LASSERTF((int)offsetof(struct obd_statfs, os_files) == 32, "found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_files)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_files) == 8, "found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_files)); LASSERTF((int)offsetof(struct obd_statfs, os_ffree) == 40, "found %lld\n", (long long)(int)offsetof(struct obd_statfs, os_ffree)); LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_ffree) == 8, "found %lld\n", @@ -1880,6 +1883,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct obd_statfs, os_namelen)); LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_namelen) == 4, "found %lld\n", (long long)(int)sizeof(((struct obd_statfs *)0)->os_namelen)); + LASSERTF((int)offsetof(struct obd_statfs, os_maxbytes) == 96, "found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_maxbytes)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_maxbytes) == 8, "found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_maxbytes)); LASSERTF((int)offsetof(struct obd_statfs, os_state) == 104, "found %lld\n", (long long)(int)offsetof(struct obd_statfs, os_state)); LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_state) == 4, "found %lld\n", @@ -5459,4 +5466,3 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct llog_update_record *)0)->lur_update_rec) == 32, "found %lld\n", (long long)(int)sizeof(((struct llog_update_record *)0)->lur_update_rec)); } - diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index 6b748a0..a763206 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -143,10 +143,23 @@ verify_comp_attr() { local fl local expected_list=$(comma_list $expected) for fl in ${expected_list//,/ }; do - echo $value | grep -q $fl || { + local neg=0 + + [[ ${fl:0:1} = "^" ]] && neg=1 + [[ $neg = 1 ]] && fl=${fl:1} + + $(echo $value | grep -q $fl) + local match=$? + # 0: matched; 1: not matched + + if [[ $neg = 0 && $match != 0 || + $neg = 1 && $match = 0 ]]; then $getstripe_cmd $tf - error "expected flag $fl existing on $comp_id" - } + [[ $neg = 0 ]] && # expect the flag + error "expected flag '$fl' not in $comp_id" + [[ $neg = 1 ]] && # not expect the flag + error "not expected flag '$fl' in $comp_id" + fi done return } @@ -1946,6 +1959,67 @@ test_47() { } run_test 47 "Verify mirror obj alloc" +test_48() { + local tf=$DIR/$tfile + + rm -f $tf + echo " ** create 2 mirrors FLR file $tf" + $LFS mirror create -N -E2M -Eeof --flags prefer \ + -N -E1M -Eeof $tf || + error "create FLR file $tf failed" + + echo " ** write it" + dd if=/dev/urandom of=$tf bs=1M count=3 || error "write $tf failed" + verify_flr_state $tf "wp" + + local sum0=$(md5sum < $tf) + + echo " ** resync the file" + $LFS mirror resync $tf + + echo " ** snapshot mirror 2" + $LFS setstripe --comp-set -I 0x20003 --comp-flags=nosync $tf + + echo " ** write it again" + dd if=/dev/urandom of=$tf bs=1M count=3 || error "write $tf failed" + echo " ** resync it again" + $LFS mirror resync $tf + + verify_flr_state $tf "wp" + verify_comp_attr lcme_flags $tf 0x20003 nosync,stale + + local sum1=$($LFS mirror dump -N1 $tf | md5sum) + local sum2=$($LFS mirror dump -N2 $tf | md5sum) + + echo " ** verify mirror 2 doesn't change" + echo "original checksum: $sum0" + echo "mirror 1 checksum: $sum1" + echo "mirror 2 checksum: $sum2" + [[ $sum0 = $sum2 ]] || + error "original checksum: $sum0, mirror 2 checksum: $sum2" + echo " ** mirror 2 stripe info" + $LFS getstripe -v --mirror-index=2 $tf + + echo " ** resync mirror 2" + $LFS mirror resync --only 2 $tf + + verify_flr_state $tf "ro" + verify_comp_attr lcme_flags $tf 0x20003 nosync,^stale + + sum1=$($LFS mirror dump -N1 $tf | md5sum) + sum2=$($LFS mirror dump -N2 $tf | md5sum) + + echo " ** verify mirror 2 resync-ed" + echo "original checksum: $sum0" + echo "mirror 1 checksum: $sum1" + echo "mirror 2 checksum: $sum2" + [[ $sum1 = $sum2 ]] || + error "mirror 1 checksum: $sum1, mirror 2 checksum: $sum2" + echo " ** mirror 2 stripe info" + $LFS getstripe -v --mirror-index=2 $tf +} +run_test 48 "Verify snapshot mirror" + ctrl_file=$(mktemp /tmp/CTRL.XXXXXX) lock_file=$(mktemp /var/lock/FLR.XXXXXX) diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 77ab9e7..c17c68a 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -68,6 +68,7 @@ #include #endif #include +#include #include #include @@ -3002,6 +3003,26 @@ static void lov_dump_comp_v1_entry(struct find_param *param, lcme_flags2str(entry->lcme_flags); separator = "\n"; } + /* print snapshot timestamp if its a nosync comp */ + if ((verbose & VERBOSE_COMP_FLAGS) && + (entry->lcme_flags & LCME_FL_NOSYNC)) { + llapi_printf(LLAPI_MSG_NORMAL, "%s", separator); + if (verbose & ~VERBOSE_COMP_FLAGS) + llapi_printf(LLAPI_MSG_NORMAL, + "%4slcme_timestamp: ", " "); + if (yaml) { + llapi_printf(LLAPI_MSG_NORMAL, "%llu", + entry->lcme_timestamp); + } else { + time_t stamp = entry->lcme_timestamp; + char *date_str = asctime(localtime(&stamp)); + + date_str[strlen(date_str) - 1] = '\0'; + llapi_printf(LLAPI_MSG_NORMAL, "'%s'", date_str); + } + + separator = "\n"; + } if (verbose & VERBOSE_COMP_START) { llapi_printf(LLAPI_MSG_NORMAL, "%s", separator); diff --git a/lustre/utils/liblustreapi_layout.c b/lustre/utils/liblustreapi_layout.c index a0905d7..f8b3ea6 100644 --- a/lustre/utils/liblustreapi_layout.c +++ b/lustre/utils/liblustreapi_layout.c @@ -60,6 +60,7 @@ struct llapi_layout_comp { struct lu_extent llc_extent; /* [start, end) of component */ uint32_t llc_id; /* unique ID of component */ uint32_t llc_flags; /* LCME_FL_* flags */ + uint64_t llc_timestamp; /* snapshot timestamp */ struct list_head llc_list; /* linked to the llapi_layout components list */ }; @@ -148,6 +149,7 @@ llapi_layout_swab_lov_user_md(struct lov_user_md *lum, int lum_size) ent = &comp_v1->lcm_entries[i]; __swab32s(&ent->lcme_id); __swab32s(&ent->lcme_flags); + __swab64s(&ent->lcme_timestamp); __swab64s(&ent->lcme_extent.e_start); __swab64s(&ent->lcme_extent.e_end); __swab32s(&ent->lcme_offset); @@ -418,6 +420,8 @@ llapi_layout_from_lum(const struct lov_user_md *lum, int lum_size) comp->llc_extent.e_end = ent->lcme_extent.e_end; comp->llc_id = ent->lcme_id; comp->llc_flags = ent->lcme_flags; + if (comp->llc_flags & LCME_FL_NOSYNC) + comp->llc_timestamp = ent->lcme_timestamp; } else { comp->llc_extent.e_start = 0; comp->llc_extent.e_end = LUSTRE_EOF; @@ -622,6 +626,8 @@ llapi_layout_to_lum(const struct llapi_layout *layout) ent = &comp_v1->lcm_entries[ent_idx]; ent->lcme_id = comp->llc_id; ent->lcme_flags = comp->llc_flags; + if (ent->lcme_flags & LCME_FL_NOSYNC) + ent->lcme_timestamp = comp->llc_timestamp; ent->lcme_extent.e_start = comp->llc_extent.e_start; ent->lcme_extent.e_end = comp->llc_extent.e_end; ent->lcme_size = blob_size; @@ -2457,6 +2463,10 @@ int llapi_mirror_find_stale(struct llapi_layout *layout, /* not in the specified mirror */ if (j == ids_nr) goto next; + } else if (flags & LCME_FL_NOSYNC) { + /* if not specified mirrors, do not resync "nosync" + * mirrors */ + goto next; } rc = llapi_layout_comp_id_get(layout, &id); diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index 816f7eb..3ae1c4d 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -240,7 +240,7 @@ check_som_attrs(void) BLANK_LINE(); CHECK_STRUCT(lustre_som_attrs); CHECK_MEMBER(lustre_som_attrs, lsa_valid); - CHECK_MEMBER(lustre_som_attrs, lsa_reserved; + CHECK_MEMBER(lustre_som_attrs, lsa_reserved); CHECK_MEMBER(lustre_som_attrs, lsa_size); CHECK_MEMBER(lustre_som_attrs, lsa_blocks); } @@ -792,8 +792,8 @@ check_lov_comp_md_entry_v1(void) CHECK_MEMBER(lov_comp_md_entry_v1, lcme_offset); CHECK_MEMBER(lov_comp_md_entry_v1, lcme_size); CHECK_MEMBER(lov_comp_md_entry_v1, lcme_layout_gen); + CHECK_MEMBER(lov_comp_md_entry_v1, lcme_timestamp); CHECK_MEMBER(lov_comp_md_entry_v1, lcme_padding_1); - CHECK_MEMBER(lov_comp_md_entry_v1, lcme_padding_2); CHECK_VALUE_X(LCME_FL_INIT); CHECK_VALUE_X(LCME_FL_NEG); @@ -857,13 +857,15 @@ check_obd_statfs(void) CHECK_MEMBER(obd_statfs, os_blocks); CHECK_MEMBER(obd_statfs, os_bfree); CHECK_MEMBER(obd_statfs, os_bavail); + CHECK_MEMBER(obd_statfs, os_files); CHECK_MEMBER(obd_statfs, os_ffree); CHECK_MEMBER(obd_statfs, os_fsid); CHECK_MEMBER(obd_statfs, os_bsize); CHECK_MEMBER(obd_statfs, os_namelen); + CHECK_MEMBER(obd_statfs, os_maxbytes); CHECK_MEMBER(obd_statfs, os_state); CHECK_MEMBER(obd_statfs, os_fprecreated); - CHECK_MEMBER(obd_statfs, os_spare2); + CHECK_MEMBER(obd_statfs, os_granted); CHECK_MEMBER(obd_statfs, os_spare3); CHECK_MEMBER(obd_statfs, os_spare4); CHECK_MEMBER(obd_statfs, os_spare5); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 21f8754..0f574e9 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -278,7 +278,7 @@ void lustre_assert_wire_constants(void) LASSERTF(MDS_ATTR_LSIZE == 0x0000000000020000ULL, "found 0x%.16llxULL\n", (long long)MDS_ATTR_LSIZE); LASSERTF(MDS_ATTR_LBLOCKS == 0x0000000000040000ULL, "found 0x%.16llxULL\n", - (long long)MDS_ATTR_BLOCKS); + (long long)MDS_ATTR_LBLOCKS); LASSERTF(FLD_QUERY == 900, "found %lld\n", (long long)FLD_QUERY); LASSERTF(FLD_READ == 901, "found %lld\n", @@ -1749,14 +1749,14 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lov_comp_md_entry_v1, lcme_layout_gen)); LASSERTF((int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_layout_gen) == 4, "found %lld\n", (long long)(int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_layout_gen)); - LASSERTF((int)offsetof(struct lov_comp_md_entry_v1, lcme_padding_1) == 36, "found %lld\n", + LASSERTF((int)offsetof(struct lov_comp_md_entry_v1, lcme_timestamp) == 36, "found %lld\n", + (long long)(int)offsetof(struct lov_comp_md_entry_v1, lcme_timestamp)); + LASSERTF((int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_timestamp) == 8, "found %lld\n", + (long long)(int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_timestamp)); + LASSERTF((int)offsetof(struct lov_comp_md_entry_v1, lcme_padding_1) == 44, "found %lld\n", (long long)(int)offsetof(struct lov_comp_md_entry_v1, lcme_padding_1)); LASSERTF((int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding_1) == 4, "found %lld\n", (long long)(int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding_1)); - LASSERTF((int)offsetof(struct lov_comp_md_entry_v1, lcme_padding_2) == 40, "found %lld\n", - (long long)(int)offsetof(struct lov_comp_md_entry_v1, lcme_padding_2)); - LASSERTF((int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding_2) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lov_comp_md_entry_v1 *)0)->lcme_padding_2)); LASSERTF(LCME_FL_INIT == 0x00000010UL, "found 0x%.8xUL\n", (unsigned)LCME_FL_INIT); LASSERTF(LCME_FL_NEG == 0x80000000UL, "found 0x%.8xUL\n", @@ -1885,6 +1885,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct obd_statfs, os_bavail)); LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_bavail) == 8, "found %lld\n", (long long)(int)sizeof(((struct obd_statfs *)0)->os_bavail)); + LASSERTF((int)offsetof(struct obd_statfs, os_files) == 32, "found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_files)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_files) == 8, "found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_files)); LASSERTF((int)offsetof(struct obd_statfs, os_ffree) == 40, "found %lld\n", (long long)(int)offsetof(struct obd_statfs, os_ffree)); LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_ffree) == 8, "found %lld\n", @@ -1901,6 +1905,10 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct obd_statfs, os_namelen)); LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_namelen) == 4, "found %lld\n", (long long)(int)sizeof(((struct obd_statfs *)0)->os_namelen)); + LASSERTF((int)offsetof(struct obd_statfs, os_maxbytes) == 96, "found %lld\n", + (long long)(int)offsetof(struct obd_statfs, os_maxbytes)); + LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_maxbytes) == 8, "found %lld\n", + (long long)(int)sizeof(((struct obd_statfs *)0)->os_maxbytes)); LASSERTF((int)offsetof(struct obd_statfs, os_state) == 104, "found %lld\n", (long long)(int)offsetof(struct obd_statfs, os_state)); LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_state) == 4, "found %lld\n", @@ -5480,4 +5488,3 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct llog_update_record *)0)->lur_update_rec) == 32, "found %lld\n", (long long)(int)sizeof(((struct llog_update_record *)0)->lur_update_rec)); } -