Whamcloud - gitweb
Branch: HEAD
[fs/lustre-release.git] / lustre / liblustre / super.c
index 211be83..1215f38 100644 (file)
 # include <sys/statfs.h>
 #endif
 
-#include <fs.h>
+#ifdef HAVE_XTIO_H
+#include <xtio.h>
+#endif
 #include <sysio.h>
 #include <mount.h>
 #include <inode.h>
+#include <fs.h>
+#ifdef HAVE_FILE_H
 #include <file.h>
+#endif
 
 #undef LIST_HEAD
 #include "llite_lib.h"
@@ -84,9 +89,10 @@ static int ll_permission(struct inode *inode, int mask)
 
 static void llu_fsop_gone(struct filesys *fs)
 {
-        struct llu_sb_info *sbi = (struct llu_sb_info *) fs->fs_private;
+        struct llu_sb_info *sbi = (struct llu_sb_info *)fs->fs_private;
         struct obd_device *obd = class_exp2obd(sbi->ll_md_exp);
-        struct lustre_cfg lcfg;
+        struct lustre_cfg_bufs bufs;
+        struct lustre_cfg *lcfg;
         int next = 0;
         ENTRY;
 
@@ -97,15 +103,17 @@ static void llu_fsop_gone(struct filesys *fs)
         while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL)
         {
                 int err;
-
-                LCFG_INIT(lcfg, LCFG_CLEANUP, obd->obd_name);
-                err = class_process_config(&lcfg);
+        
+                lustre_cfg_bufs_reset(&bufs, obd->obd_name);
+                lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs);
+                err = class_process_config(lcfg);
                 if (err) {
                         CERROR("cleanup failed: %s\n", obd->obd_name);
                 }
-
-                LCFG_INIT(lcfg, LCFG_DETACH, obd->obd_name);
-                err = class_process_config(&lcfg);
+                
+                lcfg->lcfg_command = LCFG_DETACH; 
+                err = class_process_config(lcfg);
+                lustre_cfg_free(lcfg);
                 if (err) {
                         CERROR("detach failed: %s\n", obd->obd_name);
                 }
@@ -181,7 +189,7 @@ void obdo_to_inode(struct inode *dst, struct obdo *src, obd_valid valid)
         valid &= src->o_valid;
 
         if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
-                CDEBUG(D_INODE, "valid %x, cur time %lu/%lu, new %lu/%lu\n",
+                CDEBUG(D_INODE, "valid "LPX64", cur time %lu/%lu, new %lu/%lu\n",
                        src->o_valid, 
                        LTIME_S(lli->lli_st_mtime), LTIME_S(lli->lli_st_ctime),
                        (long)src->o_mtime, (long)src->o_ctime);
@@ -221,7 +229,7 @@ void obdo_from_inode(struct obdo *dst, struct inode *src, obd_valid valid)
         obd_valid newvalid = 0;
 
         if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
-                CDEBUG(D_INODE, "valid %x, new time %lu/%lu\n",
+                CDEBUG(D_INODE, "valid "LPX64", new time %lu/%lu\n",
                        valid, LTIME_S(lli->lli_st_mtime), 
                        LTIME_S(lli->lli_st_ctime));
 
@@ -338,10 +346,11 @@ int llu_inode_getattr(struct inode *inode, struct lov_stripe_md *lsm)
         RETURN(0);
 }
 
-static struct inodellu_new_inode(struct filesys *fs,
+static struct inode *llu_new_inode(struct filesys *fs,
                                    struct lustre_id *id)
 {
        struct inode *inode;
+        struct intnl_stat stat;
         struct llu_inode_info *lli;
 
         OBD_ALLOC(lli, sizeof(*lli));
@@ -361,15 +370,13 @@ static struct inode* llu_new_inode(struct filesys *fs,
 
         memcpy(&lli->lli_id, id, sizeof(*id));
 
+#warning "fill @stat by desired attributes of new inode before using_sysio_i_new()"
+        memset(&stat, 0, sizeof(stat));
+        stat.st_ino = id_ino(id);
+        
         /* file identifier is needed by functions like _sysio_i_find() */
        inode = _sysio_i_new(fs, &lli->lli_sysio_fid,
-#ifndef AUTOMOUNT_FILE_NAME
-                            id->li_stc.u.e3s.l3s_type & S_IFMT,
-#else
-                            id->li_stc.u.e3s.l3s_type, /* all of the bits! */
-#endif
-                             0, 0,
-                            &llu_inode_ops, lli);
+                             &stat, 0, &llu_inode_ops, lli);
 
        if (!inode)
                OBD_FREE(lli, sizeof(*lli));
@@ -438,7 +445,10 @@ static int llu_inode_revalidate(struct inode *inode)
                         valid |= OBD_MD_FLEASIZE;
                 }
                 ll_inode2id(&id, inode);
-                rc = mdc_getattr(sbi->ll_md_exp, &id, valid, ealen, &req);
+
+                /* XXX: capa is NULL here, is it correct? */
+                rc = mdc_getattr(sbi->ll_md_exp, &id, valid, NULL, NULL,
+                                 0, ealen, NULL, &req);
                 if (rc) {
                         CERROR("failure %d inode %lu\n", rc, lli->lli_st_ino);
                         RETURN(-abs(rc));
@@ -480,10 +490,9 @@ static int llu_inode_revalidate(struct inode *inode)
         RETURN(llu_glimpse_size(inode));
 }
 
-static void copy_stat_buf(struct inode *ino, struct intnl_stat *b)
+static void copy_stat_buf_lli(struct llu_inode_info *lli,
+                              struct intnl_stat *b)
 {
-        struct llu_inode_info *lli = llu_i2info(ino);
-
         b->st_dev = lli->lli_st_dev;
         b->st_ino = lli->lli_st_ino;
         b->st_mode = lli->lli_st_mode;
@@ -499,6 +508,12 @@ static void copy_stat_buf(struct inode *ino, struct intnl_stat *b)
         b->st_ctime = lli->lli_st_ctime;
 }
 
+static void copy_stat_buf(struct inode *ino, struct intnl_stat *b)
+{
+        struct llu_inode_info *lli = llu_i2info(ino);
+        copy_stat_buf_lli(lli, b);
+}
+
 static int llu_iop_getattr(struct pnode *pno,
                            struct inode *ino,
                            struct intnl_stat *b)
@@ -681,7 +696,7 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr)
                 llu_prepare_mdc_data(&op_data, inode, NULL, NULL, 0, 0);
 
                 rc = mdc_setattr(sbi->ll_md_exp, &op_data,
-                                 attr, NULL, 0, NULL, 0, &request);
+                                 attr, NULL, 0, NULL, 0, NULL, 0, &request);
                 
                 if (rc) {
                         ptlrpc_req_finished(request);
@@ -768,7 +783,7 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr)
                 oa.o_valid = OBD_MD_FLID;
                 obdo_from_inode(&oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME |
                                             OBD_MD_FLMTIME | OBD_MD_FLCTIME);
-                rc = obd_setattr(sbi->ll_dt_exp, &oa, lsm, NULL);
+                rc = obd_setattr(sbi->ll_dt_exp, &oa, lsm, NULL, NULL);
                 if (rc)
                         CERROR("obd_setattr fails: rc=%d\n", rc);
         }
@@ -868,8 +883,10 @@ static int llu_readlink_internal(struct inode *inode,
         }
 
         ll_inode2id(&id, inode);
-        rc = mdc_getattr(sbi->ll_md_exp, &id,
-                         OBD_MD_LINKNAME, symlen, request);
+
+        /* XXX: capa is NULL here, is it correct? */
+        rc = mdc_getattr(sbi->ll_md_exp, &id, OBD_MD_LINKNAME, NULL, 0,
+                         0, symlen, NULL, request);
         if (rc) {
                 CERROR("inode %lu: rc = %d\n", lli->lli_st_ino, rc);
                 RETURN(rc);
@@ -943,8 +960,9 @@ static int llu_iop_mknod_raw(struct pnode *pno,
         int err = -EMLINK;
         ENTRY;
 
-        CDEBUG(D_VFSTRACE, "VFS Op:name=%s,dir=%lu\n",
-               pno->p_base->pb_name.name, llu_i2info(dir)->lli_st_ino);
+        CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu\n",
+               (int)pno->p_base->pb_name.len, pno->p_base->pb_name.name,
+               llu_i2info(dir)->lli_st_ino);
 
         if (llu_i2info(dir)->lli_st_nlink >= EXT2_LINK_MAX)
                 RETURN(err);
@@ -1178,8 +1196,8 @@ static int llu_iop_mkdir_raw(struct pnode *pno, mode_t mode)
         struct mdc_op_data op_data;
         int err = -EMLINK;
         ENTRY;
-        CDEBUG(D_VFSTRACE, "VFS Op:name=%s,dir=%lu/%lu(%p)\n",
-               name, lli->lli_st_ino, lli->lli_st_generation, dir);
+        CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%lu(%p)\n",
+               len, name, lli->lli_st_ino, lli->lli_st_generation, dir);
 
         if (lli->lli_st_nlink >= EXT2_LINK_MAX)
                 RETURN(err);
@@ -1203,8 +1221,8 @@ static int llu_iop_rmdir_raw(struct pnode *pno)
         struct llu_inode_info *lli = llu_i2info(dir);
         int rc;
         ENTRY;
-        CDEBUG(D_VFSTRACE, "VFS Op:name=%s,dir=%lu/%lu(%p)\n",
-               name, lli->lli_st_ino, lli->lli_st_generation, dir);
+        CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%lu(%p)\n",
+               len, name, lli->lli_st_ino, lli->lli_st_generation, dir);
 
         llu_prepare_mdc_data(&op_data, dir, NULL, name, len, S_IFDIR);
         rc = mdc_unlink(llu_i2sbi(dir)->ll_md_exp, &op_data, &request);
@@ -1233,7 +1251,7 @@ static int llu_iop_fcntl(struct inode *ino, int cmd, va_list ap, int *rtn)
                 flags = va_arg(ap, long);
                 flags &= FCNTL_FLMASK;
                 if (flags & FCNTL_FLMASK_INVALID) {
-                        CERROR("liblustre does not support O_NONBLOCK, O_ASYNC, "
+                        CERROR("liblustre don't support O_NONBLOCK, O_ASYNC, "
                                "and O_DIRECT on file descriptor\n");
                         *rtn = -1;
                         return EINVAL;
@@ -1355,7 +1373,8 @@ struct inode *llu_iget(struct filesys *fs, struct lustre_md *md)
         if ((md->body->valid &
              (OBD_MD_FLGENER | OBD_MD_FLID | OBD_MD_FLTYPE)) !=
             (OBD_MD_FLGENER | OBD_MD_FLID | OBD_MD_FLTYPE)) {
-                CERROR("bad md body valid mask 0x%x\n", md->body->valid);
+                CERROR("bad md body valid mask 0x"LPX64"\n", 
+                      md->body->valid);
                 LBUG();
                 return ERR_PTR(-EPERM);
         }
@@ -1475,13 +1494,12 @@ llu_fsswop_mount(const char *source,
         }
         obd_set_info(obd->obd_self_export, strlen("async"), "async",
                      sizeof(async), &async);
-#warning "FIXME ASAP!"
 #if 0
-        if (mdc_init_ea_size(obd, lov))
+        if (mdc_init_ea_size(obd, osc))
                 GOTO(out_free, err = -EINVAL);
 #endif
         /* setup mdc */
-        err = obd_connect(&lmv_conn, obd, &sbi->ll_sb_uuid, 0);
+        err = obd_connect(&lmv_conn, obd, &sbi->ll_sb_uuid, NULL, 0);
         if (err) {
                 CERROR("cannot connect to %s: rc = %d\n", lmv, err);
                 GOTO(out_free, err);
@@ -1505,7 +1523,7 @@ llu_fsswop_mount(const char *source,
         obd_set_info(obd->obd_self_export, strlen("async"), "async",
                      sizeof(async), &async);
 
-        err = obd_connect(&lov_conn, obd, &sbi->ll_sb_uuid, 0);
+        err = obd_connect(&lov_conn, obd, &sbi->ll_sb_uuid, NULL, 0);
         if (err) {
                 CERROR("cannot connect to %s: rc = %d\n", lov, err);
                 GOTO(out_lmv, err);
@@ -1520,9 +1538,10 @@ llu_fsswop_mount(const char *source,
         CDEBUG(D_SUPER, "rootid "LPU64"\n", rootid.li_stc.u.e3s.l3s_ino);
         sbi->ll_rootino = rootid.li_stc.u.e3s.l3s_ino;
 
-        /* fetch attr of root inode */
+        /* XXX: capa is NULL here, is it correct? */
         err = mdc_getattr(sbi->ll_md_exp, &rootid,
-                          OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, 0, &request);
+                          (OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS), NULL, 0,
+                          0, 0, NULL, &request);
         if (err) {
                 CERROR("mdc_getattr failed for root: rc = %d\n", err);
                 GOTO(out_lov, err);