Whamcloud - gitweb
LU-2675 obd: decruft md_enqueue() and md_intent_lock()
[fs/lustre-release.git] / lustre / liblustre / super.c
index be0b4ca..9980b95 100644 (file)
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <string.h>
-#include <assert.h>
 #include <time.h>
-#include <sys/types.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
 #include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/queue.h>
-#ifndef __CYGWIN__
-# include <sys/statvfs.h>
-#else
-# include <sys/statfs.h>
-#endif
-
+#include <sys/types.h>
+#include <libcfs/libcfs.h>
+#include <lustre/lustre_idl.h>
+#include <liblustre.h>
+#include <lclient.h>
+#include <lustre_dlm.h>
+#include <lustre_export.h>
+#include <lustre_lite.h>
+#include <lustre_mdc.h>
+#include <lustre_net.h>
+#include <lustre_req_layout.h>
+#include <lustre_ver.h>
+#include <obd.h>
+#include <obd_class.h>
+#include <obd_support.h>
 #include "llite_lib.h"
 
 #ifndef MAY_EXEC
@@ -69,10 +83,10 @@ static int ll_permission(struct inode *inode, int mask)
         struct intnl_stat *st = llu_i2stat(inode);
         mode_t mode = st->st_mode;
 
-        if (current->fsuid == st->st_uid)
-                mode >>= 6;
-        else if (cfs_curproc_is_in_groups(st->st_gid))
-                mode >>= 3;
+       if (current->fsuid == st->st_uid)
+               mode >>= 6;
+       else if (in_group_p(st->st_gid))
+               mode >>= 3;
 
         if ((mode & mask & (MAY_READ|MAY_WRITE|MAY_EXEC)) == mask)
                 return 0;
@@ -213,48 +227,6 @@ void llu_update_inode(struct inode *inode, struct lustre_md *md)
         }
 }
 
-void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid)
-{
-        struct llu_inode_info *lli = llu_i2info(dst);
-        struct intnl_stat *st = llu_i2stat(dst);
-
-        valid &= src->o_valid;
-
-       LASSERTF(!(valid & (OBD_MD_FLTYPE | OBD_MD_FLGENER | OBD_MD_FLFID |
-                           OBD_MD_FLID | OBD_MD_FLGROUP)),
-                "object "DOSTID", valid %x\n", POSTID(&src->o_oi), valid);
-
-        if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME))
-                CDEBUG(D_INODE,"valid "LPX64", cur time "CFS_TIME_T"/"CFS_TIME_T
-                       ", new %lu/%lu\n",
-                       src->o_valid,
-                       LTIME_S(st->st_mtime), LTIME_S(st->st_ctime),
-                       (long)src->o_mtime, (long)src->o_ctime);
-
-        if (valid & OBD_MD_FLATIME)
-                LTIME_S(st->st_atime) = src->o_atime;
-        if (valid & OBD_MD_FLMTIME)
-                LTIME_S(st->st_mtime) = src->o_mtime;
-        if (valid & OBD_MD_FLCTIME && src->o_ctime > LTIME_S(st->st_ctime))
-                LTIME_S(st->st_ctime) = src->o_ctime;
-        if (valid & OBD_MD_FLSIZE)
-                st->st_size = src->o_size;
-        if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
-                st->st_blocks = src->o_blocks;
-        if (valid & OBD_MD_FLBLKSZ)
-                st->st_blksize = src->o_blksize;
-        if (valid & OBD_MD_FLTYPE)
-                st->st_mode = (st->st_mode & ~S_IFMT) | (src->o_mode & S_IFMT);
-        if (valid & OBD_MD_FLMODE)
-                st->st_mode = (st->st_mode & S_IFMT) | (src->o_mode & ~S_IFMT);
-        if (valid & OBD_MD_FLUID)
-                st->st_uid = src->o_uid;
-        if (valid & OBD_MD_FLGID)
-                st->st_gid = src->o_gid;
-        if (valid & OBD_MD_FLFLAGS)
-                lli->lli_st_flags = src->o_flags;
-}
-
 /**
  * Performs the getattr on the inode and updates its fields.
  * If @sync != 0, perform the getattr under the server-side lock.
@@ -388,11 +360,6 @@ static int llu_inode_revalidate(struct inode *inode)
         struct intnl_stat *st = llu_i2stat(inode);
         ENTRY;
 
-        if (!inode) {
-                CERROR("REPORT THIS LINE TO PETER\n");
-                RETURN(0);
-        }
-
         if (!llu_have_md_lock(inode, MDS_INODELOCK_UPDATE)) {
                 struct lustre_md md;
                 struct ptlrpc_request *req = NULL;
@@ -502,7 +469,7 @@ static int null_if_equal(struct ldlm_lock *lock, void *data)
         return LDLM_ITER_CONTINUE;
 }
 
-void llu_clear_inode(struct inode *inode)
+static void llu_clear_inode(struct inode *inode)
 {
        struct llu_inode_info *lli = llu_i2info(inode);
        struct llu_sb_info *sbi = llu_i2sbi(inode);
@@ -533,7 +500,7 @@ void llu_clear_inode(struct inode *inode)
         EXIT;
 }
 
-void llu_iop_gone(struct inode *inode)
+static void llu_iop_gone(struct inode *inode)
 {
         struct llu_inode_info *lli = llu_i2info(inode);
         ENTRY;
@@ -569,12 +536,12 @@ static int inode_setattr(struct inode * inode, struct iattr * attr)
                 st->st_mtime = attr->ia_mtime;
         if (ia_valid & ATTR_CTIME)
                 st->st_ctime = attr->ia_ctime;
-        if (ia_valid & ATTR_MODE) {
-                st->st_mode = attr->ia_mode;
-                if (!cfs_curproc_is_in_groups(st->st_gid) &&
-                    !cfs_capable(CFS_CAP_FSETID))
-                        st->st_mode &= ~S_ISGID;
-        }
+       if (ia_valid & ATTR_MODE) {
+               st->st_mode = attr->ia_mode;
+               if (!in_group_p(st->st_gid) &&
+                   !cfs_capable(CFS_CAP_FSETID))
+                       st->st_mode &= ~S_ISGID;
+       }
         /* mark_inode_dirty(inode); */
         return error;
 }
@@ -1331,11 +1298,11 @@ static int llu_file_flock(struct inode *ino,
                 LBUG();
         }
 
-       CDEBUG(D_DLMTRACE, "inode=%llu, pid=%u, cmd=%d, flags=%#llx, mode=%u, "
-               "start="LPX64", end="LPX64"\n", (unsigned long long)st->st_ino,
-               flock.l_flock.pid, cmd, flags, einfo.ei_mode, flock.l_flock.start,
-               flock.l_flock.end);
-
+       CDEBUG(D_DLMTRACE, "inode=%llu, pid=%u, cmd=%d, flags="LPX64", "
+              "mode=%u, start="LPX64", end="LPX64"\n",
+              (unsigned long long)st->st_ino,
+              flock.l_flock.pid, cmd, flags, einfo.ei_mode,
+              flock.l_flock.start, flock.l_flock.end);
         {
                 struct lmv_obd *lmv;
                 struct obd_device *lmv_obd;
@@ -1345,7 +1312,7 @@ static int llu_file_flock(struct inode *ino,
                 if (lmv->desc.ld_tgt_count < 1)
                         RETURN(rc = -ENODEV);
 
-               if (lmv->tgts[0] && lmv->tgts[0]->ltd_exp != NULL)
+               if (lmv->tgts[0] != NULL && lmv->tgts[0]->ltd_exp != NULL)
                        rc = ldlm_cli_enqueue(lmv->tgts[0]->ltd_exp, NULL,
                                              &einfo, &res_id, &flock, &flags,
                                              NULL, 0, LVB_T_NONE, &lockh, 0);
@@ -1664,8 +1631,8 @@ static int llu_lov_setstripe_ea_info(struct inode *ino, int flags,
 
         llu_prep_md_op_data(&data, NULL, ino, NULL, 0, O_RDWR,
                             LUSTRE_OPC_ANY);
-        rc = md_enqueue(sbi->ll_md_exp, &einfo, &oit, &data,
-                        &lockh, lum, lum_size, NULL, LDLM_FL_INTENT_ONLY);
+       rc = md_enqueue(sbi->ll_md_exp, &einfo, NULL, &oit, &data, &lockh,
+                       LDLM_FL_INTENT_ONLY);
         if (rc)
                 GOTO(out, rc);
 
@@ -1793,9 +1760,8 @@ static int llu_iop_datasync(struct inode *inode)
         return 0;
 }
 
-struct filesys_ops llu_filesys_ops =
-{
-        fsop_gone: llu_fsop_gone,
+static struct filesys_ops llu_filesys_ops = {
+       .fsop_gone      = llu_fsop_gone,
 };
 
 struct inode *llu_iget(struct filesys *fs, struct lustre_md *md)
@@ -2053,40 +2019,41 @@ out_free:
                 OBD_FREE(osc, strlen(lprof->lp_dt) + instlen + 2);
         if (mdc)
                 OBD_FREE(mdc, strlen(lprof->lp_md) + instlen + 2);
-        OBD_FREE(sbi, sizeof(*sbi));
+        if (err != 0)
+                OBD_FREE(sbi, sizeof(*sbi));
         liblustre_wait_idle();
         return err;
 }
 
 struct fssw_ops llu_fssw_ops = {
-        llu_fsswop_mount
+       .fsswop_mount           = llu_fsswop_mount,
 };
 
 static struct inode_ops llu_inode_ops = {
-        inop_lookup:    llu_iop_lookup,
-        inop_getattr:   llu_iop_getattr,
-        inop_setattr:   llu_iop_setattr,
-        inop_filldirentries:     llu_iop_filldirentries,
-        inop_mkdir:     llu_iop_mkdir_raw,
-        inop_rmdir:     llu_iop_rmdir_raw,
-        inop_symlink:   llu_iop_symlink_raw,
-        inop_readlink:  llu_iop_readlink,
-        inop_open:      llu_iop_open,
-        inop_close:     llu_iop_close,
-        inop_link:      llu_iop_link_raw,
-        inop_unlink:    llu_iop_unlink_raw,
-        inop_rename:    llu_iop_rename_raw,
-        inop_pos:       llu_iop_pos,
-        inop_read:      llu_iop_read,
-        inop_write:     llu_iop_write,
-        inop_iodone:    llu_iop_iodone,
-        inop_fcntl:     llu_iop_fcntl,
-        inop_sync:      llu_iop_sync,
-        inop_datasync:  llu_iop_datasync,
-        inop_ioctl:     llu_iop_ioctl,
-        inop_mknod:     llu_iop_mknod_raw,
+       .inop_lookup            = llu_iop_lookup,
+       .inop_getattr           = llu_iop_getattr,
+       .inop_setattr           = llu_iop_setattr,
+       .inop_filldirentries    = llu_iop_filldirentries,
+       .inop_mkdir             = llu_iop_mkdir_raw,
+       .inop_rmdir             = llu_iop_rmdir_raw,
+       .inop_symlink           = llu_iop_symlink_raw,
+       .inop_readlink          = llu_iop_readlink,
+       .inop_open              = llu_iop_open,
+       .inop_close             = llu_iop_close,
+       .inop_link              = llu_iop_link_raw,
+       .inop_unlink            = llu_iop_unlink_raw,
+       .inop_rename            = llu_iop_rename_raw,
+       .inop_pos               = llu_iop_pos,
+       .inop_read              = llu_iop_read,
+       .inop_write             = llu_iop_write,
+       .inop_iodone            = llu_iop_iodone,
+       .inop_fcntl             = llu_iop_fcntl,
+       .inop_sync              = llu_iop_sync,
+       .inop_datasync          = llu_iop_datasync,
+       .inop_ioctl             = llu_iop_ioctl,
+       .inop_mknod             = llu_iop_mknod_raw,
 #ifdef _HAVE_STATVFS
-        inop_statvfs:   llu_iop_statvfs,
+       .inop_statvfs           = llu_iop_statvfs,
 #endif
-        inop_gone:      llu_iop_gone,
+       .inop_gone              = llu_iop_gone,
 };