Whamcloud - gitweb
LU-10830 utils: fix create mode for lfs setstripe 47/31747/4
authorAndreas Dilger <andreas.dilger@intel.com>
Fri, 23 Mar 2018 06:01:58 +0000 (00:01 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 9 Apr 2018 19:44:57 +0000 (19:44 +0000)
Fix create mode for files created by "lfs setstripe" and also
"lfs mirror create" to match regular file creates, which are
filtered by umask to determine the final file create mode.

Add test case to verify umask is working correctly in all cases.

Test-Parameters: trivial
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: I0c9d6730f437dbfbafda4902a035cc0f0ed916b0
Reviewed-on: https://review.whamcloud.com/31747
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Emoly Liu <emoly.liu@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/sanity.sh
lustre/utils/lfs.c
lustre/utils/liblustreapi_layout.c

index 567d2cb..79ba19c 100755 (executable)
@@ -8270,7 +8270,37 @@ test_103a() {
                fi
        done
 }
                fi
        done
 }
-run_test 103a "acl test ========================================="
+run_test 103a "acl test"
+
+test_103b() {
+       local U
+
+       for U in {0..511}; do
+               {
+               local O=$(printf "%04o" $U)
+
+               umask $(printf "%04o" $((511 ^ $O)))
+               $LFS setstripe -c 1 $DIR/$tfile.s$O
+               local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
+
+               (( $S == ($O & 0666) )) ||
+                       error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
+
+               $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
+               S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
+               (( $S == ($O & 0666) )) ||
+                       error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
+
+               $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
+               S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
+               (( $S == ($O & 0666) )) ||
+                       error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
+               rm -f $DIR/$tfile.[smp]$0
+               } &
+       done
+       wait
+}
+run_test 103b "umask lfs setstripe"
 
 test_103c() {
        mkdir -p $DIR/$tdir
 
 test_103c() {
        mkdir -p $DIR/$tdir
index 79ed30f..bddec09 100644 (file)
@@ -1403,7 +1403,7 @@ static int mirror_create(char *fname, struct mirror_args *mirror_list)
                goto error;
        }
 
                goto error;
        }
 
-       rc = lfs_component_create(fname, O_CREAT | O_WRONLY, 0644,
+       rc = lfs_component_create(fname, O_CREAT | O_WRONLY, 0666,
                                  layout);
        if (rc >= 0) {
                close(rc);
                                  layout);
        if (rc >= 0) {
                close(rc);
@@ -3189,7 +3189,7 @@ static int lfs_setstripe_internal(int argc, char **argv,
                                              NULL);
                } else if (layout != NULL) {
                        result = lfs_component_create(fname, O_CREAT | O_WRONLY,
                                              NULL);
                } else if (layout != NULL) {
                        result = lfs_component_create(fname, O_CREAT | O_WRONLY,
-                                                     0644, layout);
+                                                     0666, layout);
                        if (result >= 0) {
                                close(result);
                                result = 0;
                        if (result >= 0) {
                                close(result);
                                result = 0;
@@ -3197,7 +3197,7 @@ static int lfs_setstripe_internal(int argc, char **argv,
                } else {
                        result = llapi_file_open_param(fname,
                                                       O_CREAT | O_WRONLY,
                } else {
                        result = llapi_file_open_param(fname,
                                                       O_CREAT | O_WRONLY,
-                                                      0644, param);
+                                                      0666, param);
                        if (result >= 0) {
                                close(result);
                                result = 0;
                        if (result >= 0) {
                                close(result);
                                result = 0;
index d179a09..e85b39d 100644 (file)
@@ -1431,7 +1431,7 @@ int llapi_layout_pool_name_set(struct llapi_layout *layout,
  *
  * \param[in] path             name of the file to open
  * \param[in] open_flags       open() flags
  *
  * \param[in] path             name of the file to open
  * \param[in] open_flags       open() flags
- * \param[in] mode             permissions to create new file with
+ * \param[in] mode             permissions to create file, filtered by umask
  * \param[in] layout           layout to create new file with
  *
  * \retval             non-negative file descriptor on successful open
  * \param[in] layout           layout to create new file with
  *
  * \retval             non-negative file descriptor on successful open