Whamcloud - gitweb
land minor fixes from b_hd_sec:
authorericm <ericm>
Thu, 28 Jul 2005 18:31:21 +0000 (18:31 +0000)
committerericm <ericm>
Thu, 28 Jul 2005 18:31:21 +0000 (18:31 +0000)
 * "EA" is used for lustre internal metadata ea. so change user ea's name to
   "XATTR", including ACLs.
 * remove a unnecessary param from md_getattr().
 * various more fixes.

15 files changed:
lustre/cobd/cache_obd.c
lustre/include/linux/lustre_idl.h
lustre/include/linux/lustre_mds.h
lustre/include/linux/obd.h
lustre/include/linux/obd_class.h
lustre/llite/dir.c
lustre/llite/file.c
lustre/llite/llite_lib.c
lustre/llite/llite_nfs.c
lustre/llite/symlink.c
lustre/lmv/lmv_obd.c
lustre/lmv/lmv_objmgr.c
lustre/mdc/mdc_locks.c
lustre/mdc/mdc_request.c
lustre/mds/handler.c

index 8f063e3..409e6eb 100644 (file)
@@ -966,7 +966,7 @@ static int cobd_md_getstatus(struct obd_export *exp,
 }
 
 static int cobd_md_getattr(struct obd_export *exp, struct lustre_id *id,
-                           __u64 valid, const char *ea_name, int ea_namelen,
+                           __u64 valid, const char *xattr_name,
                            unsigned int ea_size, struct ptlrpc_request **request)
 {
         struct obd_device *obd = class_exp2obd(exp);
@@ -978,8 +978,7 @@ static int cobd_md_getattr(struct obd_export *exp, struct lustre_id *id,
                 return -EINVAL;
         }
         cobd_exp = cobd_get_exp(obd);
-        return md_getattr(cobd_exp, id, valid, ea_name, ea_namelen,
-                          ea_size, request);
+        return md_getattr(cobd_exp, id, valid, xattr_name, ea_size, request);
 }
 
 static int cobd_md_req2lustre_md(struct obd_export *mdc_exp, 
index b0d4190..fe3d4a8 100644 (file)
@@ -393,7 +393,7 @@ struct lov_mds_md_v0 {            /* LOV EA mds/wire data (little-endian) */
 #define OBD_MD_FLUID    (0x0000000000000200LL)    /* user ID */
 #define OBD_MD_FLGID    (0x0000000000000400LL)    /* group ID */
 #define OBD_MD_FLFLAGS  (0x0000000000000800LL)    /* flags word */
-#define OBD_MD_FLEA     (0x0000000000001000LL)    /* extended attributes */
+#define OBD_MD_FLXATTR  (0x0000000000001000LL)    /* user xattr */
 #define OBD_MD_FLNLINK  (0x0000000000002000LL)    /* link count */
 #define OBD_MD_FLGENER  (0x0000000000004000LL)    /* generation number */
 #define OBD_MD_FLINLINE (0x0000000000008000LL)    /* inline data */
@@ -414,16 +414,16 @@ struct lov_mds_md_v0 {            /* LOV EA mds/wire data (little-endian) */
 #define OBD_MD_REINT    (0x0000000040000000LL)    /* reintegrate oa */
 #define OBD_MD_FID      (0x0000000080000000LL)    /* lustre_id data */
 #define OBD_MD_MEA      (0x0000000100000000LL)    /* shows we are interested in MEA */
-#define OBD_MD_FLEALIST (0x0000000200000000LL)    /* list extended attributes */
-#define OBD_MD_FLACL_ACCESS (0x0000000400000000LL) /* access acl */
-#define OBD_MD_RACL     (0x0000000800000000LL)    /* remote acl */
+#define OBD_MD_FLXATTRLIST (0x0000000200000000LL) /* user xattr list */
+#define OBD_MD_FLACL    (0x0000000400000000LL)    /* acl */
+#define OBD_MD_FLRMTACL (0x0000000800000000LL)    /* remote acl */
 
 #define OBD_MD_FLNOTOBD (~(OBD_MD_FLBLOCKS | OBD_MD_LINKNAME |          \
                            OBD_MD_FLEASIZE | OBD_MD_FLHANDLE |          \
                            OBD_MD_FLCKSUM | OBD_MD_FLQOS |              \
                            OBD_MD_FLOSCOPQ | OBD_MD_FLCOOKIE |          \
-                           OBD_MD_FLEA | OBD_MD_FLEALIST |              \
-                           OBD_MD_FLACL_ACCESS | OBD_MD_MDS))
+                           OBD_MD_FLXATTR | OBD_MD_FLXATTRLIST |        \
+                           OBD_MD_FLACL | OBD_MD_MDS))
 
 static inline struct lustre_handle *obdo_handle(struct obdo *oa)
 {
index 2c6bcbb..40acf00 100644 (file)
@@ -301,8 +301,8 @@ int mdc_req2lustre_md(struct obd_export *exp_lmv, struct ptlrpc_request *req,
                       struct lustre_md *md);
 int mdc_getstatus(struct obd_export *exp, struct lustre_id *rootid);
 int mdc_getattr(struct obd_export *exp, struct lustre_id *id,
-                __u64 valid, const char *ea_name, int ea_namelen,
-                unsigned int ea_size, struct ptlrpc_request **request);
+                __u64 valid, const char *xattr_name, unsigned int ea_size,
+                struct ptlrpc_request **request);
 int mdc_getattr_lock(struct obd_export *exp, struct lustre_id *id,
                      char *filename, int namelen, __u64 valid,
                      unsigned int ea_size, struct ptlrpc_request **request);
index ff20fe3..292ce23 100644 (file)
@@ -901,8 +901,8 @@ struct md_ops {
                          void *, int, ldlm_completion_callback,
                          ldlm_blocking_callback, void *);
         int (*m_getattr)(struct obd_export *, struct lustre_id *,
-                         __u64, const char *, int,
-                         unsigned int, struct ptlrpc_request **);
+                         __u64, const char *, unsigned int,
+                         struct ptlrpc_request **);
         int (*m_access_check)(struct obd_export *, struct lustre_id *,
                               struct ptlrpc_request **);
         int (*m_getattr_lock)(struct obd_export *, struct lustre_id *,
index 03c9567..04ba76f 100644 (file)
@@ -1179,14 +1179,16 @@ static inline int md_delete_inode(struct obd_export *exp,
 }
 
 static inline int md_getattr(struct obd_export *exp, struct lustre_id *id,
-                             __u64 valid, const char *ea_name, int ea_namelen,
-                             unsigned int ea_size, struct ptlrpc_request **request)
+                             __u64 valid, const char *xattr_name,
+                             unsigned int ea_size,
+                             struct ptlrpc_request **request)
 {
         int rc;
         ENTRY;
         EXP_CHECK_MD_OP(exp, getattr);
         MD_COUNTER_INCREMENT(exp->exp_obd, getattr);
-        rc = MDP(exp->exp_obd, getattr)(exp, id, valid, ea_name, ea_namelen, ea_size, request);
+        rc = MDP(exp->exp_obd, getattr)(exp, id, valid, xattr_name,
+                                        ea_size, request);
         RETURN(rc);
 }
 
index d712635..f3d5e23 100644 (file)
@@ -538,7 +538,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file,
                 valid |= OBD_MD_FLDIREA;
 
                 ll_inode2id(&id, inode);
-                rc = md_getattr(sbi->ll_md_exp, &id, valid, NULL, 0,
+                rc = md_getattr(sbi->ll_md_exp, &id, valid, NULL,
                                 obd_size_diskmd(sbi->ll_dt_exp, NULL),
                                 &request);
                 if (rc < 0) {
index 1f9673c..3e5a830 100644 (file)
@@ -1876,7 +1876,7 @@ int ll_removexattr(struct dentry *dentry, const char *name)
 }
 
 static
-int ll_getxattr_internal(struct inode *inode, const char *name, int namelen,
+int ll_getxattr_internal(struct inode *inode, const char *name,
                          void *value, size_t size, __u64 valid)
 {
         struct ptlrpc_request *request = NULL;
@@ -1890,8 +1890,8 @@ int ll_getxattr_internal(struct inode *inode, const char *name, int namelen,
         lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_GETXATTR);
 
         ll_inode2id(&id, inode);
-        rc = md_getattr(sbi->ll_md_exp, &id, valid, name, namelen,
-                         size, &request);
+        rc = md_getattr(sbi->ll_md_exp, &id, valid, name,
+                        size, &request);
         if (rc) {
                 if (rc != -ENODATA && rc != -EOPNOTSUPP)
                         CERROR("md_getattr fails: rc = %d\n", rc);
@@ -1923,14 +1923,14 @@ int ll_getxattr_internal(struct inode *inode, const char *name, int namelen,
 int ll_getxattr(struct dentry *dentry, const char *name, void *value,
                 size_t size)
 {
-        return ll_getxattr_internal(dentry->d_inode, name, strlen(name) + 1, 
-                                    value, size, OBD_MD_FLEA);
+        return ll_getxattr_internal(dentry->d_inode, name,
+                                    value, size, OBD_MD_FLXATTR);
 }
 
 int ll_listxattr(struct dentry *dentry, char *list, size_t size)
 {
-        return ll_getxattr_internal(dentry->d_inode, NULL, 0, list, size,
-                                    OBD_MD_FLEALIST);
+        return ll_getxattr_internal(dentry->d_inode, NULL, list, size,
+                                    OBD_MD_FLXATTRLIST);
 }
 
 /*
index 380c4db..26bc072 100644 (file)
@@ -312,7 +312,7 @@ int lustre_common_fill_super(struct super_block *sb, char *lmv, char *lov,
         /* make root inode */
         err = md_getattr(sbi->ll_md_exp, &sbi->ll_rootid,
                          (OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS | OBD_MD_FID),
-                         NULL, 0, 0, &request);
+                         NULL, 0, &request);
         if (err) {
                 CERROR("md_getattr failed for root: rc = %d\n", err);
                 GOTO(out_lov, err);
@@ -2085,7 +2085,7 @@ int ll_iocontrol(struct inode *inode, struct file *file,
                 struct mds_body *body;
 
                 ll_inode2id(&id, inode);
-                rc = md_getattr(sbi->ll_md_exp, &id, valid, NULL, 0, 0, &req);
+                rc = md_getattr(sbi->ll_md_exp, &id, valid, NULL, 0, &req);
                 if (rc) {
                         CERROR("failure %d inode %lu\n", rc, inode->i_ino);
                         RETURN(-abs(rc));
index 6b2c3c8..c9ddcdc 100644 (file)
@@ -79,7 +79,7 @@ static struct inode * search_inode_for_lustre(struct super_block *sb,
         id_ino(&id) = (__u64)ino;
         id_gen(&id) = generation;
 
-        rc = md_getattr(sbi->ll_md_exp, &id, valid, NULL, 0, 
+        rc = md_getattr(sbi->ll_md_exp, &id, valid, NULL,
                         eadatalen, &req);
         if (rc) {
                 CERROR("failure %d inode %lu\n", rc, ino);
index 6d8a38b..66a980e 100644 (file)
@@ -49,7 +49,7 @@ static int ll_readlink_internal(struct inode *inode,
         }
 
         ll_inode2id(&id, inode);
-        rc = md_getattr(sbi->ll_md_exp, &id, OBD_MD_LINKNAME, NULL, 0, symlen,
+        rc = md_getattr(sbi->ll_md_exp, &id, OBD_MD_LINKNAME, NULL, symlen,
                         request);
 
         if (rc) {
index e21076e..49da01a 100644 (file)
@@ -683,7 +683,7 @@ static int lmv_getstatus(struct obd_export *exp, struct lustre_id *id)
 }
 
 static int lmv_getattr(struct obd_export *exp, struct lustre_id *id,
-                       __u64 valid, const char *ea_name, int ea_namelen,
+                       __u64 valid, const char *xattr_name,
                        unsigned int ea_size, struct ptlrpc_request **request)
 {
         struct obd_device *obd = exp->exp_obd;
@@ -699,8 +699,8 @@ static int lmv_getattr(struct obd_export *exp, struct lustre_id *id,
         LASSERT(i < lmv->desc.ld_tgt_count);
 
 
-        rc = md_getattr(lmv->tgts[i].ltd_exp, id, valid,
-                        ea_name, ea_namelen, ea_size, request);
+        rc = md_getattr(lmv->tgts[i].ltd_exp, id, valid, xattr_name,
+                        ea_size, request);
         if (rc)
                 RETURN(rc);
         
@@ -887,7 +887,7 @@ int lmv_get_mea_and_update_object(struct obd_export *exp,
 
         /* time to update mea of parent id */
         rc = md_getattr(lmv->tgts[id_group(id)].ltd_exp,
-                        id, valid, NULL, 0, mealen, &req);
+                        id, valid, NULL, mealen, &req);
         if (rc) {
                 CERROR("md_getattr() failed, error %d\n", rc);
                 GOTO(cleanup, rc);
index 5ed2544..85f2ef7 100644 (file)
@@ -310,7 +310,7 @@ lmv_create_obj(struct obd_export *exp, struct lustre_id *id, struct mea *mea)
                 valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA | OBD_MD_MEA;
 
                 rc = md_getattr(lmv->tgts[id_group(id)].ltd_exp,
-                                id, valid, NULL, 0, mealen, &req);
+                                id, valid, NULL, mealen, &req);
                 if (rc) {
                         CERROR("md_getattr() failed, error %d\n", rc);
                         GOTO(cleanup, obj = ERR_PTR(rc));
index 7b08a84..3addfcf 100644 (file)
@@ -264,7 +264,10 @@ int mdc_enqueue(struct obd_export *exp,
                 req->rq_replen = lustre_msg_size(5, repsize);
         } else if (it->it_op & (IT_GETATTR | IT_LOOKUP | IT_CHDIR)) {
                 __u64 valid = data->valid | OBD_MD_FLNOTOBD | OBD_MD_FLEASIZE |
-                            OBD_MD_FLACL_ACCESS;
+                              OBD_MD_FLACL;
+
+                /* we don't expect xattr retrieve could reach here */
+                LASSERT(!(valid & (OBD_MD_FLXATTR | OBD_MD_FLXATTRLIST)));
 
                 reqsize[req_buffers++] = sizeof(struct mds_body);
                 reqsize[req_buffers++] = data->namelen + 1;
index 4992ccf..a4584eb 100644 (file)
@@ -106,7 +106,7 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
         struct mds_body *body, *reqbody;
         void            *eadata;
         int              rc;
-        int              repsize[4] = {sizeof(*body)};
+        int              repsize[2] = {sizeof(*body)};
         int              bufcount = 1;
         ENTRY;
 
@@ -119,11 +119,7 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
         }
 
         reqbody = lustre_msg_buf(req->rq_reqmsg, 1, sizeof(*reqbody));
-
-        if (reqbody->valid & OBD_MD_FLACL_ACCESS) {
-                repsize[bufcount++] = 4;
-                repsize[bufcount++] = xattr_acl_size(LL_ACL_MAX_ENTRIES);
-        }
+        LASSERT(!(reqbody->valid & OBD_MD_FLACL));
 
         req->rq_replen = lustre_msg_size(bufcount, repsize);
 
@@ -145,17 +141,15 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
         LASSERT_REPSWAB (req, 1);
 
         /* Skip the check if getxattr/listxattr are called with no buffers */
-        if ((reqbody->valid & (OBD_MD_FLEA | OBD_MD_FLEALIST)) &&
-            (reqbody->eadatasize != 0)){
-                if (body->eadatasize != 0) {
+        if ((reqbody->eadatasize != 0) &&
+            !(reqbody->valid & (OBD_MD_FLXATTR | OBD_MD_FLXATTRLIST))) {
                 /* reply indicates presence of eadata; check it's there... */
-                        eadata = lustre_msg_buf (req->rq_repmsg, 1,
-                                                 body->eadatasize);
-                        if (eadata == NULL) {
-                                CERROR ("Missing/short eadata\n");
-                                RETURN (-EPROTO);
-                        }
-                 }
+                eadata = lustre_msg_buf (req->rq_repmsg, 1,
+                                         body->eadatasize);
+                if (eadata == NULL) {
+                        CERROR ("Missing/short eadata\n");
+                        RETURN (-EPROTO);
+                }
          }
 
         RETURN (0);
@@ -173,26 +167,21 @@ static int mdc_cancel_unused(struct obd_export *exp,
 }
 
 int mdc_getattr(struct obd_export *exp, struct lustre_id *id,
-                __u64 valid, const char *ea_name, int ea_namelen,
+                __u64 valid, const char *xattr_name,
                 unsigned int ea_size, struct ptlrpc_request **request)
 {
         struct ptlrpc_request *req;
         struct mds_body *body;
+        int xattr_namelen = xattr_name ? strlen(xattr_name) + 1 : 0;
         int bufcount = 2;
         int size[3] = {0, sizeof(*body)};
         int rc;
         ENTRY;
 
-        /* XXX do we need to make another request here?  We just did a getattr
-         *     to do the lookup in the first place.
-         */
         size[0] = lustre_secdesc_size();
 
-        LASSERT((ea_name != NULL) == (ea_namelen != 0));
-        if (valid & (OBD_MD_FLEA | OBD_MD_FLEALIST)) {
-                size[bufcount] = ea_namelen;
-                bufcount++;
-        }
+        if (valid & OBD_MD_FLXATTR)
+                size[bufcount++] = xattr_namelen;
 
         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
                               MDS_GETATTR, bufcount, size, NULL);
@@ -207,11 +196,9 @@ int mdc_getattr(struct obd_export *exp, struct lustre_id *id,
         body->eadatasize = ea_size;
 
 
-        if (valid & OBD_MD_FLEA) {
-                LASSERT(strnlen(ea_name, ea_namelen) == (ea_namelen - 1));
-                memcpy(lustre_msg_buf(req->rq_reqmsg, 2, ea_namelen),
-                       ea_name, ea_namelen);
-        }
+        if (valid & OBD_MD_FLXATTR)
+                memcpy(lustre_msg_buf(req->rq_reqmsg, 2, xattr_namelen),
+                       xattr_name, xattr_namelen);
 
         rc = mdc_getattr_common(exp, ea_size, req);
         if (rc != 0) {
@@ -403,11 +390,11 @@ int mdc_req2lustre_md(struct obd_export *exp_lmv, struct ptlrpc_request *req,
         if (rc)
                 RETURN(rc);
 
-        if (md->body->valid & OBD_MD_FLACL_ACCESS) {
+        if (md->body->valid & OBD_MD_FLACL) {
                 acl_off = (md->body->valid & OBD_MD_FLEASIZE) ?
                                 (offset + 2) : (offset + 1);
 
-                if (md->body->valid & OBD_MD_RACL) {
+                if (md->body->valid & OBD_MD_FLRMTACL) {
 
                         buf = lustre_swab_repbuf(req, acl_off, sizeof(*perm),
                                                  lustre_swab_remote_perm);
index 63ba972..30d8251 100644 (file)
@@ -989,7 +989,7 @@ int mds_pack_ea(struct dentry *dentry, struct ptlrpc_request *req,
                 if (rc != -ENODATA && rc != -EOPNOTSUPP)
                         CERROR("getxattr failed: %d", rc);
         } else {
-                repbody->valid |= OBD_MD_FLEA;
+                repbody->valid |= OBD_MD_FLXATTR;
                 repbody->eadatasize = rc;
                 rc = 0;
         }
@@ -1016,7 +1016,7 @@ int mds_pack_ealist(struct dentry *dentry, struct ptlrpc_request *req,
         if (rc < 0) {
                 CERROR("listxattr failed: %d", rc);
         } else {
-                repbody->valid |= OBD_MD_FLEALIST;
+                repbody->valid |= OBD_MD_FLXATTRLIST;
                 repbody->eadatasize = rc;
                 rc = 0;
         }
@@ -1053,7 +1053,7 @@ int mds_pack_posix_acl(struct lustre_msg *repmsg, int offset,
         }
 
         *sizep = cpu_to_le32(size);
-        body->valid |= OBD_MD_FLACL_ACCESS;
+        body->valid |= OBD_MD_FLACL;
 
         RETURN(0);
 }
@@ -1107,7 +1107,7 @@ int mds_pack_remote_perm(struct ptlrpc_request *req, int reply_off,
         if (inode->i_op->permission(inode, MAY_READ, NULL) == 0)
                 perm->mrp_perm |= MAY_READ;
 
-        body->valid |= (OBD_MD_FLACL_ACCESS | OBD_MD_RACL);
+        body->valid |= (OBD_MD_FLACL | OBD_MD_FLRMTACL);
 
         RETURN(0);
 }
@@ -1171,13 +1171,13 @@ static int mds_getattr_internal(struct obd_device *obd, struct dentry *dentry,
         } else if (S_ISLNK(inode->i_mode) &&
                    (reqbody->valid & OBD_MD_LINKNAME) != 0) {
                 rc = mds_pack_link(dentry, req, body, reply_off);
-        } else if (reqbody->valid & OBD_MD_FLEA) {
+        } else if (reqbody->valid & OBD_MD_FLXATTR) {
                 rc = mds_pack_ea(dentry, req, body, req_off, reply_off);
-        } else if (reqbody->valid & OBD_MD_FLEALIST) {
+        } else if (reqbody->valid & OBD_MD_FLXATTRLIST) {
                 rc = mds_pack_ealist(dentry, req, body, reply_off);
         }
         
-        if (reqbody->valid & OBD_MD_FLACL_ACCESS) {
+        if (reqbody->valid & OBD_MD_FLACL) {
                 int inc = (reqbody->valid & OBD_MD_FLEASIZE) ? 2 : 1;
                 rc = mds_pack_acl(req, reply_off + inc, body, inode);
         }
@@ -1254,7 +1254,7 @@ static int mds_getattr_pack_msg(struct ptlrpc_request *req, struct dentry *de,
                 bufcount++;
                 CDEBUG(D_INODE, "symlink size: %Lu, reply space: %d\n",
                        inode->i_size + 1, body->eadatasize);
-        } else if ((body->valid & OBD_MD_FLEA)) {
+        } else if ((body->valid & OBD_MD_FLXATTR)) {
                 char *ea_name = lustre_msg_string(req->rq_reqmsg, 
                                                   offset + 1, 0);
                 rc = -EOPNOTSUPP;
@@ -1270,7 +1270,7 @@ static int mds_getattr_pack_msg(struct ptlrpc_request *req, struct dentry *de,
                         size[bufcount] = min_t(int, body->eadatasize, rc);
                 }
                 bufcount++;
-        } else if (body->valid & OBD_MD_FLEALIST) {
+        } else if (body->valid & OBD_MD_FLXATTRLIST) {
                 rc = -EOPNOTSUPP;
                 if (inode->i_op && inode->i_op->getxattr) 
                         rc = inode->i_op->listxattr(de, NULL, 0);
@@ -1287,7 +1287,7 @@ static int mds_getattr_pack_msg(struct ptlrpc_request *req, struct dentry *de,
         }
         
         /* may co-exist with OBD_MD_FLEASIZE */
-        if (body->valid & OBD_MD_FLACL_ACCESS) {
+        if (body->valid & OBD_MD_FLACL) {
                 if (req->rq_export->exp_mds_data.med_remote) {
                         size[bufcount++] = sizeof(struct mds_remote_perm);
                 } else {