Whamcloud - gitweb
LU-9771 flr: make sure init size work 81/29581/17
authorJinshan Xiong <jinshan.xiong@intel.com>
Sat, 14 Oct 2017 19:59:06 +0000 (12:59 -0700)
committerJinshan Xiong <jinshan.xiong@intel.com>
Sun, 26 Nov 2017 00:24:31 +0000 (00:24 +0000)
Lustre allows to create a file with empty layout, and truncate it
up with non-zero file size. The size should be applied later after
a layout is attached.

Test-Parameters: testlist=sanity-flr

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Change-Id: Ie645f8172e98426a531eb2d9ffdcbec8f73f3731
Reviewed-on: https://review.whamcloud.com/29581
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/tests/sanity-flr.sh
lustre/utils/lfs.c

index 56eb391..146270c 100644 (file)
@@ -226,8 +226,6 @@ test_0a() {
        verify_comp_attrs_with_parent $tf $id
        verify_comp_extent $tf $id 0 EOF
 
-       $mirror_cmd -N $tf &> /dev/null &&
-               error "mirrored file $tf already exists"
        $mirror_cmd -N0 $tf-1 &> /dev/null && error "invalid mirror count 0"
        $mirror_cmd -N$((mirror_count + 1)) $tf-1 &> /dev/null &&
                error "invalid mirror count $((mirror_count + 1))"
@@ -649,6 +647,22 @@ test_4() {
 }
 run_test 4 "Make sure mirror attributes can be inhertied from directory"
 
+test_5() {
+       local tf=$DIR/$tfile
+       local ids=()
+
+       $MULTIOP $tf oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T12345c ||
+               error "failed to create file with non-empty layout"
+       $CHECKSTAT -t file -s 12345 $tf || error "size error: expecting 12345"
+
+       $LFS mirror create -N3 $tf || error "failed to attach mirror layout"
+       verify_mirror_count $tf 3
+
+       $CHECKSTAT -t file -s 12345 $tf ||
+               error "size error after attaching layout "
+}
+run_test 5 "Make sure init size work for mirrored layout"
+
 test_21() {
        local tf=$DIR/$tfile
        local tf2=$DIR/$tfile-2
index c6f0f94..3cce36e 100644 (file)
@@ -1134,7 +1134,7 @@ static int mirror_create(char *fname, struct mirror_args *mirror_list)
                goto error;
        }
 
-       rc = lfs_component_create(fname, O_CREAT | O_WRONLY | O_EXCL, 0644,
+       rc = lfs_component_create(fname, O_CREAT | O_WRONLY, 0644,
                                  layout);
        if (rc >= 0) {
                close(rc);