Whamcloud - gitweb
- many fixes about using ENTRY, RETURN, GOTO and EXIT.
authoryury <yury>
Fri, 12 Aug 2005 12:21:14 +0000 (12:21 +0000)
committeryury <yury>
Fri, 12 Aug 2005 12:21:14 +0000 (12:21 +0000)
- md_close() chnaged to use mdc_op_data like other md_* functions instead of using obdo.
- fixed prototype declaration for llapi_lov_get_uuids() - bug #6900
- fixed error message in ll_gns_mount_object() - bug #7146

- a lot of fixes about memory allocation/freeing:
  - checks is memory is actually allocated by OBD_ALLOC() before sing it and do appropriate
    actions otherwise.

  - fixed many leaks on error paths.
  - fixed missed OBD_FREE(capa_hash) in capa_cache_cleanup()

- fixed few on stack allocatoins of mdc_op_data in new landed stuff.

- in smfs_mount_cache() fixes correct cleanup in the cases of memory allocation failures.
  Do mntput() for new mounted cache_mnt on error path.

- in smfs_umount_cache() nullify smb->smsi_cache_ftype and smb->smsi_ftype after freeing
  them, to prevent attempt to free again if smfs_umount_cache() is called second time.

30 files changed:
lustre/cmobd/cm_write.c
lustre/cobd/cache_obd.c
lustre/include/liblustre.h
lustre/include/linux/lustre_idl.h
lustre/include/linux/lustre_mds.h
lustre/include/linux/obd.h
lustre/include/linux/obd_class.h
lustre/include/lustre/liblustreapi.h
lustre/liblustre/file.c
lustre/llite/dir.c
lustre/llite/file.c
lustre/llite/llite_gns.c
lustre/llite/llite_gs.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/lmv/lmv_intent.c
lustre/lmv/lmv_obd.c
lustre/lvfs/fsfilt_snap_ext3.c
lustre/lvfs/lvfs_linux.c
lustre/mdc/mdc_internal.h
lustre/mdc/mdc_lib.c
lustre/mdc/mdc_request.c
lustre/mds/handler.c
lustre/mds/mds_lib.c
lustre/mds/mds_lmv.c
lustre/obdclass/capa.c
lustre/sec/gks/gks_server.c
lustre/smfs/options.c
lustre/smfs/smfs_cow.c
lustre/smfs/smfs_lib.c

index 93e2942..aa6bf81 100644 (file)
@@ -318,6 +318,7 @@ static int cmobd_write_extent(struct obd_device *obd,
         if (wakeup)
                 wake_up(&set->es_waitq);
 
         if (wakeup)
                 wake_up(&set->es_waitq);
 
+        EXIT;
 out: 
         if (lnb)
                 OBD_FREE(lnb, oa_bufs * sizeof(struct niobuf_local));
 out: 
         if (lnb)
                 OBD_FREE(lnb, oa_bufs * sizeof(struct niobuf_local));
@@ -326,7 +327,7 @@ out:
         if (oa)
                 obdo_free(oa);
 
         if (oa)
                 obdo_free(oa);
 
-        RETURN(rc);
+        return rc;
 }
 
 static struct cmobd_extent_info* get_next_ei(struct cmobd_write_service *ws)
 }
 
 static struct cmobd_extent_info* get_next_ei(struct cmobd_write_service *ws)
index 83d2a97..ccc6e1d 100644 (file)
@@ -1396,7 +1396,7 @@ static int cobd_md_readpage(struct obd_export *exp,
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
-static int cobd_md_close(struct obd_export *exp, struct obdo *obdo,
+static int cobd_md_close(struct obd_export *exp, struct mdc_op_data *op_data,
                          struct obd_client_handle *och, 
                          struct ptlrpc_request **request)
 {
                          struct obd_client_handle *och, 
                          struct ptlrpc_request **request)
 {
@@ -1411,7 +1411,7 @@ static int cobd_md_close(struct obd_export *exp, struct obdo *obdo,
                 RETURN(-EINVAL);
         }
         cobd_exp = cobd_get_exp(obd);
                 RETURN(-EINVAL);
         }
         cobd_exp = cobd_get_exp(obd);
-        rc = md_close(cobd_exp, obdo, och, request);
+        rc = md_close(cobd_exp, op_data, och, request);
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
index c5446ff..dc339a4 100644 (file)
@@ -114,6 +114,12 @@ typedef unsigned short umode_t;
 #define FMODE_EXEC 4
 #endif
 
 #define FMODE_EXEC 4
 #endif
 
+#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO)
+#define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
+#define S_IRUGO   (S_IRUSR|S_IRGRP|S_IROTH)
+#define S_IWUGO   (S_IWUSR|S_IWGRP|S_IWOTH)
+#define S_IXUGO   (S_IXUSR|S_IXGRP|S_IXOTH)
+
 #define LBUG()                                                          \
         do {                                                            \
                 printf("!!!LBUG at %s:%d\n", __FILE__, __LINE__);       \
 #define LBUG()                                                          \
         do {                                                            \
                 printf("!!!LBUG at %s:%d\n", __FILE__, __LINE__);       \
index b78582f..c7f10ad 100644 (file)
@@ -739,7 +739,7 @@ struct lustre_md {
         struct mea             *mea;
         struct posix_acl       *posix_acl;
         struct mds_remote_perm *remote_perm;
         struct mea             *mea;
         struct posix_acl       *posix_acl;
         struct mds_remote_perm *remote_perm;
-        struct lustre_key *key; 
+        struct lustre_key      *key; 
 };
 
 void lustre_swab_remote_perm(struct mds_remote_perm *p);
 };
 
 void lustre_swab_remote_perm(struct mds_remote_perm *p);
@@ -753,8 +753,17 @@ struct mdc_op_data {
         __u32            create_mode;
         struct mea      *mea1;       /* mea of inode1 */
         struct mea      *mea2;       /* mea of inode2 */
         __u32            create_mode;
         struct mea      *mea1;       /* mea of inode1 */
         struct mea      *mea2;       /* mea of inode2 */
-        __u64            valid;
-        __u32            flags;
+        obd_valid        valid;
+        obd_flags        flags;
+
+        /* fields needed for md_close() */
+        __u64            io_epoch;
+        obd_size         size;
+        obd_blocks       blocks;
+        obd_time         mtime;
+        obd_time         atime;
+        obd_time         ctime;
+        obd_mode         mode;
 };
 
 #define MDS_MODE_DONT_LOCK      (1 << 30)
 };
 
 #define MDS_MODE_DONT_LOCK      (1 << 30)
index 45602d5..7a27223 100644 (file)
@@ -349,8 +349,8 @@ int mdc_set_open_replay_data(struct obd_export *exp,
                              struct ptlrpc_request *open_req);
 int mdc_clear_open_replay_data(struct obd_export *exp, 
                                struct obd_client_handle *och);
                              struct ptlrpc_request *open_req);
 int mdc_clear_open_replay_data(struct obd_export *exp, 
                                struct obd_client_handle *och);
-int mdc_close(struct obd_export *, struct obdo *, struct obd_client_handle *,
-              struct ptlrpc_request **);
+int mdc_close(struct obd_export *, struct mdc_op_data *,
+              struct obd_client_handle *, struct ptlrpc_request **);
 int mdc_readpage(struct obd_export *exp, struct lustre_id *id,
                  __u64, struct page *, struct ptlrpc_request **);
 int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data,
 int mdc_readpage(struct obd_export *exp, struct lustre_id *id,
                  __u64, struct page *, struct ptlrpc_request **);
 int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data,
index 12e67fc..0256dec 100644 (file)
@@ -958,9 +958,8 @@ struct md_ops {
         int (*m_change_cbdata_name)(struct obd_export *, struct lustre_id *,
                                     char *, int, struct lustre_id *,
                                     ldlm_iterator_t, void *);
         int (*m_change_cbdata_name)(struct obd_export *, struct lustre_id *,
                                     char *, int, struct lustre_id *,
                                     ldlm_iterator_t, void *);
-        int (*m_close)(struct obd_export *, struct obdo *,
-                       struct obd_client_handle *,
-                       struct ptlrpc_request **);
+        int (*m_close)(struct obd_export *, struct mdc_op_data *,
+                       struct obd_client_handle *, struct ptlrpc_request **);
         int (*m_create)(struct obd_export *, struct mdc_op_data *,
                         const void *, int, int, __u32, __u32,
                         __u64, struct ptlrpc_request **);
         int (*m_create)(struct obd_export *, struct mdc_op_data *,
                         const void *, int, int, __u32, __u32,
                         __u64, struct ptlrpc_request **);
index 8866039..e956380 100644 (file)
@@ -85,7 +85,7 @@ int class_process_config(struct lustre_cfg *lcfg);
 
 /* Passed as data param to class_config_parse_handler() */
 struct config_llog_instance {
 
 /* Passed as data param to class_config_parse_handler() */
 struct config_llog_instance {
-        char * cfg_instance;
+        char *cfg_instance;
         struct obd_uuid cfg_uuid;
         ptl_nid_t cfg_local_nid;
 };
         struct obd_uuid cfg_uuid;
         ptl_nid_t cfg_local_nid;
 };
@@ -1236,7 +1236,8 @@ static inline int md_change_cbdata_name(struct obd_export *exp,
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
-static inline int md_close(struct obd_export *exp, struct obdo *obdo,
+static inline int md_close(struct obd_export *exp,
+                           struct mdc_op_data *op_data,
                            struct obd_client_handle *och,
                            struct ptlrpc_request **request)
 {
                            struct obd_client_handle *och,
                            struct ptlrpc_request **request)
 {
@@ -1244,7 +1245,7 @@ static inline int md_close(struct obd_export *exp, struct obdo *obdo,
         ENTRY;
         EXP_CHECK_MD_OP(exp, close);
         MD_COUNTER_INCREMENT(exp->exp_obd, close);
         ENTRY;
         EXP_CHECK_MD_OP(exp, close);
         MD_COUNTER_INCREMENT(exp->exp_obd, close);
-        rc = MDP(exp->exp_obd, close)(exp, obdo, och, request);
+        rc = MDP(exp->exp_obd, close)(exp, op_data, och, request);
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
index 78bb204..779f8b6 100644 (file)
@@ -36,7 +36,8 @@ extern int llapi_find(char *path, struct obd_uuid *obduuid, int recursive,
                       int verbose, int quiet, int showfid);
 extern int llapi_target_check(int num_types, char **obd_types, char *dir);
 extern int llapi_catinfo(char *dir, char *keyword, char *node_name);
                       int verbose, int quiet, int showfid);
 extern int llapi_target_check(int num_types, char **obd_types, char *dir);
 extern int llapi_catinfo(char *dir, char *keyword, char *node_name);
-extern int llapi_lov_get_uuids(int fd, struct obd_uuid *uuidp, int *ost_count);
+extern int llapi_lov_get_uuids(int fd, struct obd_uuid *uuidp,
+                               __u32 *obdgens, int *ost_count);
 extern int llapi_is_lustre_mnttype(char *type);
 extern int llapi_getfacl(char *dir, char *cmd);
 extern int llapi_setfacl(char *dir, char *cmd);
 extern int llapi_is_lustre_mnttype(char *type);
 extern int llapi_getfacl(char *dir, char *cmd);
 extern int llapi_setfacl(char *dir, char *cmd);
index 1563798..d592124 100644 (file)
@@ -63,6 +63,62 @@ void llu_prepare_mdc_data(struct mdc_op_data *data, struct inode *i1,
         data->mod_time = CURRENT_TIME;
 }
 
         data->mod_time = CURRENT_TIME;
 }
 
+static void llu_inode2mdc_data(struct mdc_op_data *op_data,
+                               struct inode *inode,
+                               obd_valid valid)
+{
+        struct llu_inode_info *lli = llu_i2info(inode);
+        obd_valid newvalid = 0;
+        
+        LASSERT(op_data != NULL);
+        LASSERT(inode != NULL);
+
+        /* put object id there all the time. */
+        if (valid & OBD_MD_FLID) {
+                ll_inode2id(&op_data->id1, inode);
+                newvalid |= OBD_MD_FLID;
+        }
+        
+        if (valid & OBD_MD_FLSIZE) {
+                op_data->size = lli->lli_st_size;
+                newvalid |= OBD_MD_MEA;
+        }
+        if (valid & OBD_MD_FLBLOCKS) {
+                op_data->blocks = lli->lli_st_blocks;
+                newvalid |= OBD_MD_FLBLOCKS;
+        }
+        if (valid & OBD_MD_FLFLAGS) {
+                op_data->flags = lli->lli_st_flags;
+                newvalid |= OBD_MD_FLFLAGS;
+        }
+        if (valid & OBD_MD_FLATIME) {
+                op_data->atime = LTIME_S(lli->lli_st_atime);
+                newvalid |= OBD_MD_FLATIME;
+        }
+        if (valid & OBD_MD_FLMTIME) {
+                op_data->mtime = LTIME_S(lli->lli_st_mtime);
+                newvalid |= OBD_MD_FLMTIME;
+        }
+        if (valid & OBD_MD_FLCTIME) {
+                op_data->ctime = LTIME_S(lli->lli_st_ctime);
+                newvalid |= OBD_MD_FLCTIME;
+        }
+
+        if (valid & OBD_MD_FLTYPE) {
+                op_data->mode = (op_data->mode & S_IALLUGO) |
+                        (lli->lli_st_mode & S_IFMT);
+                newvalid |= OBD_MD_FLTYPE;
+        }
+
+        if (valid & OBD_MD_FLMODE) {
+                op_data->mode = (op_data->mode & S_IFMT) |
+                        (lli->lli_st_mode & S_IALLUGO);
+                newvalid |= OBD_MD_FLMODE;
+        }
+
+        op_data->valid |= newvalid;
+}
+
 void obdo_refresh_inode(struct inode *dst,
                         struct obdo *src,
                         obd_valid valid)
 void obdo_refresh_inode(struct inode *dst,
                         struct obdo *src,
                         obd_valid valid)
@@ -272,7 +328,7 @@ int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode)
         struct ll_file_data *fd = lli->lli_file_data;
         struct ptlrpc_request *req = NULL;
         struct obd_client_handle *och = &fd->fd_mds_och;
         struct ll_file_data *fd = lli->lli_file_data;
         struct ptlrpc_request *req = NULL;
         struct obd_client_handle *och = &fd->fd_mds_och;
-        struct obdo obdo;
+        struct mdc_op_data op_data;
         int rc, valid;
         ENTRY;
 
         int rc, valid;
         ENTRY;
 
@@ -284,20 +340,21 @@ int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode)
                                        &fd->fd_cwlockh);
         }
 
                                        &fd->fd_cwlockh);
         }
 
-        obdo.o_id = lli->lli_st_ino;
-        obdo.o_valid = OBD_MD_FLID;
+       memset(&op_data, 0, sizeof(op_data));
+       id_ino(&op_data.id1) = lli->lli_st_ino;
+        op_data.valid = OBD_MD_FLID;
         valid = OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLSIZE |OBD_MD_FLBLOCKS |
                 OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME;
         if (test_bit(LLI_F_HAVE_OST_SIZE_LOCK, &lli->lli_flags))
                 valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
 
         valid = OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLSIZE |OBD_MD_FLBLOCKS |
                 OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME;
         if (test_bit(LLI_F_HAVE_OST_SIZE_LOCK, &lli->lli_flags))
                 valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
 
-        obdo_from_inode(&obdo, inode, valid);
+       llu_inode2mdc_data(&op_data, inode, valid);
 
         if (0 /* ll_is_inode_dirty(inode) */) {
 
         if (0 /* ll_is_inode_dirty(inode) */) {
-                obdo.o_flags = MDS_BFLAG_UNCOMMITTED_WRITES;
-                obdo.o_valid |= OBD_MD_FLFLAGS;
+                op_data.flags = MDS_BFLAG_UNCOMMITTED_WRITES;
+                op_data.valid |= OBD_MD_FLFLAGS;
         }
         }
-        rc = mdc_close(mdc_exp, &obdo, och, &req);
+        rc = mdc_close(mdc_exp, &op_data, och, &req);
         if (rc == EAGAIN) {
                 /* We are the last writer, so the MDS has instructed us to get
                  * the file size and any write cookies, then close again. */
         if (rc == EAGAIN) {
                 /* We are the last writer, so the MDS has instructed us to get
                  * the file size and any write cookies, then close again. */
index 8868604..28f664f 100644 (file)
@@ -233,7 +233,7 @@ static struct page *ll_get_dir_page(struct inode *dir, unsigned long n)
                 if (op_data == NULL)
                         return ERR_PTR(-ENOMEM);
 
                 if (op_data == NULL)
                         return ERR_PTR(-ENOMEM);
 
-                ll_prepare_mdc_data(op_data, dir, NULL, NULL, 0, 0);
+                ll_inode2mdc_data(op_data, dir, (OBD_MD_FLID | OBD_MD_MEA));
 
                 rc = ll_intent_alloc(&it);
                 if (rc)
 
                 rc = ll_intent_alloc(&it);
                 if (rc)
@@ -426,7 +426,7 @@ static int ll_mkdir_stripe(struct inode *inode, unsigned long arg)
         OBD_ALLOC(op_data, sizeof(*op_data));
         if (op_data == NULL)
                 GOTO(out, err = -ENOMEM);
         OBD_ALLOC(op_data, sizeof(*op_data));
         if (op_data == NULL)
                 GOTO(out, err = -ENOMEM);
-        ll_prepare_mdc_data(op_data, inode, NULL, name,lums.lums_namelen,0);
+        ll_prepare_mdc_data(op_data, inode, NULL, name, lums.lums_namelen, 0);
         err = md_create(sbi->ll_md_exp, op_data, &nstripes, sizeof(nstripes),
                         mode, current->fsuid, current->fsgid, 0, &request);
         OBD_FREE(op_data, sizeof(*op_data));
         err = md_create(sbi->ll_md_exp, op_data, &nstripes, sizeof(nstripes),
                         mode, current->fsuid, current->fsgid, 0, &request);
         OBD_FREE(op_data, sizeof(*op_data));
@@ -500,7 +500,7 @@ static int ll_ioctl_setfacl(struct inode *inode,
                             struct ll_acl_ioctl_data *ioc)
 {
         struct ptlrpc_request *req = NULL;
                             struct ll_acl_ioctl_data *ioc)
 {
         struct ptlrpc_request *req = NULL;
-        struct mdc_op_data op_data;
+        struct mdc_op_data *op_data;
         struct mds_body *body;
         struct iattr attr;
         char *cmd;
         struct mds_body *body;
         struct iattr attr;
         char *cmd;
@@ -522,12 +522,18 @@ static int ll_ioctl_setfacl(struct inode *inode,
         attr.ia_valid |= ATTR_EA;
         attr.ia_attr_flags = 0;
 
         attr.ia_valid |= ATTR_EA;
         attr.ia_attr_flags = 0;
 
-        ll_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0);
+        OBD_ALLOC(op_data, sizeof(*op_data));
+        if (!op_data)
+                GOTO(out, rc = -ENOMEM);
+        
+        ll_inode2mdc_data(op_data, inode, (OBD_MD_FLID | OBD_MD_MEA));
 
 
-        rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, &op_data, &attr,
-                        (void*) XATTR_NAME_LUSTRE_ACL,
+        rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, &attr,
+                        (void *)XATTR_NAME_LUSTRE_ACL,
                         sizeof(XATTR_NAME_LUSTRE_ACL),
                         sizeof(XATTR_NAME_LUSTRE_ACL),
-                        (void*) cmd, ioc->cmd_len, NULL, 0, &req);
+                        (void *)cmd, ioc->cmd_len, NULL, 0, &req);
+        OBD_FREE(op_data, sizeof(*op_data));
+        
         if (rc) {
                 CERROR("md_setattr fails: rc = %d\n", rc);
                 GOTO(out, rc);
         if (rc) {
                 CERROR("md_setattr fails: rc = %d\n", rc);
                 GOTO(out, rc);
@@ -658,7 +664,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file,
                 if (op_data == NULL)
                         RETURN(-ENOMEM);
                 
                 if (op_data == NULL)
                         RETURN(-ENOMEM);
                 
-                ll_prepare_mdc_data(op_data, inode, NULL, NULL, 0, 0);
+                ll_inode2mdc_data(op_data, inode, (OBD_MD_FLID | OBD_MD_MEA));
 
                 rc = md_setattr(sbi->ll_md_exp, op_data, &attr, &lum,
                                 sizeof(lum), NULL, 0, NULL, 0, &request);
 
                 rc = md_setattr(sbi->ll_md_exp, op_data, &attr, &lum,
                                 sizeof(lum), NULL, 0, NULL, 0, &request);
index 3ecc041..b466110 100644 (file)
@@ -77,8 +77,9 @@ int ll_md_och_close(struct obd_export *md_exp, struct inode *inode,
                     struct obd_client_handle *och, int dirty)
 {
         struct ptlrpc_request *req = NULL;
                     struct obd_client_handle *och, int dirty)
 {
         struct ptlrpc_request *req = NULL;
-        struct obdo *obdo = NULL;
+        struct mdc_op_data *op_data;
         struct obd_device *obd;
         struct obd_device *obd;
+        obd_valid valid;
         int rc;
         ENTRY;
 
         int rc;
         ENTRY;
 
@@ -86,55 +87,47 @@ int ll_md_och_close(struct obd_export *md_exp, struct inode *inode,
         if (obd == NULL) {
                 CERROR("Invalid MDC connection handle "LPX64"\n",
                        md_exp->exp_handle.h_cookie);
         if (obd == NULL) {
                 CERROR("Invalid MDC connection handle "LPX64"\n",
                        md_exp->exp_handle.h_cookie);
-                EXIT;
-                return 0;
+                RETURN(0);
         }
 
         }
 
-        /*
-         * here we check if this is forced umount. If so this is called on
+        /* here we check if this is forced umount. If so this is called on
          * canceling "open lock" and we do not call md_close() in this case , as
          * canceling "open lock" and we do not call md_close() in this case , as
-         * it will not successful, as import is already deactivated.
-         */
+         * it will not successful, as import is already deactivated. */
         if (obd->obd_no_recov)
                 GOTO(out, rc = 0);
 
         if (obd->obd_no_recov)
                 GOTO(out, rc = 0);
 
-        /* closing opened file */
-        obdo = obdo_alloc();
-        if (obdo == NULL)
+        /* prepare @op_data for close request */
+        OBD_ALLOC(op_data, sizeof(*op_data));
+        if (!op_data)
                 RETURN(-ENOMEM);
 
                 RETURN(-ENOMEM);
 
-        obdo->o_id = inode->i_ino;
-        obdo->o_generation = inode->i_generation;
-        obdo->o_valid = OBD_MD_FLID;
-        obdo_from_inode(obdo, inode, (OBD_MD_FLTYPE | OBD_MD_FLMODE |
-                                      OBD_MD_FLATIME | OBD_MD_FLMTIME |
-                                      OBD_MD_FLCTIME));
+        memset(op_data, 0, sizeof(*op_data));
+
+        valid = (OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME |
+                 OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLEPOCH |
+                 OBD_MD_FLID);
+        
+        ll_inode2mdc_data(op_data, inode, valid);
+
         if (0 /* ll_is_inode_dirty(inode) */) {
         if (0 /* ll_is_inode_dirty(inode) */) {
-                obdo->o_flags = MDS_BFLAG_UNCOMMITTED_WRITES;
-                obdo->o_valid |= OBD_MD_FLFLAGS;
+                op_data->flags = MDS_BFLAG_UNCOMMITTED_WRITES;
+                op_data->valid |= OBD_MD_FLFLAGS;
         }
         }
-        obdo->o_fid = id_fid(&ll_i2info(inode)->lli_id);
-        obdo->o_mds = id_group(&ll_i2info(inode)->lli_id);
-
-        obdo->o_valid |= OBD_MD_FLEPOCH;
-        obdo->o_easize = ll_i2info(inode)->lli_io_epoch;
 
         if (dirty) {
                 /* we modified data through this handle */
 
         if (dirty) {
                 /* we modified data through this handle */
-                obdo->o_flags |= MDS_BFLAG_DIRTY_EPOCH;
-                obdo->o_valid |= OBD_MD_FLFLAGS;
-                if (ll_validate_size(inode, &obdo->o_size, &obdo->o_blocks))
-                        obdo->o_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
+                op_data->flags |= MDS_BFLAG_DIRTY_EPOCH;
+                op_data->valid |= OBD_MD_FLFLAGS;
+                if (ll_validate_size(inode, &op_data->size, &op_data->blocks))
+                        op_data->valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS;
         }
 
         }
 
-        rc = md_close(md_exp, obdo, och, &req);
-        obdo_free(obdo);
+        rc = md_close(md_exp, op_data, och, &req);
+        OBD_FREE(op_data, sizeof(*op_data));
 
         if (rc == EAGAIN) {
 
         if (rc == EAGAIN) {
-                /*
-                 * we are the last writer, so the MDS has instructed us to get
-                 * the file size and any write cookies, then close again.
-                 */
+                /* we are the last writer, so the MDS has instructed us to get
+                 * the file size and any write cookies, then close again. */
 
                 //ll_queue_done_writing(inode);
                 rc = 0;
 
                 //ll_queue_done_writing(inode);
                 rc = 0;
@@ -1267,15 +1260,14 @@ static int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
                                     int flags, struct lov_user_md *lum,
                                     int lum_size)
 {
                                     int flags, struct lov_user_md *lum,
                                     int lum_size)
 {
-        struct ll_inode_info *lli = ll_i2info(inode);
-        struct file *f;
-        struct obd_export *exp = ll_i2dtexp(inode);
-        struct lov_stripe_md *lsm;
         struct lookup_intent oit = {.it_op = IT_OPEN, .it_flags = flags};
         struct lookup_intent oit = {.it_op = IT_OPEN, .it_flags = flags};
+        struct ll_inode_info *lli = ll_i2info(inode);
         struct ptlrpc_request *req = NULL;
         struct ptlrpc_request *req = NULL;
-        int rc = 0;
-        struct lustre_md md;
         struct obd_client_handle *och;
         struct obd_client_handle *och;
+        struct lov_stripe_md *lsm;
+        struct lustre_md md;
+        struct file *f;
+        int rc = 0;
         ENTRY;
 
         
         ENTRY;
 
         
@@ -1317,16 +1309,21 @@ static int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
         if (rc < 0)
                 GOTO(out, rc);
 
         if (rc < 0)
                 GOTO(out, rc);
 
-        rc = mdc_req2lustre_md(ll_i2mdexp(inode), req, 1, exp, &md);
+        rc = mdc_req2lustre_md(ll_i2mdexp(inode), req, 1,
+                               ll_i2dtexp(inode), &md);
         if (rc)
                 GOTO(out, rc);
         ll_update_inode(f->f_dentry->d_inode, &md);
 
         OBD_ALLOC(och, sizeof(struct obd_client_handle));
         if (rc)
                 GOTO(out, rc);
         ll_update_inode(f->f_dentry->d_inode, &md);
 
         OBD_ALLOC(och, sizeof(struct obd_client_handle));
+        if (!och)
+                GOTO(out, rc = -ENOMEM);
+        
+         /* actually ll_local_open() cannot fail! */
         rc = ll_local_open(f, &oit, och);
         rc = ll_local_open(f, &oit, och);
-        if (rc) { /* Actually ll_local_open cannot fail! */
+        if (rc)
                 GOTO(out, rc);
                 GOTO(out, rc);
-        }
+
         if (LUSTRE_IT(&oit)->it_lock_mode) {
                 ldlm_lock_decref_and_cancel((struct lustre_handle *)
                                             &LUSTRE_IT(&oit)->it_lock_handle,
         if (LUSTRE_IT(&oit)->it_lock_mode) {
                 ldlm_lock_decref_and_cancel((struct lustre_handle *)
                                             &LUSTRE_IT(&oit)->it_lock_handle,
@@ -1336,9 +1333,9 @@ static int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
 
         ll_intent_release(&oit);
 
 
         ll_intent_release(&oit);
 
-        /* ll_file_release will decrease the count, but won't free anything
-           because we have at least one more reference coming from actual open
-         */
+        /* ll_file_release() will decrease the count, but won't free anything
+         * because we have at least one more reference coming from actual
+         * open. */
         down(&lli->lli_och_sem);
         lli->lli_open_fd_write_count++;
         up(&lli->lli_och_sem);
         down(&lli->lli_och_sem);
         lli->lli_open_fd_write_count++;
         up(&lli->lli_och_sem);
@@ -1347,7 +1344,7 @@ static int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
         /* Now also destroy our supplemental och */
         ll_md_och_close(ll_i2mdexp(inode), f->f_dentry->d_inode, och, 0);
         EXIT;
         /* Now also destroy our supplemental och */
         ll_md_och_close(ll_i2mdexp(inode), f->f_dentry->d_inode, och, 0);
         EXIT;
- out:
+out:
         ll_intent_release(&oit);
         if (f)
                 put_filp(f);
         ll_intent_release(&oit);
         if (f)
                 put_filp(f);
@@ -1361,37 +1358,35 @@ static int ll_lov_setea(struct inode *inode, struct file *file,
                         unsigned long arg)
 {
         int flags = MDS_OPEN_HAS_OBJS | FMODE_WRITE;
                         unsigned long arg)
 {
         int flags = MDS_OPEN_HAS_OBJS | FMODE_WRITE;
-        struct lov_user_md  *lump;
         int lum_size = sizeof(struct lov_user_md) +
                 sizeof(struct lov_user_ost_data);
         int lum_size = sizeof(struct lov_user_md) +
                 sizeof(struct lov_user_ost_data);
+        struct lov_user_md  *lump;
         int rc;
         ENTRY;
 
         int rc;
         ENTRY;
 
-        if (!capable (CAP_SYS_ADMIN))
+        if (!capable(CAP_SYS_ADMIN))
                 RETURN(-EPERM);
 
         OBD_ALLOC(lump, lum_size);
                 RETURN(-EPERM);
 
         OBD_ALLOC(lump, lum_size);
-        if (lump == NULL) {
+        if (lump == NULL)
                 RETURN(-ENOMEM);
                 RETURN(-ENOMEM);
-        }
+        
         rc = copy_from_user(lump, (struct lov_user_md  *)arg, lum_size);
         rc = copy_from_user(lump, (struct lov_user_md  *)arg, lum_size);
-        if (rc) {
-                OBD_FREE(lump, lum_size);
-                RETURN(-EFAULT);
-        }
+        if (rc)
+                GOTO(out_free_lump, rc = -EFAULT);
 
         rc = ll_lov_setstripe_ea_info(inode, file, flags, lump, lum_size);
 
         rc = ll_lov_setstripe_ea_info(inode, file, flags, lump, lum_size);
-
+        EXIT;
+out_free_lump:
         OBD_FREE(lump, lum_size);
         OBD_FREE(lump, lum_size);
-        RETURN(rc);
+        return rc;
 }
 
 static int ll_lov_setstripe(struct inode *inode, struct file *file,
                             unsigned long arg)
 {
         struct lov_user_md lum, *lump = (struct lov_user_md *)arg;
 }
 
 static int ll_lov_setstripe(struct inode *inode, struct file *file,
                             unsigned long arg)
 {
         struct lov_user_md lum, *lump = (struct lov_user_md *)arg;
-        int rc;
-        int flags = FMODE_WRITE;
+        int rc, flags = FMODE_WRITE;
         ENTRY;
 
         /* Bug 1152: copy properly when this is no longer true */
         ENTRY;
 
         /* Bug 1152: copy properly when this is no longer true */
@@ -1893,7 +1888,7 @@ int ll_setxattr_internal(struct inode *inode, const char *name,
 {
         struct ll_sb_info *sbi = ll_i2sbi(inode);
         struct ptlrpc_request *request = NULL;
 {
         struct ll_sb_info *sbi = ll_i2sbi(inode);
         struct ptlrpc_request *request = NULL;
-        struct mdc_op_data op_data;
+        struct mdc_op_data *op_data;
         struct iattr attr;
         void *key = NULL;
         int rc = 0, key_size = 0;
         struct iattr attr;
         void *key = NULL;
         int rc = 0, key_size = 0;
@@ -1914,11 +1909,15 @@ int ll_setxattr_internal(struct inode *inode, const char *name,
                                        &key, &key_size);
         }
 
                                        &key, &key_size);
         }
 
-        ll_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0);
+        OBD_ALLOC(op_data, sizeof(*op_data));
+        if (!op_data)
+                RETURN(-ENOMEM);
+        
+        ll_inode2mdc_data(op_data, inode, (OBD_MD_FLID | OBD_MD_MEA));
 
 
-        rc = md_setattr(sbi->ll_md_exp, &op_data, &attr,
-                        (void*) name, strnlen(name, XATTR_NAME_MAX) + 1, 
-                        (void*) value,  size, key, key_size, &request);
+        rc = md_setattr(sbi->ll_md_exp, op_data, &attr,
+                        (void *)name, strnlen(name, XATTR_NAME_MAX) + 1, 
+                        (void *)value,  size, key, key_size, &request);
         
         if (key && key_size) 
                 OBD_FREE(key, key_size);
         
         if (key && key_size) 
                 OBD_FREE(key, key_size);
index 00f4b17..4109a08 100644 (file)
@@ -173,8 +173,8 @@ ll_gns_mount_object(struct dentry *dentry, struct vfsmount *mnt)
         path = d_path(dentry, mnt, pathpage, PAGE_SIZE);
         if (IS_ERR(path)) {
                 CERROR("can't build mount object path, err %d\n",
         path = d_path(dentry, mnt, pathpage, PAGE_SIZE);
         if (IS_ERR(path)) {
                 CERROR("can't build mount object path, err %d\n",
-                       (int)PTR_ERR(dchild));
-                GOTO(cleanup, rc = PTR_ERR(dchild));
+                       (int)PTR_ERR(path));
+                GOTO(cleanup, rc = PTR_ERR(path));
         }
 
         /* synchronizing with possible /proc/fs/...write */
         }
 
         /* synchronizing with possible /proc/fs/...write */
index 574a926..7fe1804 100644 (file)
@@ -94,15 +94,17 @@ static int ll_get_acl_key(struct inode *inode, struct posix_acl **acl,
         *acl = posix_acl_dup(lli->lli_posix_acl);
         *lkey =  lustre_key_get(lli->lli_key_info);
         spin_unlock(&lli->lli_lock);
         *acl = posix_acl_dup(lli->lli_posix_acl);
         *lkey =  lustre_key_get(lli->lli_key_info);
         spin_unlock(&lli->lli_lock);
+        EXIT;
 out:
         if (req)
                 ptlrpc_req_finished(req);        
 out:
         if (req)
                 ptlrpc_req_finished(req);        
-        RETURN(rc);
+        return rc;
 }
 
 static int ll_init_key_perm(struct key_perm *kperm, struct posix_acl *acl, 
                             __u32 uid, __u32 gid, int mode) 
 {
 }
 
 static int ll_init_key_perm(struct key_perm *kperm, struct posix_acl *acl, 
                             __u32 uid, __u32 gid, int mode) 
 {
+        ENTRY;
         if (acl) {
                 kperm->kp_acl_count = acl->a_count;
                 memcpy(kperm->kp_acls, acl->a_entries, 
         if (acl) {
                 kperm->kp_acl_count = acl->a_count;
                 memcpy(kperm->kp_acls, acl->a_entries, 
@@ -170,11 +172,12 @@ static int ll_get_default_acl(struct inode *inode, struct posix_acl **acl,
                 }
         }
         
                 }
         }
         
-        rc = posix_acl_create_masq(*acl, &mode); 
+        rc = posix_acl_create_masq(*acl, &mode);
+        EXIT;
 out:
         if (buf) 
                 OBD_FREE(buf, buf_size);
 out:
         if (buf) 
                 OBD_FREE(buf, buf_size);
-        RETURN(rc);
+        return rc;
 }
 
 int ll_gks_create_key(struct inode *dir, mode_t mode, void **key, 
 }
 
 int ll_gks_create_key(struct inode *dir, mode_t mode, void **key, 
@@ -182,9 +185,9 @@ int ll_gks_create_key(struct inode *dir, mode_t mode, void **key,
 {
         struct obd_export *gs_exp = ll_i2gsexp(dir);
         struct key_context *kcontext = NULL;
 {
         struct obd_export *gs_exp = ll_i2gsexp(dir);
         struct key_context *kcontext = NULL;
-        struct key_parms   kparms;
         struct posix_acl *default_acl = NULL;       
         struct posix_acl *default_acl = NULL;       
-        int    rc = 0;  
+        struct key_parms kparms;
+        int rc = 0;  
         ENTRY;
  
         OBD_ALLOC(kcontext, sizeof(struct key_context));
         ENTRY;
  
         OBD_ALLOC(kcontext, sizeof(struct key_context));
@@ -207,7 +210,7 @@ int ll_gks_create_key(struct inode *dir, mode_t mode, void **key,
         if (!*key)
                 GOTO(out, rc = -ENOMEM);
  
         if (!*key)
                 GOTO(out, rc = -ENOMEM);
  
-        /*GET an encrypt key from GS server*/
+        /* GET an encrypt key from GS server */
         rc = obd_get_info(gs_exp, sizeof(struct key_parms), (void *)&kparms,
                           key_size, *key);
         if (rc) {
         rc = obd_get_info(gs_exp, sizeof(struct key_parms), (void *)&kparms,
                           key_size, *key);
         if (rc) {
@@ -218,12 +221,13 @@ int ll_gks_create_key(struct inode *dir, mode_t mode, void **key,
                (char*)((struct crypto_key *)(*key))->ck_key, 
                (char*)((struct crypto_key *)(*key))->ck_mac, 
                gs_exp);
                (char*)((struct crypto_key *)(*key))->ck_key, 
                (char*)((struct crypto_key *)(*key))->ck_mac, 
                gs_exp);
+        EXIT;
 out:
         if (kcontext)
                 OBD_FREE(kcontext, sizeof(struct key_context));
         if (default_acl)
                 posix_acl_release(default_acl);
 out:
         if (kcontext)
                 OBD_FREE(kcontext, sizeof(struct key_context));
         if (default_acl)
                 posix_acl_release(default_acl);
-        RETURN(rc);
+        return rc;
 
 }
  
 
 }
  
@@ -257,13 +261,14 @@ int ll_gks_init_it(struct inode *parent, struct lookup_intent *it)
                 GOTO(out, rc);
 
         lustre_data->it_key = key; 
                 GOTO(out, rc);
 
         lustre_data->it_key = key; 
-        lustre_data->it_key_size = key_size; 
+        lustre_data->it_key_size = key_size;
+        EXIT;
 out:
         if (rc) {
                 if (key && key_size)
                         OBD_FREE(key, key_size);
         }
 out:
         if (rc) {
                 if (key && key_size)
                         OBD_FREE(key, key_size);
         }
-        RETURN(rc)
+        return rc
 }
 
 int ll_gks_decrypt_key(struct inode *inode, struct lookup_intent *it)
 }
 
 int ll_gks_decrypt_key(struct inode *inode, struct lookup_intent *it)
@@ -305,6 +310,9 @@ int ll_gks_decrypt_key(struct inode *inode, struct lookup_intent *it)
         spin_unlock(&lli->lli_lock); 
         
         OBD_ALLOC(kperm, sizeof(struct key_perm));
         spin_unlock(&lli->lli_lock); 
         
         OBD_ALLOC(kperm, sizeof(struct key_perm));
+        if (!kperm)
+                GOTO(out, rc = -ENOMEM);
+            
         ll_init_key_perm(kperm, NULL, current->uid, current->gid, 0);
     
         kparms.context = kcontext;
         ll_init_key_perm(kperm, NULL, current->uid, current->gid, 0);
     
         kparms.context = kcontext;
@@ -332,7 +340,8 @@ int ll_gks_decrypt_key(struct inode *inode, struct lookup_intent *it)
         spin_lock(&lli->lli_lock); 
         memcpy(&lkey->lk_dk, ckey->ck_key, KEY_SIZE);
         SET_DECRYPTED(lkey->lk_flags);
         spin_lock(&lli->lli_lock); 
         memcpy(&lkey->lk_dk, ckey->ck_key, KEY_SIZE);
         SET_DECRYPTED(lkey->lk_flags);
-        spin_unlock(&lli->lli_lock); 
+        spin_unlock(&lli->lli_lock);
+        EXIT;
 out:
         if (acl)
                 posix_acl_release(acl);
 out:
         if (acl)
                 posix_acl_release(acl);
@@ -344,8 +353,9 @@ out:
                 OBD_FREE(kcontext, kcontext_size);
         if (ckey)
                 OBD_FREE(ckey, ck_size);
                 OBD_FREE(kcontext, kcontext_size);
         if (ckey)
                 OBD_FREE(ckey, ck_size);
-        RETURN(rc)
+        return rc
 }
 }
+
 static void get_real_parameters(struct inode *inode, struct iattr *iattr,
                                 struct posix_acl *new_acl, mode_t *mode,   
                                 __u32 *uid, __u32 *gid)
 static void get_real_parameters(struct inode *inode, struct iattr *iattr,
                                 struct posix_acl *new_acl, mode_t *mode,   
                                 __u32 *uid, __u32 *gid)
@@ -429,6 +439,9 @@ int ll_gks_get_mac(struct inode *inode, struct iattr *iattr, void *value,
         acl_count = new_acl ? new_acl->a_count : 0;  
         kperm_size = crypto_kperm_size(acl_count);
         OBD_ALLOC(kperm, kperm_size);
         acl_count = new_acl ? new_acl->a_count : 0;  
         kperm_size = crypto_kperm_size(acl_count);
         OBD_ALLOC(kperm, kperm_size);
+        if (!kperm)
+                GOTO(out, rc = -ENOMEM);
+                
         get_real_parameters(inode, iattr, new_acl, &mac_mode, &uid, &gid);
         ll_init_key_perm(kperm, new_acl, uid, gid, mac_mode);
         kparms.context = kcontext;
         get_real_parameters(inode, iattr, new_acl, &mac_mode, &uid, &gid);
         ll_init_key_perm(kperm, new_acl, uid, gid, mac_mode);
         kparms.context = kcontext;
@@ -449,6 +462,7 @@ int ll_gks_get_mac(struct inode *inode, struct iattr *iattr, void *value,
         }
         *key = ckey;
         iattr->ia_valid |= ATTR_MAC;
         }
         *key = ckey;
         iattr->ia_valid |= ATTR_MAC;
+        EXIT;
 out:
         if (acl)
                 posix_acl_release(acl);
 out:
         if (acl)
                 posix_acl_release(acl);
@@ -460,12 +474,13 @@ out:
                 OBD_FREE(kperm, kperm_size);
         if (kcontext)
                 OBD_FREE(kcontext, kcontext_size);
                 OBD_FREE(kperm, kperm_size);
         if (kcontext)
                 OBD_FREE(kcontext, kcontext_size);
-        RETURN(rc)
+        return rc
 }
 
 static int ll_crypt_permission_check(struct lustre_key *lkey,
                                      int flags)
 {
 }
 
 static int ll_crypt_permission_check(struct lustre_key *lkey,
                                      int flags)
 {
+        ENTRY;
         if (!IS_DECRYPTED(lkey->lk_flags)) 
                 RETURN(-EFAULT);
         if (flags == ENCRYPT_DATA && !IS_ENABLE_ENCRYPT(lkey->lk_flags)) 
         if (!IS_DECRYPTED(lkey->lk_flags)) 
                 RETURN(-EFAULT);
         if (flags == ENCRYPT_DATA && !IS_ENABLE_ENCRYPT(lkey->lk_flags)) 
@@ -596,10 +611,12 @@ int ll_mks_create_key(struct inode *inode, struct lookup_intent *it)
         LASSERT(it->d.fs_data != NULL); 
         lustre_data = (struct lustre_intent_data *)it->d.fs_data;
        
         LASSERT(it->d.fs_data != NULL); 
         lustre_data = (struct lustre_intent_data *)it->d.fs_data;
        
-        if (lustre_data->it_key) {
+        if (lustre_data->it_key)
                 OBD_FREE(lustre_data->it_key, sizeof(struct crypto_key));
                 OBD_FREE(lustre_data->it_key, sizeof(struct crypto_key));
-        }
+
         OBD_ALLOC(crypto_key, sizeof(struct crypto_key));
         OBD_ALLOC(crypto_key, sizeof(struct crypto_key));
+        if (!crypto_key)
+                RETURN(-ENOMEM);
        
         crypto_key->ck_type = MKS_TYPE;
         lustre_data->it_key = crypto_key; 
        
         crypto_key->ck_type = MKS_TYPE;
         lustre_data->it_key = crypto_key; 
@@ -628,7 +645,6 @@ int ll_mks_decrypt_key(struct inode *inode, struct lookup_intent *it)
         struct lustre_key *lkey =  NULL;
         struct posix_acl *acl = NULL;
         int rc = 0;
         struct lustre_key *lkey =  NULL;
         struct posix_acl *acl = NULL;
         int rc = 0;
-        
         ENTRY;
  
         rc = ll_get_acl_key(inode, &acl, &lkey);
         ENTRY;
  
         rc = ll_get_acl_key(inode, &acl, &lkey);
@@ -636,13 +652,14 @@ int ll_mks_decrypt_key(struct inode *inode, struct lookup_intent *it)
                 GOTO(out, rc);      
         spin_lock(&lli->lli_lock); 
         SET_DECRYPTED(lkey->lk_flags); 
                 GOTO(out, rc);      
         spin_lock(&lli->lli_lock); 
         SET_DECRYPTED(lkey->lk_flags); 
-        spin_unlock(&lli->lli_lock); 
+        spin_unlock(&lli->lli_lock);
+        EXIT;
 out:
         if (acl)
                 posix_acl_release(acl);
         if (lkey)
                 lustre_key_release(lkey); 
 out:
         if (acl)
                 posix_acl_release(acl);
         if (lkey)
                 lustre_key_release(lkey); 
-        RETURN(rc);
+        return rc;
 }
 
 struct crypto_helper_ops ll_cmd_ops = { 
 }
 
 struct crypto_helper_ops ll_cmd_ops = { 
@@ -665,24 +682,26 @@ static int ll_register_cops(struct ll_crypto_info *llci, char *type,
         list_for_each_entry(tmp, list, clist) {
                 if (!strcmp(type, tmp->ctype)) {
                         CWARN("%s is already registered\n", type);
         list_for_each_entry(tmp, list, clist) {
                 if (!strcmp(type, tmp->ctype)) {
                         CWARN("%s is already registered\n", type);
-                        rc = -EEXIST;
-                        GOTO(exit, rc); 
+                        RETURN(-EEXIST);
                 }
         }
         
         OBD_ALLOC(opi, sizeof(*opi));
                 }
         }
         
         OBD_ALLOC(opi, sizeof(*opi));
+        if (!opi)
+                RETURN(-ENOMEM);
        
        
-        OBD_ALLOC(opi_name, strlen(type) + 1); 
+        OBD_ALLOC(opi_name, strlen(type) + 1);
+        if (!opi_name) {
+                OBD_FREE(opi, sizeof(*opi));
+                RETURN(-ENOMEM);
+        }
        
        
-        LASSERT(opi && opi_name);
-
         memcpy(opi_name, type, strlen(type));
 
         opi->ctype = opi_name;
         opi->cops = cops;
   
         list_add_tail(&opi->clist, list);
         memcpy(opi_name, type, strlen(type));
 
         opi->ctype = opi_name;
         opi->cops = cops;
   
         list_add_tail(&opi->clist, list);
-exit:
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
@@ -693,7 +712,6 @@ static int ll_init_sb_crypto(struct super_block *sb)
         ENTRY;
 
         OBD_ALLOC(llci, sizeof(*llci));
         ENTRY;
 
         OBD_ALLOC(llci, sizeof(*llci));
-        
         if (!llci)
                 RETURN(-ENOMEM);
 
         if (!llci)
                 RETURN(-ENOMEM);
 
@@ -711,6 +729,7 @@ static int ll_unregister_cops(struct ll_crypto_info *llci)
 {
         struct list_head *list = &llci->ll_cops_list;
         struct crypto_ops_item *tmp, *item;
 {
         struct list_head *list = &llci->ll_cops_list;
         struct crypto_ops_item *tmp, *item;
+        ENTRY;
 
         list_for_each_entry_safe(item, tmp, list, clist) {       
                 list_del_init(&item->clist);       
 
         list_for_each_entry_safe(item, tmp, list, clist) {       
                 list_del_init(&item->clist);       
@@ -771,10 +790,11 @@ int lustre_init_crypto(struct super_block *sb, char *gkc,
                 GOTO(out, rc);
         }
         ll_s2crpi(sb)->ll_gt_exp = class_conn2export(&gt_conn);
                 GOTO(out, rc);
         }
         ll_s2crpi(sb)->ll_gt_exp = class_conn2export(&gt_conn);
+        EXIT;
 out:
         if (rc)
                 lustre_destroy_crypto(sb); 
 out:
         if (rc)
                 lustre_destroy_crypto(sb); 
-        RETURN(rc);
+        return rc;
 }
 struct crypto_helper_ops *
 ll_gks_find_ops(struct ll_crypto_info *llc_info, char *type)
 }
 struct crypto_helper_ops *
 ll_gks_find_ops(struct ll_crypto_info *llc_info, char *type)
index 6896b55..c8144a8 100644 (file)
@@ -576,26 +576,95 @@ ll_inode2id(struct lustre_id *id, struct inode *inode)
 }
 
 static inline void
 }
 
 static inline void
-ll_prepare_mdc_data(struct mdc_op_data *data, struct inode *i1,
+ll_inode2mdc_data(struct mdc_op_data *op_data,
+                  struct inode *inode,
+                  obd_valid valid)
+{
+        obd_valid newvalid = 0;
+        
+        LASSERT(op_data != NULL);
+        LASSERT(inode != NULL);
+
+        /* put object id there all the time. */
+        if (valid & OBD_MD_FLID) {
+                ll_inode2id(&op_data->id1, inode);
+                newvalid |= OBD_MD_FLID;
+        }
+        
+        /* it could be directory with mea */
+        if (valid & OBD_MD_MEA) {
+                op_data->mea1 = ll_i2info(inode)->lli_mea;
+                if (op_data->mea1)
+                        newvalid |= OBD_MD_MEA;
+        }
+
+        if (valid & OBD_MD_FLSIZE) {
+                op_data->size = inode->i_size;
+                newvalid |= OBD_MD_FLSIZE;
+        }
+        if (valid & OBD_MD_FLBLOCKS) {
+                op_data->blocks = inode->i_blocks;
+                newvalid |= OBD_MD_FLBLOCKS;
+        }
+        if (valid & OBD_MD_FLFLAGS) {
+                op_data->flags = inode->i_flags;
+                newvalid |= OBD_MD_FLFLAGS;
+        }
+        if (valid & OBD_MD_FLATIME) {
+                op_data->atime = LTIME_S(inode->i_atime);
+                newvalid |= OBD_MD_FLATIME;
+        }
+        if (valid & OBD_MD_FLMTIME) {
+                op_data->mtime = LTIME_S(inode->i_mtime);
+                newvalid |= OBD_MD_FLMTIME;
+        }
+        if (valid & OBD_MD_FLCTIME) {
+                op_data->ctime = LTIME_S(inode->i_ctime);
+                newvalid |= OBD_MD_FLCTIME;
+        }
+        if (valid & OBD_MD_FLEPOCH) {
+                op_data->io_epoch = ll_i2info(inode)->lli_io_epoch;
+                newvalid |= OBD_MD_FLEPOCH;
+        }
+
+        if (valid & OBD_MD_FLTYPE) {
+                op_data->mode = (op_data->mode & S_IALLUGO) |
+                        (inode->i_mode & S_IFMT);
+                newvalid |= OBD_MD_FLTYPE;
+        }
+
+        if (valid & OBD_MD_FLMODE) {
+                op_data->mode = (op_data->mode & S_IFMT) |
+                        (inode->i_mode & S_IALLUGO);
+                newvalid |= OBD_MD_FLMODE;
+        }
+
+        op_data->valid |= newvalid;
+}
+
+static inline void
+ll_prepare_mdc_data(struct mdc_op_data *op_data, struct inode *i1,
                     struct inode *i2, const char *name, int namelen,
                     int mode)
 {
                     struct inode *i2, const char *name, int namelen,
                     int mode)
 {
-        LASSERT(i1);
-        ll_inode2id(&data->id1, i1);
+        LASSERT(op_data != NULL);
+        LASSERT(i1 != NULL);
+        
+        ll_inode2id(&op_data->id1, i1);
 
         /* it could be directory with mea */
 
         /* it could be directory with mea */
-        data->mea1 = ll_i2info(i1)->lli_mea;
+        op_data->mea1 = ll_i2info(i1)->lli_mea;
 
         if (i2) {
 
         if (i2) {
-                ll_inode2id(&data->id2, i2);
-                data->mea2 = ll_i2info(i2)->lli_mea;
+                ll_inode2id(&op_data->id2, i2);
+                op_data->mea2 = ll_i2info(i2)->lli_mea;
         }
 
         }
 
-       data->valid = 0;
-        data->name = name;
-        data->namelen = namelen;
-        data->create_mode = mode;
-        data->mod_time = LTIME_S(CURRENT_TIME);
+       op_data->valid = 0;
+        op_data->name = name;
+        op_data->namelen = namelen;
+        op_data->create_mode = mode;
+        op_data->mod_time = LTIME_S(CURRENT_TIME);
 }
 
 struct crypto_helper_ops {
 }
 
 struct crypto_helper_ops {
index 279eb27..f2002f4 100644 (file)
@@ -834,10 +834,9 @@ static int lustre_process_profile(struct super_block *sb,
                                   char **lov, char **lmv, char **gkc)  
 {
         struct ll_sb_info *sbi = ll_s2sbi(sb);
                                   char **lov, char **lmv, char **gkc)  
 {
         struct ll_sb_info *sbi = ll_s2sbi(sb);
-        struct lustre_profile *lprof;
         struct config_llog_instance cfg;
         struct config_llog_instance cfg;
+        struct lustre_profile *lprof;
         int len, err = 0;
         int len, err = 0;
-        
         ENTRY;
 
         if (!lmd->lmd_profile)
         ENTRY;
 
         if (!lmd->lmd_profile)
@@ -855,8 +854,8 @@ static int lustre_process_profile(struct super_block *sb,
                 GOTO(out, err = -ENOMEM);
         memcpy(sbi->ll_lmd, lmd, sizeof(*lmd));
 
                 GOTO(out, err = -ENOMEM);
         memcpy(sbi->ll_lmd, lmd, sizeof(*lmd));
 
-        /* generate a string unique to this super, let's try
-         the address of the super itself.*/
+        /* generate a string unique to this super, let's try the address of the
+         * super itself. */
         len = (sizeof(sb) * 2) + 1;
         OBD_ALLOC(sbi->ll_instance, len);
         if (sbi->ll_instance == NULL)
         len = (sizeof(sb) * 2) + 1;
         OBD_ALLOC(sbi->ll_instance, len);
         if (sbi->ll_instance == NULL)
@@ -880,19 +879,36 @@ static int lustre_process_profile(struct super_block *sb,
 
         OBD_ALLOC(*lov, strlen(lprof->lp_lov) +
                   strlen(sbi->ll_instance) + 2);
 
         OBD_ALLOC(*lov, strlen(lprof->lp_lov) +
                   strlen(sbi->ll_instance) + 2);
+        if (*lov = NULL)
+                GOTO(out, err = -ENOMEM);
+        
         sprintf(*lov, "%s-%s", lprof->lp_lov, sbi->ll_instance);
 
         OBD_ALLOC(*lmv, strlen(lprof->lp_lmv) +
                   strlen(sbi->ll_instance) + 2);
         sprintf(*lov, "%s-%s", lprof->lp_lov, sbi->ll_instance);
 
         OBD_ALLOC(*lmv, strlen(lprof->lp_lmv) +
                   strlen(sbi->ll_instance) + 2);
+        if (*lmv == NULL)
+                GOTO(out_free_lov, err = -ENOMEM);
+
         sprintf(*lmv, "%s-%s", lprof->lp_lmv, sbi->ll_instance);
 
         if (lprof->lp_gkc) {
                OBD_ALLOC(*gkc, strlen(lprof->lp_gkc) +
         sprintf(*lmv, "%s-%s", lprof->lp_lmv, sbi->ll_instance);
 
         if (lprof->lp_gkc) {
                OBD_ALLOC(*gkc, strlen(lprof->lp_gkc) +
-                               strlen(sbi->ll_instance) + 2);
+                         strlen(sbi->ll_instance) + 2);
+               if (*gkc == NULL)
+                       GOTO(out_free_lmv, err = -ENOMEM);
+               
                sprintf(*gkc, "%s-%s", lprof->lp_gkc, sbi->ll_instance); 
         }
                sprintf(*gkc, "%s-%s", lprof->lp_gkc, sbi->ll_instance); 
         }
+        
+        RETURN(err);
+out_free_lmv:
+        OBD_FREE(*lmv, strlen(lprof->lp_lmv) +
+                 strlen(sbi->ll_instance) + 2);
+out_free_lov:
+        OBD_FREE(*lov, strlen(lprof->lp_lov) +
+                 strlen(sbi->ll_instance) + 2);
 out: 
 out: 
-        RETURN(err)
+        return err
 }
 
 static int lustre_clean_profile(struct ll_sb_info *sbi, int force_umount)
 }
 
 static int lustre_clean_profile(struct ll_sb_info *sbi, int force_umount)
@@ -919,6 +935,12 @@ static int lustre_clean_profile(struct ll_sb_info *sbi, int force_umount)
                 cfg.cfg_uuid = sbi->ll_sb_uuid;
 
                 OBD_ALLOC(cl_prof, len);
                 cfg.cfg_uuid = sbi->ll_sb_uuid;
 
                 OBD_ALLOC(cl_prof, len);
+                if (!cl_prof) {
+                        CERROR("can't allocate memory, "
+                               "skipping processing cleanup profile.\n");
+                        GOTO(free_lmd, err = -ENOMEM);
+                }
+                
                 sprintf(cl_prof, "%s-clean", lmd->lmd_profile);
                 err = lustre_process_log(lmd, cl_prof, &cfg, 0);
                 if (err < 0) {
                 sprintf(cl_prof, "%s-clean", lmd->lmd_profile);
                 err = lustre_process_log(lmd, cl_prof, &cfg, 0);
                 if (err < 0) {
@@ -927,11 +949,12 @@ static int lustre_clean_profile(struct ll_sb_info *sbi, int force_umount)
                 }
                 OBD_FREE(cl_prof, len);
         }
                 }
                 OBD_FREE(cl_prof, len);
         }
+        EXIT;
 free_lmd:
         if (sbi->ll_instance)
                 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance) + 1);
         OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
 free_lmd:
         if (sbi->ll_instance)
                 OBD_FREE(sbi->ll_instance, strlen(sbi->ll_instance) + 1);
         OBD_FREE(sbi->ll_lmd, sizeof(*sbi->ll_lmd));
-        RETURN(err);
+        return err;
 }
 
 int lustre_fill_super(struct super_block *sb, void *data, int silent)
 }
 
 int lustre_fill_super(struct super_block *sb, void *data, int silent)
@@ -970,7 +993,8 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent)
 
         if (err)
                 GOTO(out_free, err);
 
         if (err)
                 GOTO(out_free, err);
-        
+
+        EXIT;
 out_dev:
         if (lmv)
                 OBD_FREE(lmv, strlen(lmv) + 1);
 out_dev:
         if (lmv)
                 OBD_FREE(lmv, strlen(lmv) + 1);
@@ -979,11 +1003,11 @@ out_dev:
         if (gkc)
                 OBD_FREE(gkc, strlen(gkc) + 1);
         
         if (gkc)
                 OBD_FREE(gkc, strlen(gkc) + 1);
         
-        RETURN(err);
+        return err;
 out_free:
         lustre_clean_profile(sbi, 0);
         lustre_free_sbi(sb);
 out_free:
         lustre_clean_profile(sbi, 0);
         lustre_free_sbi(sb);
-        GOTO(out_dev, err);
+        goto out_dev;
 
 } /* lustre_fill_super */
 
 
 } /* lustre_fill_super */
 
@@ -1264,7 +1288,7 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
                 OBD_ALLOC(op_data, sizeof(*op_data));
                 if (op_data == NULL)
                         RETURN(-ENOMEM);
                 OBD_ALLOC(op_data, sizeof(*op_data));
                 if (op_data == NULL)
                         RETURN(-ENOMEM);
-                ll_prepare_mdc_data(op_data, inode, NULL, NULL, 0, 0);
+                ll_inode2mdc_data(op_data, inode, (OBD_MD_FLID | OBD_MD_MEA));
 
                 if (ia_valid & (ATTR_UID | ATTR_GID)) {
                         rc = ll_crypto_get_mac(inode, attr, NULL, 0, &key, 
 
                 if (ia_valid & (ATTR_UID | ATTR_GID)) {
                         rc = ll_crypto_get_mac(inode, attr, NULL, 0, &key, 
@@ -2256,7 +2280,7 @@ int ll_iocontrol(struct inode *inode, struct file *file,
                         obdo_free(oa);
                         RETURN(-ENOMEM);
                 }
                         obdo_free(oa);
                         RETURN(-ENOMEM);
                 }
-                ll_prepare_mdc_data(op_data, inode, NULL, NULL, 0, 0);
+                ll_inode2mdc_data(op_data, inode, (OBD_MD_FLID | OBD_MD_MEA));
 
                 memset(&attr, 0x0, sizeof(attr));
                 attr.ia_attr_flags = flags;
 
                 memset(&attr, 0x0, sizeof(attr));
                 attr.ia_attr_flags = flags;
index ea613ee..c308cdf 100644 (file)
@@ -417,7 +417,9 @@ int lmv_lookup_slaves(struct obd_export *exp, struct ptlrpc_request **reqp)
                 memset(&it, 0, sizeof(it));
                 it.it_op = IT_GETATTR;
                 OBD_ALLOC(it.d.fs_data, sizeof(struct lustre_intent_data));
                 memset(&it, 0, sizeof(it));
                 it.it_op = IT_GETATTR;
                 OBD_ALLOC(it.d.fs_data, sizeof(struct lustre_intent_data));
-
+                if (!it.d.fs_data)
+                        GOTO(cleanup, rc = -ENOMEM);
+                        
                 rc = md_intent_lock(lmv->tgts[id_group(&id)].ltd_exp, &id,
                                     NULL, 0, NULL, 0, &id, &it, 0, &req,
                                     lmv_dirobj_blocking_ast);
                 rc = md_intent_lock(lmv->tgts[id_group(&id)].ltd_exp, &id,
                                     NULL, 0, NULL, 0, &id, &it, 0, &req,
                                     lmv_dirobj_blocking_ast);
@@ -672,6 +674,9 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp,
                 cb = lmv_dirobj_blocking_ast;
 
                 OBD_ALLOC(it.d.fs_data, sizeof(struct lustre_intent_data));
                 cb = lmv_dirobj_blocking_ast;
 
                 OBD_ALLOC(it.d.fs_data, sizeof(struct lustre_intent_data));
+                if (!it.d.fs_data)
+                        GOTO(cleanup, rc = -ENOMEM);
+                        
                 if (id_equal_fid(&id, &obj->id)) {
                         if (master_valid) {
                                 /* lmv_intent_getattr() already checked
                 if (id_equal_fid(&id, &obj->id)) {
                         if (master_valid) {
                                 /* lmv_intent_getattr() already checked
index 45017df..d7c05c6 100644 (file)
@@ -855,13 +855,13 @@ static int lmv_valid_attrs(struct obd_export *exp, struct lustre_id *id)
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
-static int lmv_close(struct obd_export *exp, struct obdo *obdo,
+static int lmv_close(struct obd_export *exp, struct mdc_op_data *op_data,
                      struct obd_client_handle *och,
                      struct ptlrpc_request **request)
 {
         struct obd_device *obd = exp->exp_obd;
         struct lmv_obd *lmv = &obd->u.lmv;
                      struct obd_client_handle *och,
                      struct ptlrpc_request **request)
 {
         struct obd_device *obd = exp->exp_obd;
         struct lmv_obd *lmv = &obd->u.lmv;
-        int rc, i = obdo->o_mds;
+        int rc, i = id_group(&op_data->id1);
         ENTRY;
         
         rc = lmv_check_connect(obd);
         ENTRY;
         
         rc = lmv_check_connect(obd);
@@ -869,9 +869,8 @@ static int lmv_close(struct obd_export *exp, struct obdo *obdo,
                 RETURN(rc);
 
         LASSERT(i < lmv->desc.ld_tgt_count);
                 RETURN(rc);
 
         LASSERT(i < lmv->desc.ld_tgt_count);
-        CDEBUG(D_OTHER, "CLOSE %lu/%lu/%lu\n", (unsigned long)obdo->o_mds,
-               (unsigned long)obdo->o_id, (unsigned long)obdo->o_generation);
-        rc = md_close(lmv->tgts[i].ltd_exp, obdo, och, request);
+        CDEBUG(D_OTHER, "CLOSE "DLID4"\n", OLID4(&op_data->id1));
+        rc = md_close(lmv->tgts[i].ltd_exp, op_data, och, request);
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
index ffe147e..a4accc7 100644 (file)
@@ -376,7 +376,6 @@ static void ext3_copy_meta(handle_t *handle, struct inode *dst, struct inode *sr
                        if (attrlen < 0)
                                continue;
                        OBD_ALLOC(buf, attrlen);
                        if (attrlen < 0)
                                continue;
                        OBD_ALLOC(buf, attrlen);
-                               break;
                        if (!buf) {
                                 CERROR("No MEM\n");
                                 break;
                        if (!buf) {
                                 CERROR("No MEM\n");
                                 break;
index 008c7ef..2acb86c 100644 (file)
@@ -397,7 +397,9 @@ static int l_filldir(void *__buf, const char *name, int namlen, loff_t offset,
                dirent->lld_off = offset; 
 
         OBD_ALLOC(dirent, sizeof(*dirent));
                dirent->lld_off = offset; 
 
         OBD_ALLOC(dirent, sizeof(*dirent));
-
+        if (!dirent)
+                return -ENOMEM;
+        
         list_add_tail(&dirent->lld_list, buf->lrc_list);
 
         buf->lrc_dirent = dirent;
         list_add_tail(&dirent->lld_list, buf->lrc_list);
 
         buf->lrc_dirent = dirent;
index c2faf05..8e1ff84 100644 (file)
@@ -35,10 +35,13 @@ void mdc_open_pack(struct lustre_msg *msg, int offset,
                    struct mdc_op_data *op_data, __u32 mode,
                    __u64 rdev, __u32 flags, const void *lmm,
                    int lmmlen, void *key, int keylen);
                    struct mdc_op_data *op_data, __u32 mode,
                    __u64 rdev, __u32 flags, const void *lmm,
                    int lmmlen, void *key, int keylen);
+
+void mdc_close_pack(struct ptlrpc_request *req, int offset,
+                    struct mdc_op_data *op_data,
+                    struct obd_client_handle *och);
+
 void mdc_readdir_pack(struct ptlrpc_request *req, int req_offset,
                       __u64 offset, __u32 size, struct lustre_id *mdc_id);
 void mdc_readdir_pack(struct ptlrpc_request *req, int req_offset,
                       __u64 offset, __u32 size, struct lustre_id *mdc_id);
-void mdc_close_pack(struct ptlrpc_request *req, int offset, struct obdo *oa,
-                   __u64 valid, struct obd_client_handle *och);
 
 struct mdc_open_data {
         struct obd_client_handle *mod_och;
 
 struct mdc_open_data {
         struct obd_client_handle *mod_och;
index 5967d97..36dc34c 100644 (file)
@@ -108,41 +108,44 @@ void mdc_getattr_pack(struct lustre_msg *msg, int offset,
         }
 }
 
         }
 }
 
-void mdc_close_pack(struct ptlrpc_request *req, int offset, struct obdo *oa,
-                    __u64 valid, struct obd_client_handle *och)
+void mdc_close_pack(struct ptlrpc_request *req, int offset,
+                    struct mdc_op_data *op_data,
+                    struct obd_client_handle *och)
 {
 {
+        obd_valid valid = op_data->valid;
         struct mds_body *body;
 
         struct mds_body *body;
 
-        body = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*body));
-        mdc_pack_id(&body->id1, oa->o_id, oa->o_generation, oa->o_mode, 0, 0);
+        body = lustre_msg_buf(req->rq_reqmsg, offset,
+                              sizeof(*body));
+        body->id1 = op_data->id1;
 
         memcpy(&body->handle, &och->och_fh, sizeof(body->handle));
 
         memcpy(&body->handle, &och->och_fh, sizeof(body->handle));
-        if (oa->o_valid & OBD_MD_FLATIME) {
-                body->atime = oa->o_atime;
+        if (valid & OBD_MD_FLATIME) {
+                body->atime = op_data->atime;
                 body->valid |= OBD_MD_FLATIME;
         }
                 body->valid |= OBD_MD_FLATIME;
         }
-        if (oa->o_valid & OBD_MD_FLMTIME) {
-                body->mtime = oa->o_mtime;
+        if (valid & OBD_MD_FLMTIME) {
+                body->mtime = op_data->mtime;
                 body->valid |= OBD_MD_FLMTIME;
         }
                 body->valid |= OBD_MD_FLMTIME;
         }
-        if (oa->o_valid & OBD_MD_FLCTIME) {
-                body->ctime = oa->o_ctime;
+        if (valid & OBD_MD_FLCTIME) {
+                body->ctime = op_data->ctime;
                 body->valid |= OBD_MD_FLCTIME;
         }
                 body->valid |= OBD_MD_FLCTIME;
         }
-        if (oa->o_valid & OBD_MD_FLSIZE) {
-                body->size = oa->o_size;
+        if (valid & OBD_MD_FLSIZE) {
+                body->size = op_data->size;
                 body->valid |= OBD_MD_FLSIZE;
         }
                 body->valid |= OBD_MD_FLSIZE;
         }
-        if (oa->o_valid & OBD_MD_FLBLOCKS) {
-                body->blocks = oa->o_blocks;
+        if (valid & OBD_MD_FLBLOCKS) {
+                body->blocks = op_data->blocks;
                 body->valid |= OBD_MD_FLBLOCKS;
         }
                 body->valid |= OBD_MD_FLBLOCKS;
         }
-        if (oa->o_valid & OBD_MD_FLFLAGS) {
-                body->flags = oa->o_flags;
+        if (valid & OBD_MD_FLFLAGS) {
+                body->flags = op_data->flags;
                 body->valid |= OBD_MD_FLFLAGS;
         }
                 body->valid |= OBD_MD_FLFLAGS;
         }
-        if (oa->o_valid & OBD_MD_FLEPOCH) {
-                body->io_epoch = oa->o_easize;
+        if (valid & OBD_MD_FLEPOCH) {
+                body->io_epoch = op_data->io_epoch;
                 body->valid |= OBD_MD_FLEPOCH;
         }
 }
                 body->valid |= OBD_MD_FLEPOCH;
         }
 }
index 6d103e9..3154f93 100644 (file)
@@ -752,9 +752,8 @@ static void mdc_commit_close(struct ptlrpc_request *req)
         spin_unlock(&open_req->rq_lock);
 }
 
         spin_unlock(&open_req->rq_lock);
 }
 
-int mdc_close(struct obd_export *exp, struct obdo *oa,
-              struct obd_client_handle *och,
-              struct ptlrpc_request **request)
+int mdc_close(struct obd_export *exp, struct mdc_op_data *op_data,
+              struct obd_client_handle *och, struct ptlrpc_request **request)
 {
         struct obd_device *obd = class_exp2obd(exp);
         struct obd_import *imp = class_exp2cliimp(exp);
 {
         struct obd_device *obd = class_exp2obd(exp);
         struct obd_import *imp = class_exp2cliimp(exp);
@@ -779,10 +778,7 @@ int mdc_close(struct obd_export *exp, struct obdo *oa,
                 GOTO(out, rc = -ENOMEM);
         req->rq_request_portal = MDS_CLOSE_PORTAL;
 
                 GOTO(out, rc = -ENOMEM);
         req->rq_request_portal = MDS_CLOSE_PORTAL;
 
-        //reqsize[0] = lustre_secdesc_size();
-        //lustre_pack_secdesc(req, reqsize[0]);
-
-        /* Ensure that this close's handle is fixed up during replay. */
+        /* ensure that this close's handle is fixed up during replay. */
         LASSERT(och != NULL);
         mod = och->och_mod;
         if (likely(mod != NULL)) {
         LASSERT(och != NULL);
         mod = och->och_mod;
         if (likely(mod != NULL)) {
@@ -794,7 +790,7 @@ int mdc_close(struct obd_export *exp, struct obdo *oa,
                        "expecting close error\n");
         }
 
                        "expecting close error\n");
         }
 
-        mdc_close_pack(req, 1, oa, oa->o_valid, och);
+        mdc_close_pack(req, 1, op_data, och);
 
         req->rq_replen = lustre_msg_size(3, repsize);
         req->rq_commit_cb = mdc_commit_close;
 
         req->rq_replen = lustre_msg_size(3, repsize);
         req->rq_commit_cb = mdc_commit_close;
@@ -1554,8 +1550,8 @@ out_req:
 }
 
 int mdc_obj_create(struct obd_export *exp, struct obdo *oa,
 }
 
 int mdc_obj_create(struct obd_export *exp, struct obdo *oa,
-                   void *acl, int acl_size,
-                   struct lov_stripe_md **ea, struct obd_trans_info *oti)
+                   void *acl, int acl_size, struct lov_stripe_md **ea,
+                   struct obd_trans_info *oti)
 {
         struct ptlrpc_request *request;
         struct ost_body *body;
 {
         struct ptlrpc_request *request;
         struct ost_body *body;
index c25bd26..62a909e 100644 (file)
@@ -3915,6 +3915,12 @@ int mds_dt_clean(struct obd_device *obd)
                 int len = strlen(mds->mds_profile) + sizeof("-clean") + 1;
 
                 OBD_ALLOC(cln_prof, len);
                 int len = strlen(mds->mds_profile) + sizeof("-clean") + 1;
 
                 OBD_ALLOC(cln_prof, len);
+                if (!cln_prof) {
+                        CERROR("can't allocate memory, processing cleanup "
+                               "profile is skipped\n");
+                        goto out;
+                }
+                
                 sprintf(cln_prof, "%s-clean", mds->mds_profile);
 
                 cfg.cfg_instance = NULL;
                 sprintf(cln_prof, "%s-clean", mds->mds_profile);
 
                 cfg.cfg_instance = NULL;
@@ -3927,6 +3933,7 @@ int mds_dt_clean(struct obd_device *obd)
                 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
 
                 OBD_FREE(cln_prof, len);
                 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
 
                 OBD_FREE(cln_prof, len);
+        out:
                 OBD_FREE(mds->mds_profile, strlen(mds->mds_profile) + 1);
                 mds->mds_profile = NULL;
         }
                 OBD_FREE(mds->mds_profile, strlen(mds->mds_profile) + 1);
                 mds->mds_profile = NULL;
         }
index a8c5868..ffb4b8d 100644 (file)
@@ -255,12 +255,14 @@ int mds_pack_gskey(struct obd_device *obd, struct lustre_msg *repmsg,
         *sizep = cpu_to_le32(sizeof(*ckey));
 
         OBD_ALLOC(md_key, sizeof(*md_key));
         *sizep = cpu_to_le32(sizeof(*ckey));
 
         OBD_ALLOC(md_key, sizeof(*md_key));
+        if (!md_key)
+                RETURN(-ENOMEM);
       
         buflen = repmsg->buflens[*offset];
         buf = lustre_msg_buf(repmsg, (*offset)++, buflen);
 
         size = fsfilt_get_md(obd, inode, md_key, sizeof(*md_key), 
       
         buflen = repmsg->buflens[*offset];
         buf = lustre_msg_buf(repmsg, (*offset)++, buflen);
 
         size = fsfilt_get_md(obd, inode, md_key, sizeof(*md_key), 
-                           EA_KEY);
+                             EA_KEY);
         if (size <= 0) {
                 if (size < 0) 
                         CERROR("Can not get gskey from MDS ino %lu rc %d\n",
         if (size <= 0) {
                 if (size < 0) 
                         CERROR("Can not get gskey from MDS ino %lu rc %d\n",
@@ -309,9 +311,8 @@ int mds_set_gskey(struct obd_device *obd, void *handle,
         LASSERT(ckey->ck_type == MKS_TYPE || ckey->ck_type == GKS_TYPE);   
         
         OBD_ALLOC(md_key, sizeof(*md_key)); 
         LASSERT(ckey->ck_type == MKS_TYPE || ckey->ck_type == GKS_TYPE);   
         
         OBD_ALLOC(md_key, sizeof(*md_key)); 
-        if (ckey->ck_type == MKS_TYPE) { 
+        if (ckey->ck_type == MKS_TYPE)
                 mds_get_gskey(inode, ckey);
                 mds_get_gskey(inode, ckey);
-        } 
 
         rc = fsfilt_get_md(obd, inode, md_key, sizeof(*md_key), 
                            EA_KEY);
 
         rc = fsfilt_get_md(obd, inode, md_key, sizeof(*md_key), 
                            EA_KEY);
index d1000e0..6a20951 100644 (file)
@@ -477,6 +477,11 @@ static int filldir(void * __buf, const char * name, int namlen,
         }
         
         OBD_ALLOC(n, namlen + 1);
         }
         
         OBD_ALLOC(n, namlen + 1);
+
+        /* XXX: should be memory allocation checked here in some more smart
+         * manner? */
+        LASSERT(n != NULL);
+
         memcpy(n, name, namlen);
         n[namlen] = (char) 0;
         
         memcpy(n, name, namlen);
         n[namlen] = (char) 0;
         
@@ -1012,10 +1017,16 @@ int mds_lock_slave_objs(struct obd_device *obd, struct dentry *dentry,
         it.it_op = IT_UNLINK;
 
         OBD_ALLOC(it.d.fs_data, sizeof(struct lustre_intent_data));
         it.it_op = IT_UNLINK;
 
         OBD_ALLOC(it.d.fs_data, sizeof(struct lustre_intent_data));
+        if (!it.d.fs_data) {
+                OBD_FREE(*rlockh, handle_size);
+                OBD_FREE(op_data, sizeof(*op_data));
+                RETURN(-ENOMEM);
+        }
 
         rc = md_enqueue(mds->mds_md_exp, LDLM_IBITS, &it, LCK_EX,
                         op_data, *rlockh, NULL, 0, ldlm_completion_ast,
                         mds_blocking_ast, NULL);
 
         rc = md_enqueue(mds->mds_md_exp, LDLM_IBITS, &it, LCK_EX,
                         op_data, *rlockh, NULL, 0, ldlm_completion_ast,
                         mds_blocking_ast, NULL);
+        
         OBD_FREE(op_data, sizeof(*op_data));
         OBD_FREE(it.d.fs_data, sizeof(struct lustre_intent_data));
         EXIT;
         OBD_FREE(op_data, sizeof(*op_data));
         OBD_FREE(it.d.fs_data, sizeof(struct lustre_intent_data));
         EXIT;
index 18d4311..0fa7afe 100644 (file)
@@ -181,6 +181,8 @@ void capa_cache_cleanup(void)
                 list_del(&ocapa->c_list);
                 OBD_FREE(ocapa, sizeof(*ocapa));
         }
                 list_del(&ocapa->c_list);
                 OBD_FREE(ocapa, sizeof(*ocapa));
         }
+
+        OBD_FREE(capa_hash, PAGE_SIZE);
 }
 
 
 }
 
 
index ecea3a3..7e3005e 100644 (file)
@@ -243,7 +243,8 @@ static int gks_mac_verification(struct ptlrpc_request *req,
         ENTRY;
 
         OBD_ALLOC(tmp_mac, MAC_SIZE);
         ENTRY;
 
         OBD_ALLOC(tmp_mac, MAC_SIZE);
-
+        if (!tmp_mac)
+                RETURN(-ENOMEM);
         crypto_get_gks_mac(req, kperm, tmp_mac);
 
         if (!memcmp(tmp_mac, key->ck_mac, MAC_SIZE)) {
         crypto_get_gks_mac(req, kperm, tmp_mac);
 
         if (!memcmp(tmp_mac, key->ck_mac, MAC_SIZE)) {
index 19a32bb..af52d61 100644 (file)
@@ -88,7 +88,10 @@ int get_opt(struct option **option, char **pos)
         if (!left)
                 left = opt_left + strlen(opt_left);
 
         if (!left)
                 left = opt_left + strlen(opt_left);
 
-        OBD_ALLOC(tmp_opt, sizeof(struct option));
+        OBD_ALLOC(tmp_opt, sizeof(*tmp_opt));
+        if (!tmp_opt)
+                return -ENOMEM;
+        
         tmp_opt->opt = NULL;
         tmp_opt->value = NULL;
 
         tmp_opt->opt = NULL;
         tmp_opt->value = NULL;
 
@@ -98,6 +101,11 @@ int get_opt(struct option **option, char **pos)
                 tmp++;
         }
         OBD_ALLOC(name, length + 1);
                 tmp++;
         }
         OBD_ALLOC(name, length + 1);
+        if (!name) {
+                OBD_GREE(tmp_opt, sizeof(*tmp_opt));
+                return -ENOMEM;
+        }
+                
         tmp_opt->opt = name;
         while (opt_left != tmp) *name++ = *opt_left++;
 
         tmp_opt->opt = name;
         while (opt_left != tmp) *name++ = *opt_left++;
 
index 9fe77a6..3d36182 100644 (file)
@@ -66,7 +66,10 @@ static int smfs_init_snap_super_info(struct smfs_super_info *smfs_info)
                 char *snap_cache_ftype = NULL;
                 int   tmp = strlen(smfs_info->smsi_cache_ftype) + strlen("_snap");
                 
                 char *snap_cache_ftype = NULL;
                 int   tmp = strlen(smfs_info->smsi_cache_ftype) + strlen("_snap");
                 
-                OBD_ALLOC(snap_cache_ftype, tmp + 1);  
+                OBD_ALLOC(snap_cache_ftype, tmp + 1);
+                if (!snap_cache_ftype)
+                        GOTO(exit, rc = -ENOMEM);
+                        
                 sprintf(snap_cache_ftype, "%s_snap", smfs_info->smsi_cache_ftype);
                 snap_sinfo->snap_cache_fsfilt = fsfilt_get_ops(snap_cache_ftype);
                 OBD_FREE(snap_cache_ftype, tmp + 1);
                 sprintf(snap_cache_ftype, "%s_snap", smfs_info->smsi_cache_ftype);
                 snap_sinfo->snap_cache_fsfilt = fsfilt_get_ops(snap_cache_ftype);
                 OBD_FREE(snap_cache_ftype, tmp + 1);
@@ -81,6 +84,9 @@ static int smfs_init_snap_super_info(struct smfs_super_info *smfs_info)
                 int   tmp = strlen(smfs_info->smsi_ftype) + strlen("_snap");
                 
                 OBD_ALLOC(snap_ftype, tmp + 1);  
                 int   tmp = strlen(smfs_info->smsi_ftype) + strlen("_snap");
                 
                 OBD_ALLOC(snap_ftype, tmp + 1);  
+                if (!snap_ftype)
+                        GOTO(exit, rc = -ENOMEM);
+
                 sprintf(snap_ftype, "%s_snap", smfs_info->smsi_ftype);
                 snap_sinfo->snap_fsfilt = fsfilt_get_ops(snap_ftype);
                 OBD_FREE(snap_ftype, tmp + 1);
                 sprintf(snap_ftype, "%s_snap", smfs_info->smsi_ftype);
                 snap_sinfo->snap_fsfilt = fsfilt_get_ops(snap_ftype);
                 OBD_FREE(snap_ftype, tmp + 1);
index 4f7a59a..9057928 100644 (file)
@@ -280,9 +280,9 @@ static int smfs_mount_cache(struct smfs_super_info *smb, char *devstr,
         
         mnt = do_kern_mount(typestr, 0, devstr, (void *)opts);
         if (IS_ERR(mnt)) {
         
         mnt = do_kern_mount(typestr, 0, devstr, (void *)opts);
         if (IS_ERR(mnt)) {
-                CERROR("do_kern_mount failed: rc = %ld\n", 
-                       PTR_ERR(mnt));
-                GOTO(err_out, err = PTR_ERR(mnt));
+                CERROR("do_kern_mount failed: rc = %d\n", 
+                       (int)PTR_ERR(mnt));
+                RETURN(PTR_ERR(mnt));
         }
 
         smb->smsi_sb = mnt->mnt_sb;
         }
 
         smb->smsi_sb = mnt->mnt_sb;
@@ -291,36 +291,53 @@ static int smfs_mount_cache(struct smfs_super_info *smb, char *devstr,
         smfs_init_sm_ops(smb);
 
         OBD_ALLOC(smb->smsi_cache_ftype, strlen(typestr) + 1);
         smfs_init_sm_ops(smb);
 
         OBD_ALLOC(smb->smsi_cache_ftype, strlen(typestr) + 1);
+        if (!smb->smsi_cache_ftype)
+                GOTO(err_umount_cache, err = -ENOMEM);
+
         memcpy(smb->smsi_cache_ftype, typestr, strlen(typestr));
 
         OBD_ALLOC(smb->smsi_ftype, strlen(SMFS_TYPE) + 1);
         memcpy(smb->smsi_cache_ftype, typestr, strlen(typestr));
 
         OBD_ALLOC(smb->smsi_ftype, strlen(SMFS_TYPE) + 1);
+        if (!smb->smsi_ftype)
+                GOTO(err_free_cache_fstype, err = -ENOMEM);
+        
         memcpy(smb->smsi_ftype, SMFS_TYPE, strlen(SMFS_TYPE));
         
         err = smfs_init_fsfilt_ops(smb);
         memcpy(smb->smsi_ftype, SMFS_TYPE, strlen(SMFS_TYPE));
         
         err = smfs_init_fsfilt_ops(smb);
-err_out:
         RETURN(err);
         RETURN(err);
+err_free_cache_fstype:
+        OBD_FREE(smb->smsi_cache_ftype, strlen(typestr) + 1);
+err_umount_cache:
+        mntput(mnt);
+err_out:
+        return err;
 }
 
 static int smfs_umount_cache(struct smfs_super_info *smb)
 {
 }
 
 static int smfs_umount_cache(struct smfs_super_info *smb)
 {
+        ENTRY;
+        
         mntput(smb->smsi_mnt);
         smfs_cleanup_sm_ops(smb);
         smfs_cleanup_fsfilt_ops(smb);
 
         mntput(smb->smsi_mnt);
         smfs_cleanup_sm_ops(smb);
         smfs_cleanup_fsfilt_ops(smb);
 
-        if (smb->smsi_cache_ftype)
+        if (smb->smsi_cache_ftype) {
                 OBD_FREE(smb->smsi_cache_ftype,
                          strlen(smb->smsi_cache_ftype) + 1);
                 OBD_FREE(smb->smsi_cache_ftype,
                          strlen(smb->smsi_cache_ftype) + 1);
-        if (smb->smsi_ftype)
-                OBD_FREE(smb->smsi_ftype, strlen(smb->smsi_ftype) + 1);
-               
-        return 0;
+                smb->smsi_cache_ftype = NULL;
+        }
+        if (smb->smsi_ftype) {
+                OBD_FREE(smb->smsi_ftype,
+                         strlen(smb->smsi_ftype) + 1);
+                smb->smsi_ftype = NULL;
+        }
+
+        RETURN(0);
 }
 
 /* This function initializes plugins in SMFS 
  * @flags: are filled while options parsing 
  * @sb: smfs super block
  */
 }
 
 /* This function initializes plugins in SMFS 
  * @flags: are filled while options parsing 
  * @sb: smfs super block
  */
-
 static int smfs_init_plugins(struct super_block * sb, int flags)
 {
         struct smfs_super_info * smb = S2SMI(sb);
 static int smfs_init_plugins(struct super_block * sb, int flags)
 {
         struct smfs_super_info * smb = S2SMI(sb);