Whamcloud - gitweb
land b_gns onto HEAD. If you are working on CMD, you MUST UPDATE YOUR
[fs/lustre-release.git] / lustre / obdclass / obdo.c
index 493e829..4e8e244 100644 (file)
  */
 
 #define DEBUG_SUBSYSTEM S_CLASS
-#define EXPORT_SYMTAB
+#ifndef EXPORT_SYMTAB
+# define EXPORT_SYMTAB
+#endif
 
+#ifndef __KERNEL__
+#include <liblustre.h>
+#else
 #include <linux/module.h>
 #include <linux/obd_class.h>
 #include <linux/lustre_idl.h>
+#endif
 
 #ifdef __KERNEL__
 #include <linux/fs.h>
+#include <linux/pagemap.h> /* for PAGE_CACHE_SIZE */
 
 void obdo_from_iattr(struct obdo *oa, struct iattr *attr, unsigned int ia_valid)
 {
@@ -114,6 +121,10 @@ void iattr_from_obdo(struct iattr *attr, struct obdo *oa, obd_flag valid)
                 attr->ia_gid = oa->o_gid;
                 attr->ia_valid |= ATTR_GID;
         }
+        if (valid & OBD_MD_FLFLAGS) {
+                attr->ia_attr_flags = oa->o_flags;
+                attr->ia_valid |= ATTR_ATTR_FLAG;
+        }
 }
 EXPORT_SYMBOL(iattr_from_obdo);
 
@@ -125,7 +136,8 @@ void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid)
 
         if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
                 CDEBUG(D_INODE, "valid %x, new time %lu/%lu\n",
-                       valid, src->i_mtime, src->i_ctime);
+                       valid, LTIME_S(src->i_mtime), 
+                       LTIME_S(src->i_ctime));
 
         if (valid & OBD_MD_FLATIME) {
                 dst->o_atime = LTIME_S(src->i_atime);
@@ -171,18 +183,10 @@ void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid)
                 dst->o_flags = src->i_flags;
                 newvalid |= OBD_MD_FLFLAGS;
         }
-        if (valid & OBD_MD_FLNLINK) {
-                dst->o_nlink = src->i_nlink;
-                newvalid |= OBD_MD_FLNLINK;
-        }
         if (valid & OBD_MD_FLGENER) {
                 dst->o_generation = src->i_generation;
                 newvalid |= OBD_MD_FLGENER;
         }
-        if (valid & OBD_MD_FLRDEV) {
-                dst->o_rdev = (__u32)kdev_t_to_nr(src->i_rdev);
-                newvalid |= OBD_MD_FLRDEV;
-        }
 
         dst->o_valid |= newvalid;
 }
@@ -194,7 +198,8 @@ void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_flag valid)
 
         if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
                 CDEBUG(D_INODE, "valid %x, cur time %lu/%lu, new %lu/%lu\n",
-                       src->o_valid, dst->i_mtime, dst->i_ctime,
+                       src->o_valid, LTIME_S(dst->i_mtime), 
+                       LTIME_S(dst->i_ctime),
                        (long)src->o_mtime, (long)src->o_ctime);
 
         if (valid & OBD_MD_FLATIME && src->o_atime > LTIME_S(dst->i_atime))
@@ -203,10 +208,13 @@ void obdo_refresh_inode(struct inode *dst, struct obdo *src, obd_flag valid)
                 LTIME_S(dst->i_mtime) = src->o_mtime;
         if (valid & OBD_MD_FLCTIME && src->o_ctime > LTIME_S(dst->i_ctime))
                 LTIME_S(dst->i_ctime) = src->o_ctime;
-        if (valid & OBD_MD_FLSIZE && src->o_size > dst->i_size)
+        if (valid & OBD_MD_FLSIZE
                 dst->i_size = src->o_size;
-        /* Bug 1598: don't ever update i_blksize here; it needs to be managed
-         * by the LOV */
+        /* optimum IO size */
+        if (valid & OBD_MD_FLBLKSZ && src->o_blksize > dst->i_blksize)
+                dst->i_blksize = src->o_blksize;
+        if (dst->i_blksize < PAGE_CACHE_SIZE)
+                dst->i_blksize = PAGE_CACHE_SIZE;
         /* allocation of space */
         if (valid & OBD_MD_FLBLOCKS && src->o_blocks > dst->i_blocks)
                 dst->i_blocks = src->o_blocks;
@@ -219,7 +227,8 @@ void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid)
 
         if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
                 CDEBUG(D_INODE, "valid %x, cur time %lu/%lu, new %lu/%lu\n",
-                       src->o_valid, dst->i_mtime, dst->i_ctime,
+                       src->o_valid, 
+                       LTIME_S(dst->i_mtime), LTIME_S(dst->i_ctime),
                        (long)src->o_mtime, (long)src->o_ctime);
 
         if (valid & OBD_MD_FLATIME)
@@ -244,12 +253,8 @@ void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid)
                 dst->i_gid = src->o_gid;
         if (valid & OBD_MD_FLFLAGS)
                 dst->i_flags = src->o_flags;
-        if (valid & OBD_MD_FLNLINK)
-                dst->i_nlink = src->o_nlink;
         if (valid & OBD_MD_FLGENER)
                 dst->i_generation = src->o_generation;
-        if (valid & OBD_MD_FLRDEV)
-                dst->i_rdev = to_kdev_t(src->o_rdev);
 }
 EXPORT_SYMBOL(obdo_to_inode);
 #endif
@@ -282,21 +287,10 @@ void obdo_cpy_md(struct obdo *dst, struct obdo *src, obd_flag valid)
                 dst->o_gid = src->o_gid;
         if (valid & OBD_MD_FLFLAGS)
                 dst->o_flags = src->o_flags;
-        /*
-        if (valid & OBD_MD_FLOBDFLG)
-                dst->o_obdflags = src->o_obdflags;
-        */
-        if (valid & OBD_MD_FLNLINK)
-                dst->o_nlink = src->o_nlink;
         if (valid & OBD_MD_FLGENER)
                 dst->o_generation = src->o_generation;
-        if (valid & OBD_MD_FLRDEV)
-                dst->o_rdev = src->o_rdev;
-        if (valid & OBD_MD_FLINLINE &&
-             src->o_obdflags & OBD_FL_INLINEDATA) {
+        if (valid & OBD_MD_FLINLINE)
                 memcpy(dst->o_inline, src->o_inline, sizeof(src->o_inline));
-                dst->o_obdflags |= OBD_FL_INLINEDATA;
-        }
 
         dst->o_valid |= valid;
 }
@@ -340,3 +334,14 @@ int obdo_cmp_md(struct obdo *dst, struct obdo *src, obd_flag compare)
         return res;
 }
 EXPORT_SYMBOL(obdo_cmp_md);
+
+void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj)
+{
+        ioobj->ioo_id = oa->o_id;
+        if (oa->o_valid & OBD_MD_FLGROUP)
+                ioobj->ioo_gr = oa->o_gr;
+        else 
+                ioobj->ioo_gr = 0;
+        ioobj->ioo_type = oa->o_mode;
+}
+EXPORT_SYMBOL(obdo_to_ioobj);