Whamcloud - gitweb
LU-5878 lfs: migrate file to its proper destination 01/12601/6
authorFrank Zago <fzago@cray.com>
Thu, 6 Nov 2014 17:08:30 +0000 (11:08 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 4 Dec 2014 02:28:36 +0000 (02:28 +0000)
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 <fzago@cray.com>
Reviewed-on: http://review.whamcloud.com/12601
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Henri Doreau <henri.doreau@cea.fr>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/tests/sanity.sh
lustre/utils/liblustreapi.c

index e5f2143..1918c3a 100644 (file)
@@ -4830,6 +4830,29 @@ test_56w() {
 
     check_stripe_count $TDIR/file1 $expected
 
 
     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"
     # lfs_migrate dir
     cmd="$LFS_MIGRATE -y -c $expected $TDIR/dir1"
     echo "$cmd"
index c211a6e..e8c92a2 100644 (file)
@@ -664,13 +664,13 @@ int llapi_search_ost(char *fsname, char *poolname, char *ostname)
 /**
  * Open a Lustre file.
  *
 /**
  * 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)
  */
 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);
 
                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);
                                  "error on ioctl "LPX64" for '%s' (%d): %s",
                                  (__u64)LL_IOC_LOV_SETSTRIPE, name, fd,
                                  errmsg);
-       }
 
 
-       if (rc) {
                close(fd);
                fd = rc;
        }
                close(fd);
                fd = rc;
        }
-       if (lum != NULL)
-               free(lum);
+
+       free(lum);
+
        return fd;
 }
 
        return fd;
 }