[PATCH 3/5] staging: lustre: acl: increase ACL entries limitation

2018-05-14 Thread James Simmons
From: Fan Yong 

Originally, the limitation of ACL entries is 32, that is not
enough for some use cases. In fact, restricting ACL entries
count is mainly for preparing the RPC reply buffer to receive
the ACL data. So we cannot make the ACL entries count to be
unlimited. But we can enlarge the RPC reply buffer to hold
more ACL entries. On the other hand, MDT backend filesystem
has its own EA size limitation. For example, for ldiskfs case,
if large EA enable, then the max ACL size is 1048492 bytes;
otherwise, it is 4012 bytes. For ZFS backend, such value is
32768 bytes. With such hard limitation, we can calculate how
many ACL entries we can have at most. This patch increases
the RPC reply buffer to match such hard limitation. For old
client, to avoid buffer overflow because of large ACL data
(more than 32 ACL entries), the MDT will forbid the old client
to access the file with large ACL data. As for how to know
whether it is old client or new, a new connection flag
OBD_CONNECT_LARGE_ACL is used for that.

Signed-off-by: Fan Yong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7473
Reviewed-on: https://review.whamcloud.com/19790
Reviewed-by: Andreas Dilger 
Reviewed-by: Li Xi 
Reviewed-by: Lai Siyao 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h | 2 +-
 drivers/staging/lustre/lustre/include/lustre_acl.h| 7 ++-
 drivers/staging/lustre/lustre/llite/llite_lib.c   | 3 ++-
 drivers/staging/lustre/lustre/mdc/mdc_locks.c | 6 ++
 drivers/staging/lustre/lustre/mdc/mdc_reint.c | 2 ++
 drivers/staging/lustre/lustre/mdc/mdc_request.c   | 4 
 drivers/staging/lustre/lustre/ptlrpc/layout.c | 4 +---
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c   | 4 ++--
 8 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h 
b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
index aac98db..8778c6f 100644
--- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
+++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
@@ -615,7 +615,7 @@ struct ptlrpc_body_v2 {
 #define OBD_CONNECT_REQPORTAL   0x40ULL /*Separate non-IO req portal */
 #define OBD_CONNECT_ACL 0x80ULL /*access control lists 
*/
 #define OBD_CONNECT_XATTR  0x100ULL /*client use extended attr */
-#define OBD_CONNECT_CROW   0x200ULL /*MDS+OST create obj on write*/
+#define OBD_CONNECT_LARGE_ACL  0x200ULL /* more than 32 ACL entries */
 #define OBD_CONNECT_TRUNCLOCK  0x400ULL /*locks on server for punch */
 #define OBD_CONNECT_TRANSNO0x800ULL /*replay sends init transno */
 #define OBD_CONNECT_IBITS 0x1000ULL /*support for inodebits locks*/
diff --git a/drivers/staging/lustre/lustre/include/lustre_acl.h 
b/drivers/staging/lustre/lustre/include/lustre_acl.h
index 35ff61c..e7575a1 100644
--- a/drivers/staging/lustre/lustre/include/lustre_acl.h
+++ b/drivers/staging/lustre/lustre/include/lustre_acl.h
@@ -36,11 +36,16 @@
 
 #include 
 #include 
+#ifdef CONFIG_FS_POSIX_ACL
 #include 
 
 #define LUSTRE_POSIX_ACL_MAX_ENTRIES   32
-#define LUSTRE_POSIX_ACL_MAX_SIZE  
\
+#define LUSTRE_POSIX_ACL_MAX_SIZE_OLD  
\
(sizeof(struct posix_acl_xattr_header) +
\
 LUSTRE_POSIX_ACL_MAX_ENTRIES * sizeof(struct posix_acl_xattr_entry))
 
+#else /* ! CONFIG_FS_POSIX_ACL */
+#define LUSTRE_POSIX_ACL_MAX_SIZE_OLD 0
+#endif /* CONFIG_FS_POSIX_ACL */
+
 #endif
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 83eb2da..b5c287b 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -198,7 +198,8 @@ static int client_common_fill_super(struct super_block *sb, 
char *md, char *dt)
if (sbi->ll_flags & LL_SBI_LRU_RESIZE)
data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
 #ifdef CONFIG_FS_POSIX_ACL
-   data->ocd_connect_flags |= OBD_CONNECT_ACL | OBD_CONNECT_UMASK;
+   data->ocd_connect_flags |= OBD_CONNECT_ACL | OBD_CONNECT_UMASK |
+  OBD_CONNECT_LARGE_ACL;
 #endif
 
if (OBD_FAIL_CHECK(OBD_FAIL_MDC_LIGHTWEIGHT))
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c 
b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
index 253a545..65a5341 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
@@ -308,6 +308,8 @@ static void mdc_realloc_openmsg(struct ptlrpc_request *req,
 

[PATCH 3/5] staging: lustre: acl: increase ACL entries limitation

2018-05-14 Thread James Simmons
From: Fan Yong 

Originally, the limitation of ACL entries is 32, that is not
enough for some use cases. In fact, restricting ACL entries
count is mainly for preparing the RPC reply buffer to receive
the ACL data. So we cannot make the ACL entries count to be
unlimited. But we can enlarge the RPC reply buffer to hold
more ACL entries. On the other hand, MDT backend filesystem
has its own EA size limitation. For example, for ldiskfs case,
if large EA enable, then the max ACL size is 1048492 bytes;
otherwise, it is 4012 bytes. For ZFS backend, such value is
32768 bytes. With such hard limitation, we can calculate how
many ACL entries we can have at most. This patch increases
the RPC reply buffer to match such hard limitation. For old
client, to avoid buffer overflow because of large ACL data
(more than 32 ACL entries), the MDT will forbid the old client
to access the file with large ACL data. As for how to know
whether it is old client or new, a new connection flag
OBD_CONNECT_LARGE_ACL is used for that.

Signed-off-by: Fan Yong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7473
Reviewed-on: https://review.whamcloud.com/19790
Reviewed-by: Andreas Dilger 
Reviewed-by: Li Xi 
Reviewed-by: Lai Siyao 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
 drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h | 2 +-
 drivers/staging/lustre/lustre/include/lustre_acl.h| 7 ++-
 drivers/staging/lustre/lustre/llite/llite_lib.c   | 3 ++-
 drivers/staging/lustre/lustre/mdc/mdc_locks.c | 6 ++
 drivers/staging/lustre/lustre/mdc/mdc_reint.c | 2 ++
 drivers/staging/lustre/lustre/mdc/mdc_request.c   | 4 
 drivers/staging/lustre/lustre/ptlrpc/layout.c | 4 +---
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c   | 4 ++--
 8 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h 
b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
index aac98db..8778c6f 100644
--- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
+++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
@@ -615,7 +615,7 @@ struct ptlrpc_body_v2 {
 #define OBD_CONNECT_REQPORTAL   0x40ULL /*Separate non-IO req portal */
 #define OBD_CONNECT_ACL 0x80ULL /*access control lists 
*/
 #define OBD_CONNECT_XATTR  0x100ULL /*client use extended attr */
-#define OBD_CONNECT_CROW   0x200ULL /*MDS+OST create obj on write*/
+#define OBD_CONNECT_LARGE_ACL  0x200ULL /* more than 32 ACL entries */
 #define OBD_CONNECT_TRUNCLOCK  0x400ULL /*locks on server for punch */
 #define OBD_CONNECT_TRANSNO0x800ULL /*replay sends init transno */
 #define OBD_CONNECT_IBITS 0x1000ULL /*support for inodebits locks*/
diff --git a/drivers/staging/lustre/lustre/include/lustre_acl.h 
b/drivers/staging/lustre/lustre/include/lustre_acl.h
index 35ff61c..e7575a1 100644
--- a/drivers/staging/lustre/lustre/include/lustre_acl.h
+++ b/drivers/staging/lustre/lustre/include/lustre_acl.h
@@ -36,11 +36,16 @@
 
 #include 
 #include 
+#ifdef CONFIG_FS_POSIX_ACL
 #include 
 
 #define LUSTRE_POSIX_ACL_MAX_ENTRIES   32
-#define LUSTRE_POSIX_ACL_MAX_SIZE  
\
+#define LUSTRE_POSIX_ACL_MAX_SIZE_OLD  
\
(sizeof(struct posix_acl_xattr_header) +
\
 LUSTRE_POSIX_ACL_MAX_ENTRIES * sizeof(struct posix_acl_xattr_entry))
 
+#else /* ! CONFIG_FS_POSIX_ACL */
+#define LUSTRE_POSIX_ACL_MAX_SIZE_OLD 0
+#endif /* CONFIG_FS_POSIX_ACL */
+
 #endif
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 83eb2da..b5c287b 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -198,7 +198,8 @@ static int client_common_fill_super(struct super_block *sb, 
char *md, char *dt)
if (sbi->ll_flags & LL_SBI_LRU_RESIZE)
data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
 #ifdef CONFIG_FS_POSIX_ACL
-   data->ocd_connect_flags |= OBD_CONNECT_ACL | OBD_CONNECT_UMASK;
+   data->ocd_connect_flags |= OBD_CONNECT_ACL | OBD_CONNECT_UMASK |
+  OBD_CONNECT_LARGE_ACL;
 #endif
 
if (OBD_FAIL_CHECK(OBD_FAIL_MDC_LIGHTWEIGHT))
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c 
b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
index 253a545..65a5341 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
@@ -308,6 +308,8 @@ static void mdc_realloc_openmsg(struct ptlrpc_request *req,
 
req_capsule_set_size(>rq_pill, _MDT_MD, RCL_SERVER,
 obddev->u.cli.cl_max_mds_easize);
+   req_capsule_set_size(>rq_pill, _ACL,