struct llog_handle *llh,
struct llog_rec_hdr *hdr, void *data)
{
- struct mdd_device *mdd = ((struct changelog_orphan_data *)data)->mdd;
+ struct changelog_orphan_data *user_orphan = data;
+ struct mdd_device *mdd = user_orphan->mdd;
struct llog_changelog_user_rec *rec = container_of(hdr,
struct llog_changelog_user_rec,
cur_hdr);
rec->cur_hdr.lrh_index, rec->cur_id, rec->cur_endrec,
PFID(&llh->lgh_id.lgl_oi.oi_fid));
- if (((struct changelog_orphan_data *)data)->index == 0 ||
- rec->cur_endrec < ((struct changelog_orphan_data *)data)->index)
- ((struct changelog_orphan_data *)data)->index = rec->cur_endrec;
+ user_orphan->index = min_t(__u64, user_orphan->index, rec->cur_endrec);
return 0;
}
{
struct obd_device *obd = mdd2obd_dev(mdd);
struct llog_ctxt *ctxt = NULL, *uctxt = NULL;
- struct changelog_orphan_data changelog_orphan = { .index = 0,
- .mdd = mdd },
- user_orphan = { .index = 0,
- .mdd = mdd };
- int rc;
+ struct changelog_orphan_data changelog_orphan = {
+ .mdd = mdd,
+ .index = -1,
+ }, user_orphan = {
+ .mdd = mdd,
+ .index = -1,
+ };
+ int rc;
ENTRY;
}
run_test 160n "Changelog destroy race"
+test_160p() {
+ remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ [[ $MDS1_VERSION -ge $(version_code 2.14.51) ]] ||
+ skip "Need MDS version at least 2.14.51"
+ [[ "$mds1_FSTYPE" == "ldiskfs" ]] || skip "ldiskfs only test"
+ local cl_users
+ local cl_user1
+ local entry_count
+
+ # Create a user
+ changelog_register || error "first changelog_register failed"
+
+ cl_users=(${CL_USERS[mds1]})
+ cl_user1="${cl_users[0]}"
+
+ test_mkdir -p -i0 -c1 $DIR/$tdir || error "test_mkdir $tdir failed"
+ createmany -m $DIR/$tdir/$tfile 50 ||
+ error "create $DIR/$tdir/$tfile failed"
+ unlinkmany $DIR/$tdir/$tfile 50 || error "unlinkmany failed"
+ rm -rf $DIR/$tdir
+
+ # check changelogs have been generated
+ entry_count=$(changelog_dump | wc -l)
+ ((entry_count != 0)) || error "no changelog entries found"
+
+ # remove changelog_users and check that orphan entries are removed
+ stop mds1
+ do_facet mds1 "$DEBUGFS -w -R 'rm changelog_users' $(mdsdevname 1)"
+ start mds1 || error "cannot start mdt"
+ entry_count=$(changelog_dump | wc -l)
+ ((entry_count == 0)) ||
+ error "found $entry_count changelog entries, expected none"
+}
+run_test 160p "Changelog orphan cleanup with no users"
+
test_161a() {
[ $PARALLEL == "yes" ] && skip "skip parallel run"
# so reorder to get same order than in changelog_register()
local cl_facets=$(echo "${!CL_USERS[@]}" | tr " " "\n" | sort |
tr "\n" " ")
+ local cl_user
for facet in $cl_facets; do
for cl_user in ${CL_USERS[$facet]}; do