From: Frank Zago Date: Thu, 6 Nov 2014 17:08:30 +0000 (-0600) Subject: LU-5878 lfs: migrate file to its proper destination X-Git-Tag: 2.6.91~35 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=01bc529ccffdb21d33ab6a36ed64fe96ef9ac55b;p=fs%2Flustre-release.git LU-5878 lfs: migrate file to its proper destination llapi_file_open_param() is supposed to be returning the opened file descriptor. However, when llapi_search_ost() is called, it returns 1, which sets rc to 1, which in turn is confused for an error later, and returned to the caller. So when the copy happen, the destination file descriptor is 1 (stdout). Fixed a typo in the function description, and format the parameters descriptions. Fixed a bad indentation. There's no need to test lum before freeing it since at that point is not NULL (and free will test it anyway). Change-Id: I16fe26480b880aa818b1bb706b22bfdd6833d69c Signed-off-by: frank zago Reviewed-on: http://review.whamcloud.com/12601 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Henri Doreau Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond --- diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index e5f2143..1918c3a 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -4830,6 +4830,29 @@ test_56w() { check_stripe_count $TDIR/file1 $expected + if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.90) ]; + then + # lfs_migrate file onto OST 0 if it is on OST 1, or onto + # OST 1 if it is on OST 0. This file is small enough to + # be on only one stripe. + file=$TDIR/migr_1_ost + dd bs=$dd_bs count=1 if=/dev/urandom of=$file >/dev/null 2>&1 || + error "write data into $file failed" + local obdidx=$($LFS getstripe -i $file) + local oldmd5=$(md5sum $file) + local newobdidx=0 + [[ $obdidx -eq 0 ]] && newobdidx=1 + cmd="$LFS migrate -i $newobdidx $file" + echo $cmd + eval $cmd || error "$cmd failed" + local realobdix=$($LFS getstripe -i $file) + local newmd5=$(md5sum $file) + [[ $newobdidx -ne $realobdix ]] && + error "new OST is different (was=$obdidx, wanted=$newobdidx, got=$realobdix)" + [[ "$oldmd5" != "$newmd5" ]] && + error "md5sum differ: $oldmd5, $newmd5" + fi + # lfs_migrate dir cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1" echo "$cmd" diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index c211a6e..e8c92a2 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -664,13 +664,13 @@ int llapi_search_ost(char *fsname, char *poolname, char *ostname) /** * Open a Lustre file. * - * \param name the name of the file to be opened - * \param flags access mode, see flags in open(2) - * \param mode permisson of the file if it is created, see mode in open(2) - * \param param stripe pattern of the newly created file + * \param name the name of the file to be opened + * \param flags access mode, see flags in open(2) + * \param mode permission of the file if it is created, see mode in open(2) + * \param param stripe pattern of the newly created file * - * \return file descriptor of opened file - * \return -error failure + * \retval file descriptor of opened file + * \retval negative errno on failure */ int llapi_file_open_param(const char *name, int flags, mode_t mode, const struct llapi_stripe_param *param) @@ -821,18 +821,17 @@ retry_open: if (errno != EEXIST && errno != EALREADY) errmsg = strerror(errno); - llapi_err_noerrno(LLAPI_MSG_ERROR, + llapi_err_noerrno(LLAPI_MSG_ERROR, "error on ioctl "LPX64" for '%s' (%d): %s", (__u64)LL_IOC_LOV_SETSTRIPE, name, fd, errmsg); - } - if (rc) { close(fd); fd = rc; } - if (lum != NULL) - free(lum); + + free(lum); + return fd; }