Whamcloud - gitweb
LU-2441 mdd: Implement volatile file
[fs/lustre-release.git] / lustre / mdc / mdc_lib.c
index 7f7f775..13d055e 100644 (file)
@@ -132,37 +132,41 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
                      const void *data, int datalen, __u32 mode,
                      __u32 uid, __u32 gid, cfs_cap_t cap_effective, __u64 rdev)
 {
-        struct mdt_rec_create *rec;
-        char                  *tmp;
-
-        CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_create));
-        rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
-
-
-        rec->cr_opcode   = REINT_CREATE;
-        rec->cr_fsuid    = uid;
-        rec->cr_fsgid    = gid;
-        rec->cr_cap      = cap_effective;
-        rec->cr_fid1     = op_data->op_fid1;
-        rec->cr_fid2     = op_data->op_fid2;
-        rec->cr_mode     = mode;
-        rec->cr_rdev     = rdev;
-        rec->cr_time     = op_data->op_mod_time;
-        rec->cr_suppgid1 = op_data->op_suppgids[0];
-        rec->cr_suppgid2 = op_data->op_suppgids[1];
-        set_mrc_cr_flags(rec, op_data->op_flags & MF_SOM_LOCAL_FLAGS);
-        rec->cr_bias     = op_data->op_bias;
-        rec->cr_umask    = cfs_curproc_umask();
-
-        mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
-
-        tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
-        LOGL0(op_data->op_name, op_data->op_namelen, tmp);
-
-        if (data) {
-                tmp = req_capsule_client_get(&req->rq_pill, &RMF_EADATA);
-                memcpy(tmp, data, datalen);
-        }
+       struct mdt_rec_create   *rec;
+       char                    *tmp;
+       __u64                    flags;
+
+       CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_create));
+       rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
+
+
+       rec->cr_opcode   = REINT_CREATE;
+       rec->cr_fsuid    = uid;
+       rec->cr_fsgid    = gid;
+       rec->cr_cap      = cap_effective;
+       rec->cr_fid1     = op_data->op_fid1;
+       rec->cr_fid2     = op_data->op_fid2;
+       rec->cr_mode     = mode;
+       rec->cr_rdev     = rdev;
+       rec->cr_time     = op_data->op_mod_time;
+       rec->cr_suppgid1 = op_data->op_suppgids[0];
+       rec->cr_suppgid2 = op_data->op_suppgids[1];
+       flags = op_data->op_flags & MF_SOM_LOCAL_FLAGS;
+       if (op_data->op_bias & MDS_CREATE_VOLATILE)
+               flags |= MDS_OPEN_VOLATILE;
+       set_mrc_cr_flags(rec, flags);
+       rec->cr_bias     = op_data->op_bias;
+       rec->cr_umask    = cfs_curproc_umask();
+
+       mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
+
+       tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
+       LOGL0(op_data->op_name, op_data->op_namelen, tmp);
+
+       if (data) {
+               tmp = req_capsule_client_get(&req->rq_pill, &RMF_EADATA);
+               memcpy(tmp, data, datalen);
+       }
 }
 
 static __u64 mds_pack_open_flags(__u32 flags, __u32 mode)
@@ -198,53 +202,55 @@ static __u64 mds_pack_open_flags(__u32 flags, __u32 mode)
 
 /* packing of MDS records */
 void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
-                   __u32 mode, __u64 rdev, __u32 flags, const void *lmm,
-                   int lmmlen)
+                  __u32 mode, __u64 rdev, __u32 flags, const void *lmm,
+                  int lmmlen)
 {
-        struct mdt_rec_create *rec;
-        char *tmp;
-        __u64 cr_flags;
-
-        CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_create));
-        rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
-
-        /* XXX do something about time, uid, gid */
-        rec->cr_opcode   = REINT_OPEN;
-        rec->cr_fsuid   = cfs_curproc_fsuid();
-        rec->cr_fsgid   = cfs_curproc_fsgid();
-        rec->cr_cap      = cfs_curproc_cap_pack();
-        if (op_data != NULL) {
-                rec->cr_fid1 = op_data->op_fid1;
-                rec->cr_fid2 = op_data->op_fid2;
-        }
-        rec->cr_mode     = mode;
-        cr_flags = mds_pack_open_flags(flags, mode);
-        rec->cr_rdev     = rdev;
-        rec->cr_time     = op_data->op_mod_time;
-        rec->cr_suppgid1 = op_data->op_suppgids[0];
-        rec->cr_suppgid2 = op_data->op_suppgids[1];
-        rec->cr_bias     = op_data->op_bias;
-        rec->cr_umask    = cfs_curproc_umask();
-
-        mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
-        /* the next buffer is child capa, which is used for replay,
-         * will be packed from the data in reply message. */
-
-        if (op_data->op_name) {
-                tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
-                LOGL0(op_data->op_name, op_data->op_namelen, tmp);
-        }
-
-        if (lmm) {
-                cr_flags |= MDS_OPEN_HAS_EA;
+       struct mdt_rec_create *rec;
+       char *tmp;
+       __u64 cr_flags;
+
+       CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_create));
+       rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
+
+       /* XXX do something about time, uid, gid */
+       rec->cr_opcode   = REINT_OPEN;
+       rec->cr_fsuid   = cfs_curproc_fsuid();
+       rec->cr_fsgid   = cfs_curproc_fsgid();
+       rec->cr_cap      = cfs_curproc_cap_pack();
+       if (op_data != NULL) {
+               rec->cr_fid1 = op_data->op_fid1;
+               rec->cr_fid2 = op_data->op_fid2;
+       }
+       rec->cr_mode     = mode;
+       cr_flags = mds_pack_open_flags(flags, mode);
+       rec->cr_rdev     = rdev;
+       rec->cr_time     = op_data->op_mod_time;
+       rec->cr_suppgid1 = op_data->op_suppgids[0];
+       rec->cr_suppgid2 = op_data->op_suppgids[1];
+       rec->cr_bias     = op_data->op_bias;
+       rec->cr_umask    = cfs_curproc_umask();
+
+       mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
+       /* the next buffer is child capa, which is used for replay,
+        * will be packed from the data in reply message. */
+
+       if (op_data->op_name) {
+               tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
+               LOGL0(op_data->op_name, op_data->op_namelen, tmp);
+               if (op_data->op_bias & MDS_CREATE_VOLATILE)
+                       cr_flags |= MDS_OPEN_VOLATILE;
+       }
+
+       if (lmm) {
+               cr_flags |= MDS_OPEN_HAS_EA;
 #ifndef __KERNEL__
-                /*XXX a hack for liblustre to set EA (LL_IOC_LOV_SETSTRIPE) */
-                rec->cr_fid2 = op_data->op_fid2;
+               /*XXX a hack for liblustre to set EA (LL_IOC_LOV_SETSTRIPE) */
+               rec->cr_fid2 = op_data->op_fid2;
 #endif
-                tmp = req_capsule_client_get(&req->rq_pill, &RMF_EADATA);
-                memcpy (tmp, lmm, lmmlen);
-        }
-        set_mrc_cr_flags(rec, cr_flags);
+               tmp = req_capsule_client_get(&req->rq_pill, &RMF_EADATA);
+               memcpy(tmp, lmm, lmmlen);
+       }
+       set_mrc_cr_flags(rec, cr_flags);
 }
 
 static inline __u64 attr_pack(unsigned int ia_valid) {