Whamcloud - gitweb
LU-911 obdclass: la_from_obdo helper
authorAlex Zhuravlev <bzzz@whamcloud.com>
Fri, 25 Nov 2011 07:39:49 +0000 (10:39 +0300)
committerOleg Drokin <green@whamcloud.com>
Fri, 6 Apr 2012 05:29:46 +0000 (01:29 -0400)
- OFD will need la_from_obdo() conversion.
- Fix obdo_from_la() to work with la flags.
- Call obdo_set_parent_fid() directly when needed instead of
  using obdo_from_inode() just to update parent fid
- Make obdo_from_inode() consistent with its name and don't
  update parent FID from.

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: Ib1a7d0a4a3e19434ae48c74b06b153d2fc5e5d78
Signed-off-by: Mikhail Pershin <tappro@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/1848
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Tested-by: Hudson
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
12 files changed:
lustre/include/linux/obd_class.h
lustre/include/obd.h
lustre/lclient/lcommon_cl.c
lustre/liblustre/file.c
lustre/liblustre/super.c
lustre/llite/file.c
lustre/llite/llite_lib.c
lustre/mdd/mdd_lov.c
lustre/obdclass/linux/linux-obdo.c
lustre/obdclass/obdo.c
lustre/obdfilter/filter.c
lustre/obdfilter/filter_io_26.c

index 8f027dc..a6760b6 100644 (file)
@@ -81,7 +81,8 @@ int ldiskfsfs_dirhash(const char *name, int len, struct ldiskfs_dx_hash_info *hi
 
 /* obdo.c */
 #ifdef __KERNEL__
-void obdo_from_la(struct obdo *dst, struct lu_attr *la, obd_flag valid);
+void obdo_from_la(struct obdo *dst, struct lu_attr *la, __u64 valid);
+void la_from_obdo(struct lu_attr *la, struct obdo *dst, obd_flag valid);
 void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_flag valid);
 void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid);
 #define ll_inode_flags(inode)         (inode->i_flags)
index a340d4f..b579fca 100644 (file)
@@ -1727,8 +1727,8 @@ static inline struct md_open_data *obd_mod_alloc(void)
         }                                                       \
 })
 
-extern void obdo_from_inode(struct obdo *dst, struct inode *src,
-                            struct lu_fid *parent, obd_flag valid);
+void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid);
+void obdo_set_parent_fid(struct obdo *dst, const struct lu_fid *parent);
 
 /* return 1 if client should be resend request */
 static inline int client_should_resend(int resend, struct client_obd *cli)
index e767c02..9afb985 100644 (file)
@@ -1000,8 +1000,8 @@ void ccc_req_attr_set(const struct lu_env *env,
                                 OBD_MD_FLUID|OBD_MD_FLGID;
                 }
         }
-        obdo_from_inode(oa, inode, &cl_i2info(inode)->lli_fid,
-                        valid_flags & flags);
+        obdo_from_inode(oa, inode, valid_flags & flags);
+        obdo_set_parent_fid(oa, &cl_i2info(inode)->lli_fid);
 }
 
 const struct cl_req_operations ccc_req_ops = {
index 3d63f26..f7618b3 100644 (file)
@@ -290,8 +290,7 @@ int llu_objects_destroy(struct ptlrpc_request *req, struct inode *dir)
         oa->o_seq = lsm->lsm_object_seq;
         oa->o_mode = body->mode & S_IFMT;
         oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLGROUP;
-        obdo_from_inode(oa, NULL, &llu_i2info(dir)->lli_fid, 0);
-
+        obdo_set_parent_fid(oa, &llu_i2info(dir)->lli_fid);
         if (body->valid & OBD_MD_FLCOOKIE) {
                 oa->o_valid |= OBD_MD_FLCOOKIE;
                 oti.oti_logcookies =
index 8d03a8e..9f474bc 100644 (file)
@@ -289,7 +289,7 @@ int llu_inode_getattr(struct inode *inode, struct obdo *obdo,
                                OBD_MD_FLBLKSZ | OBD_MD_FLMTIME |
                                OBD_MD_FLCTIME | OBD_MD_FLGROUP |
                                OBD_MD_FLATIME | OBD_MD_FLEPOCH;
-        obdo_from_inode(oinfo.oi_oa, NULL, &llu_i2info(inode)->lli_fid, 0);
+        obdo_set_parent_fid(oinfo.oi_oa, &llu_i2info(inode)->lli_fid);
         if (sync) {
                 oinfo.oi_oa->o_valid |= OBD_MD_FLFLAGS;
                 oinfo.oi_oa->o_flags |= OBD_FL_SRVLOCK;
index 4282d49..3027d1d 100644 (file)
@@ -1249,8 +1249,9 @@ static int ll_lov_recreate(struct inode *inode, obd_id id, obd_seq seq,
         oa->o_nlink = ost_idx;
         oa->o_flags |= OBD_FL_RECREATE_OBJS;
         oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS | OBD_MD_FLGROUP;
-        obdo_from_inode(oa, inode, &ll_i2info(inode)->lli_fid, OBD_MD_FLTYPE |
-                        OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME);
+        obdo_from_inode(oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
+                                   OBD_MD_FLMTIME | OBD_MD_FLCTIME);
+        obdo_set_parent_fid(oa, &ll_i2info(inode)->lli_fid);
         memcpy(lsm2, lsm, lsm_size);
         rc = obd_create(exp, oa, &lsm2, &oti);
 
@@ -1641,8 +1642,8 @@ int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap,
         fm_key.oa.o_seq = lsm->lsm_object_seq;
         fm_key.oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
 
-        obdo_from_inode(&fm_key.oa, inode, &ll_i2info(inode)->lli_fid,
-                        OBD_MD_FLSIZE);
+        obdo_from_inode(&fm_key.oa, inode, OBD_MD_FLSIZE);
+        obdo_set_parent_fid(&fm_key.oa, &ll_i2info(inode)->lli_fid);
         /* If filesize is 0, then there would be no objects for mapping */
         if (fm_key.oa.o_size == 0) {
                 fiemap->fm_mapped_extents = 0;
@@ -2048,10 +2049,11 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data)
                 oinfo->oi_oa->o_id = lsm->lsm_object_id;
                 oinfo->oi_oa->o_seq = lsm->lsm_object_seq;
                 oinfo->oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
-                obdo_from_inode(oinfo->oi_oa, inode, &ll_i2info(inode)->lli_fid,
+                obdo_from_inode(oinfo->oi_oa, inode,
                                 OBD_MD_FLTYPE | OBD_MD_FLATIME |
                                 OBD_MD_FLMTIME | OBD_MD_FLCTIME |
                                 OBD_MD_FLGROUP);
+                obdo_set_parent_fid(oinfo->oi_oa, &ll_i2info(inode)->lli_fid);
                 oinfo->oi_md = lsm;
                 oinfo->oi_capa = ll_osscapa_get(inode, CAPA_OPC_OSS_WRITE);
                 err = obd_sync_rqset(ll_i2sbi(inode)->ll_dt_exp, oinfo, 0,
index 76bc5d0..13ba855 100644 (file)
@@ -1929,8 +1929,7 @@ int ll_iocontrol(struct inode *inode, struct file *file,
                 oinfo.oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS |
                                        OBD_MD_FLGROUP;
                 oinfo.oi_capa = ll_mdscapa_get(inode);
-                obdo_from_inode(oinfo.oi_oa, inode,
-                                &ll_i2info(inode)->lli_fid, 0);
+                obdo_set_parent_fid(oinfo.oi_oa, &ll_i2info(inode)->lli_fid);
                 rc = obd_setattr_rqset(sbi->ll_dt_exp, &oinfo, NULL);
                 capa_put(oinfo.oi_capa);
                 OBDO_FREE(oinfo.oi_oa);
index 56691e1..ad6d8da 100644 (file)
@@ -536,16 +536,14 @@ int mdd_lov_create(const struct lu_env *env, struct mdd_device *mdd,
 
                 /* When setting attr to ost, FLBKSZ is not needed. */
                 oa->o_valid &= ~OBD_MD_FLBLKSZ;
-                obdo_from_la(oa, la, OBD_MD_FLTYPE | OBD_MD_FLATIME |
-                             OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLSIZE);
-
+                obdo_from_la(oa, la, LA_TYPE | LA_ATIME | LA_MTIME |
+                                     LA_CTIME | LA_SIZE);
                 /*
                  * XXX: Pack lustre id to OST, in OST, it will be packed by
                  * filter_fid, but can not see what is the usages. So just pack
                  * o_seq o_ver here, maybe fix it after this cycle.
                  */
-                obdo_from_inode(oa, NULL,
-                                (struct lu_fid *)mdd_object_fid(child), 0);
+                obdo_set_parent_fid(oa, mdd_object_fid(child));
                 oinfo->oi_oa = oa;
                 oinfo->oi_md = lsm;
                 oinfo->oi_capa = NULL;
@@ -857,7 +855,7 @@ static int mdd_osc_setattr_async(struct obd_device *obd, __u32 uid, __u32 gid,
                 oti.oti_logcookies = logcookies;
         }
 
-        obdo_from_inode(oinfo.oi_oa, NULL, (struct lu_fid *)parent, 0);
+        obdo_set_parent_fid(oinfo.oi_oa, parent);
         oinfo.oi_capa = oc;
 
         /* do async setattr from mds to ost not waiting for responses. */
index 9007833..3e7f77b 100644 (file)
 #include <linux/pagemap.h> /* for PAGE_CACHE_SIZE */
 
 /*FIXME: Just copy from obdo_from_inode*/
-void obdo_from_la(struct obdo *dst, struct lu_attr *la, obd_flag valid)
+void obdo_from_la(struct obdo *dst, struct lu_attr *la, __u64 valid)
 {
         obd_flag newvalid = 0;
 
-        if (valid & OBD_MD_FLATIME) {
+        if (valid & LA_ATIME) {
                 dst->o_atime = la->la_atime;
                 newvalid |= OBD_MD_FLATIME;
         }
-        if (valid & OBD_MD_FLMTIME) {
+        if (valid & LA_MTIME) {
                 dst->o_mtime = la->la_mtime;
                 newvalid |= OBD_MD_FLMTIME;
         }
-        if (valid & OBD_MD_FLCTIME) {
+        if (valid & LA_CTIME) {
                 dst->o_ctime = la->la_ctime;
                 newvalid |= OBD_MD_FLCTIME;
         }
-        if (valid & OBD_MD_FLSIZE) {
+        if (valid & LA_SIZE) {
                 dst->o_size = la->la_size;
                 newvalid |= OBD_MD_FLSIZE;
         }
-        if (valid & OBD_MD_FLBLOCKS) {  /* allocation of space (x512 bytes) */
+        if (valid & LA_BLOCKS) {  /* allocation of space (x512 bytes) */
                 dst->o_blocks = la->la_blocks;
                 newvalid |= OBD_MD_FLBLOCKS;
         }
-        if (valid & OBD_MD_FLTYPE) {
-                dst->o_mode = (dst->o_mode & S_IALLUGO)|(la->la_mode & S_IFMT);
+        if (valid & LA_TYPE) {
+                dst->o_mode = (dst->o_mode & S_IALLUGO) |
+                              (la->la_mode & S_IFMT);
                 newvalid |= OBD_MD_FLTYPE;
         }
-        if (valid & OBD_MD_FLMODE) {
-                dst->o_mode = (dst->o_mode & S_IFMT)|(la->la_mode & S_IALLUGO);
+        if (valid & LA_MODE) {
+                dst->o_mode = (dst->o_mode & S_IFMT) |
+                              (la->la_mode & S_IALLUGO);
                 newvalid |= OBD_MD_FLMODE;
         }
-        if (valid & OBD_MD_FLUID) {
+        if (valid & LA_UID) {
                 dst->o_uid = la->la_uid;
                 newvalid |= OBD_MD_FLUID;
         }
-        if (valid & OBD_MD_FLGID) {
+        if (valid & LA_GID) {
                 dst->o_gid = la->la_gid;
                 newvalid |= OBD_MD_FLGID;
         }
@@ -102,6 +104,55 @@ void obdo_from_la(struct obdo *dst, struct lu_attr *la, obd_flag valid)
 }
 EXPORT_SYMBOL(obdo_from_la);
 
+/*FIXME: Just copy from obdo_from_inode*/
+void la_from_obdo(struct lu_attr *dst, struct obdo *obdo, obd_flag valid)
+{
+        __u64 newvalid = 0;
+
+        valid &= obdo->o_valid;
+
+        if (valid & OBD_MD_FLATIME) {
+                dst->la_atime = obdo->o_atime;
+                newvalid |= LA_ATIME;
+        }
+        if (valid & OBD_MD_FLMTIME) {
+                dst->la_mtime = obdo->o_mtime;
+                newvalid |= LA_MTIME;
+        }
+        if (valid & OBD_MD_FLCTIME) {
+                dst->la_ctime = obdo->o_ctime;
+                newvalid |= LA_CTIME;
+        }
+        if (valid & OBD_MD_FLSIZE) {
+                dst->la_size = obdo->o_size;
+                newvalid |= LA_SIZE;
+        }
+        if (valid & OBD_MD_FLBLOCKS) {
+                dst->la_blocks = obdo->o_blocks;
+                newvalid |= LA_BLOCKS;
+        }
+        if (valid & OBD_MD_FLTYPE) {
+                dst->la_mode = (dst->la_mode & S_IALLUGO) |
+                               (obdo->o_mode & S_IFMT);
+                newvalid |= LA_TYPE;
+        }
+        if (valid & OBD_MD_FLMODE) {
+                dst->la_mode = (dst->la_mode & S_IFMT) |
+                               (obdo->o_mode & S_IALLUGO);
+                newvalid |= LA_MODE;
+        }
+        if (valid & OBD_MD_FLUID) {
+                dst->la_uid = obdo->o_uid;
+                newvalid |= LA_UID;
+        }
+        if (valid & OBD_MD_FLGID) {
+                dst->la_gid = obdo->o_gid;
+                newvalid |= LA_GID;
+        }
+        dst->la_valid = newvalid;
+}
+EXPORT_SYMBOL(la_from_obdo);
+
 void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_flag valid)
 {
         valid &= src->o_valid;
index 390c234..8213798 100644 (file)
 #include <lustre/lustre_idl.h>
 #endif
 
-static void obdo_set_parent_fid(struct obdo *dst, struct lu_fid *parent)
+void obdo_set_parent_fid(struct obdo *dst, const struct lu_fid *parent)
 {
         dst->o_parent_oid = fid_oid(parent);
         dst->o_parent_seq = fid_seq(parent);
         dst->o_parent_ver = fid_ver(parent);
         dst->o_valid |= OBD_MD_FLGENER | OBD_MD_FLFID;
 }
+EXPORT_SYMBOL(obdo_set_parent_fid);
 
 /* WARNING: the file systems must take care not to tinker with
    attributes they don't manage (such as blocks). */
-void obdo_from_inode(struct obdo *dst, struct inode *src, struct lu_fid *parent,
-                     obd_flag valid)
+void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid)
 {
         obd_flag newvalid = 0;
 
@@ -120,8 +120,6 @@ void obdo_from_inode(struct obdo *dst, struct inode *src, struct lu_fid *parent,
                 dst->o_flags = ll_inode_flags(src);
                 newvalid |= OBD_MD_FLFLAGS;
         }
-        if (parent)
-                obdo_set_parent_fid(dst, parent);
         dst->o_valid |= newvalid;
 }
 EXPORT_SYMBOL(obdo_from_inode);
index 984defe..ab8896f 100644 (file)
@@ -3181,7 +3181,7 @@ static int filter_getattr(struct obd_export *exp, struct obd_info *oinfo)
 
         /* Limit the valid bits in the return data to what we actually use */
         oinfo->oi_oa->o_valid = OBD_MD_FLID;
-        obdo_from_inode(oinfo->oi_oa, dentry->d_inode, NULL, FILTER_VALID_FLAGS);
+        obdo_from_inode(oinfo->oi_oa, dentry->d_inode, FILTER_VALID_FLAGS);
 
         /* Store inode version in reply */
         curr_version = fsfilt_get_version(exp->exp_obd, dentry->d_inode);
@@ -3505,7 +3505,7 @@ int filter_setattr(struct obd_export *exp, struct obd_info *oinfo,
         oa->o_valid = OBD_MD_FLID;
 
         /* Quota release need uid/gid info */
-        obdo_from_inode(oa, dentry->d_inode, NULL,
+        obdo_from_inode(oa, dentry->d_inode,
                         FILTER_VALID_FLAGS | OBD_MD_FLUID | OBD_MD_FLGID);
 
         EXIT;
@@ -4268,7 +4268,7 @@ int filter_destroy(struct obd_export *exp, struct obdo *oa,
         cleanup_phase = 4; /* fsfilt_commit */
 
         /* Quota release need uid/gid of inode */
-        obdo_from_inode(oa, dchild->d_inode, NULL, OBD_MD_FLUID|OBD_MD_FLGID);
+        obdo_from_inode(oa, dchild->d_inode, OBD_MD_FLUID | OBD_MD_FLGID);
 
         filter_fmd_drop(exp, oa->o_id, oa->o_seq);
 
@@ -4400,8 +4400,7 @@ static int filter_sync(struct obd_export *exp, struct obd_info *oinfo,
         UNLOCK_INODE_MUTEX(dentry->d_inode);
 
         oinfo->oi_oa->o_valid = OBD_MD_FLID;
-        obdo_from_inode(oinfo->oi_oa, dentry->d_inode, NULL,
-                        FILTER_VALID_FLAGS);
+        obdo_from_inode(oinfo->oi_oa, dentry->d_inode, FILTER_VALID_FLAGS);
 
         pop_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, NULL);
 
index c03ff78..896fa0d 100644 (file)
@@ -768,8 +768,8 @@ retry:
                 goto retry;
         }
 
-        obdo_from_inode(oa, inode, NULL, rc == 0 ? FILTER_VALID_FLAGS : 0 |
-                                                   OBD_MD_FLUID |OBD_MD_FLGID);
+        obdo_from_inode(oa, inode, (rc == 0 ? FILTER_VALID_FLAGS : 0) |
+                                   OBD_MD_FLUID | OBD_MD_FLGID);
 
         lquota_getflag(filter_quota_interface_ref, obd, oa);