From dd79052617be1002b0dcd6e36d74f8124c403177 Mon Sep 17 00:00:00 2001 From: Alexander Zarochentsev Date: Sun, 8 Jul 2018 00:21:36 +0300 Subject: [PATCH] LU-11130 osd-ldiskfs: create non-empty local agent symlinks e2fsck doesn't like zero-sized symlink inodes created by osd_create_local_agent_inode(). Store the FID of the remote inode as the symlink target so that it is possible to debug where this symlink comes from in case there is some problem in the future. It would be better to just migrate the whole symlink instead of creating a remote symlink, in the very common case where there is not a hard link to the symlink (which POSIX allows, but is extremely uncommon). For the short term, we store keep the remote symlinks to ensure on-disk consistency with this simple patch, until the migration code can be fixed. Lustre-change: https://review.whamcloud.com/32797 Lustre-commit: c3a836364892cacbc4737645893b094971c6ec49 Cray-bug-id: LUS-6189 Change-Id: Ida43616c51b6903f0a51aeec05a9a2dd189efe31 Signed-off-by: Alexander Zarochentsev Signed-off-by: Andreas Dilger Reviewed-by: Lai Siyao Reviewed-on: https://review.whamcloud.com/33973 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/osd-ldiskfs/osd_handler.c | 13 +++++++++++++ lustre/tests/conf-sanity.sh | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 1b13df9..d69dcc1 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -3490,6 +3490,19 @@ static struct inode *osd_create_local_agent_inode(const struct lu_env *env, * correct gid on remote file, not agent here */ local->i_gid = current_fsgid(); ldiskfs_set_inode_state(local, LDISKFS_STATE_LUSTRE_NOSCRUB); + + /* e2fsck doesn't like empty symlinks. Store remote FID as symlink. + * That gives e2fsck something to look at and be happy, and allows + * debugging if we need to determine where this symlink came from. + */ + if (S_ISLNK(type)) { + CLASSERT(LDISKFS_N_BLOCKS * 4 >= FID_LEN + 1); + rc = snprintf((char *)LDISKFS_I(local)->i_data, + LDISKFS_N_BLOCKS * 4, DFID, PFID(fid)); + + i_size_write(local, rc); + LDISKFS_I(local)->i_disksize = rc; + } unlock_new_inode(local); /* Agent inode should not have project ID */ diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 97e6ab1..c417da7 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -7758,6 +7758,31 @@ test_109b() } run_test 109b "test lctl clear_conf one config" +test_120() { # LU-11130 + [ "$MDSCOUNT" -lt 2 ] && skip "mdt count < 2" + [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] && + skip "ldiskfs only test" + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] && + skip "Need DNE2 capable MD target with LU-11130 fix" + + setup + + local mds1host=$(facet_active_host mds1) + local mds1dev=$(mdsdevname 1) + + $LFS mkdir -i 1 $DIR/$tdir + $LFS mkdir -i 0 $DIR/$tdir/mds1dir + + ln -s foo $DIR/$tdir/bar + mv $DIR/$tdir/bar $DIR/$tdir/mds1dir/bar2 || + error "cross-target rename failed" + + stopall + + run_e2fsck $mds1host $mds1dev "-n" +} +run_test 120 "cross-target rename should not create bad symlinks" + test_122() { [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return [[ $(lustre_version_code ost1) -ge $(version_code 2.10.6) ]] || -- 1.8.3.1