staging: lustre: acl: increase ACL entries limitation
authorFan Yong <fan.yong@intel.com>
Tue, 29 May 2018 14:21:43 +0000 (10:21 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 31 May 2018 16:55:36 +0000 (18:55 +0200)
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 <fan.yong@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7473
Reviewed-on: https://review.whamcloud.com/19790
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Li Xi <lixi@ddn.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
drivers/staging/lustre/lustre/include/lustre_acl.h
drivers/staging/lustre/lustre/llite/llite_lib.c
drivers/staging/lustre/lustre/mdc/mdc_locks.c
drivers/staging/lustre/lustre/mdc/mdc_reint.c
drivers/staging/lustre/lustre/mdc/mdc_request.c
drivers/staging/lustre/lustre/ptlrpc/layout.c
drivers/staging/lustre/lustre/ptlrpc/wiretest.c

index 8a7301a7612297bc2095792ee9bb8a60ca2aed02..6c7e3992d646c34658560db01d125d4868c8322b 100644 (file)
@@ -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_TRANSNO            0x800ULL /*replay sends init transno */
 #define OBD_CONNECT_IBITS             0x1000ULL /*support for inodebits locks*/
index 35ff61ce4e9d8677c06c71781302720c2b02d827..e7575a172b5fe8bef16a0c69ced935b7557037ef 100644 (file)
 
 #include <linux/fs.h>
 #include <linux/dcache.h>
+#ifdef CONFIG_FS_POSIX_ACL
 #include <linux/posix_acl_xattr.h>
 
 #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
index 1bc0782feae38cb095355986585bfbb63f15138f..36066c839160c4c45c45cf29cb50a5e9e11c255b 100644 (file)
@@ -199,7 +199,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))
index 253a54550ba8c5d68b08d8c0abd41d5b62484e8c..65a5341e8a7c461403e8f92f780382f8fc0ce08a 100644 (file)
@@ -308,6 +308,8 @@ mdc_intent_open_pack(struct obd_export *exp, struct lookup_intent *it,
 
        req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
                             obddev->u.cli.cl_max_mds_easize);
+       req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
+                            req->rq_import->imp_connect_data.ocd_max_easize);
 
        ptlrpc_request_set_replen(req);
        return req;
@@ -352,6 +354,8 @@ mdc_intent_getxattr_pack(struct obd_export *exp,
        req_capsule_set_size(&req->rq_pill, &RMF_EAVALS_LENS,
                             RCL_SERVER, maxdata);
 
+       req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, maxdata);
+
        ptlrpc_request_set_replen(req);
 
        return req;
@@ -433,6 +437,8 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp,
        mdc_getattr_pack(req, valid, it->it_flags, op_data, easize);
 
        req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER, easize);
+       req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
+                            req->rq_import->imp_connect_data.ocd_max_easize);
        ptlrpc_request_set_replen(req);
        return req;
 }
index 94ab43bcbe4fa32500ffe1a77a6112448d419325..e77c00df0693358fce3f2e9b23a36982600ddbba 100644 (file)
@@ -134,6 +134,8 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data,
                       LTIME_S(op_data->op_attr.ia_ctime));
        mdc_setattr_pack(req, op_data, ea, ealen);
 
+       req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
+                            req->rq_import->imp_connect_data.ocd_max_easize);
        ptlrpc_request_set_replen(req);
 
        rc = mdc_reint(req, LUSTRE_IMP_FULL);
index 9b1180547afc5f06181d20db6691e4c983066d39..cff31cb0a9ace637f8fc0e6245576fb8b446766c 100644 (file)
@@ -184,6 +184,8 @@ static int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data,
        mdc_pack_body(req, &op_data->op_fid1, op_data->op_valid,
                      op_data->op_mode, -1, 0);
 
+       req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
+                            req->rq_import->imp_connect_data.ocd_max_easize);
        req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
                             op_data->op_mode);
        ptlrpc_request_set_replen(req);
@@ -230,6 +232,8 @@ static int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data,
 
        req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
                             op_data->op_mode);
+       req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
+                            req->rq_import->imp_connect_data.ocd_max_easize);
        ptlrpc_request_set_replen(req);
 
        rc = mdc_getattr_common(exp, req);
index 2855f38c8190f5c6902a87d617e73250995d3053..417d4a151433cdff1b656aa07583bb086ea0e669 100644 (file)
@@ -992,9 +992,7 @@ EXPORT_SYMBOL(RMF_EADATA);
 struct req_msg_field RMF_EAVALS = DEFINE_MSGF("eavals", 0, -1, NULL, NULL);
 EXPORT_SYMBOL(RMF_EAVALS);
 
-struct req_msg_field RMF_ACL =
-       DEFINE_MSGF("acl", RMF_F_NO_SIZE_CHECK,
-                   LUSTRE_POSIX_ACL_MAX_SIZE, NULL, NULL);
+struct req_msg_field RMF_ACL = DEFINE_MSGF("acl", 0, -1, NULL, NULL);
 EXPORT_SYMBOL(RMF_ACL);
 
 /* FIXME: this should be made to use RMF_F_STRUCT_ARRAY */
index 2f64eb417e772d54e06ca1851cefeef303a22a2a..f9394c3e1ee232b143cbe145465d836ed25ff389 100644 (file)
@@ -1010,8 +1010,8 @@ void lustre_assert_wire_constants(void)
                 OBD_CONNECT_ACL);
        LASSERTF(OBD_CONNECT_XATTR == 0x100ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT_XATTR);
-       LASSERTF(OBD_CONNECT_CROW == 0x200ULL, "found 0x%.16llxULL\n",
-                OBD_CONNECT_CROW);
+       LASSERTF(OBD_CONNECT_LARGE_ACL == 0x200ULL, "found 0x%.16llxULL\n",
+                OBD_CONNECT_LARGE_ACL);
        LASSERTF(OBD_CONNECT_TRUNCLOCK == 0x400ULL, "found 0x%.16llxULL\n",
                 OBD_CONNECT_TRUNCLOCK);
        LASSERTF(OBD_CONNECT_TRANSNO == 0x800ULL, "found 0x%.16llxULL\n",