Whamcloud - gitweb
LU-6589 llapi: ..._layout_pattern_set() rejects valid patterns 84/14784/4
authorNed Bass <bass6@llnl.gov>
Tue, 12 May 2015 18:07:59 +0000 (11:07 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 22 Sep 2015 23:23:25 +0000 (23:23 +0000)
A typo in the input validation code causes llapi_layout_pattern_set()
to reject valid pattern values. Correct the typo and add related test
coverage in llapi_layout_test.c.

Signed-off-by: Ned Bass <bass6@llnl.gov>
Change-Id: I676a98b63d61fca114eacd882a19abce6f2cc857
Reviewed-on: http://review.whamcloud.com/14784
Reviewed-by: frank zago <fzago@cray.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/llapi_layout_test.c
lustre/utils/liblustreapi_layout.c

index 53b20b7..60d3ab8 100644 (file)
@@ -173,7 +173,6 @@ void test1(void)
        llapi_layout_free(layout);
 }
 
-
 #define T2_DESC                "Read test0 file by FD and verify attributes"
 void test2(void)
 {
@@ -219,7 +218,6 @@ void test3(void)
        llapi_layout_free(layout);
 }
 
-
 #define T4FILE                 "t4"
 #define T4_STRIPE_COUNT                2
 #define T4_STRIPE_SIZE         2097152
@@ -302,7 +300,6 @@ void test6(void)
        ASSERTF(layout == NULL && errno == EBADF, "errno = %d", errno);
 }
 
-
 #define T7FILE         "t7"
 #define T7_DESC                "llapi_layout_get_by_path EACCES handling"
 void test7(void)
@@ -345,7 +342,6 @@ void test7(void)
        ASSERTF(rc == 0, "errno = %d", errno);
 }
 
-
 /* llapi_layout_get_by_path() returns default layout for file with no
  * striping attributes. */
 #define T8FILE         "t8"
@@ -388,8 +384,8 @@ void test8(void)
        llapi_layout_free(layout);
 }
 
-/* Setting pattern > 0 returns EOPNOTSUPP in errno. */
-#define T9_DESC                "llapi_layout_pattern_set() EOPNOTSUPP handling"
+/* Verify llapi_layout_patter_set() return values for various inputs. */
+#define T9_DESC                "verify llapi_layout_pattern_set() return values"
 void test9(void)
 {
        struct llapi_layout *layout;
@@ -397,14 +393,28 @@ void test9(void)
 
        layout = llapi_layout_alloc();
        ASSERTF(layout != NULL, "errno = %d\n", errno);
+
        errno = 0;
-       rc = llapi_layout_pattern_set(layout, 1);
+       rc = llapi_layout_pattern_set(layout, LLAPI_LAYOUT_INVALID);
        ASSERTF(rc == -1 && errno == EOPNOTSUPP, "rc = %d, errno = %d", rc,
                errno);
+
+       errno = 0;
+       rc = llapi_layout_pattern_set(NULL, LLAPI_LAYOUT_DEFAULT);
+       ASSERTF(rc == -1 && errno == EINVAL, "rc = %d, errno = %d", rc,
+               errno);
+
+       errno = 0;
+       rc = llapi_layout_pattern_set(layout, LLAPI_LAYOUT_DEFAULT);
+       ASSERTF(rc == 0, "rc = %d, errno = %d", rc, errno);
+
+       errno = 0;
+       rc = llapi_layout_pattern_set(layout, LLAPI_LAYOUT_RAID0);
+       ASSERTF(rc == 0, "rc = %d, errno = %d", rc, errno);
+
        llapi_layout_free(layout);
 }
 
-
 /* Verify stripe_count interfaces return errors as expected */
 #define T10_DESC       "stripe_count error handling"
 void test10(void)
index 937d5cc..4cd584e 100644 (file)
@@ -786,7 +786,7 @@ int llapi_layout_pattern_set(struct llapi_layout *layout, uint64_t pattern)
                return -1;
        }
 
-       if (pattern != LLAPI_LAYOUT_DEFAULT ||
+       if (pattern != LLAPI_LAYOUT_DEFAULT &&
            pattern != LLAPI_LAYOUT_RAID0) {
                errno = EOPNOTSUPP;
                return -1;