Whamcloud - gitweb
Use the OBD_MD_FLTYPE and OBD_MD_FLMODE flags where appropriate.
authoradilger <adilger>
Tue, 24 Sep 2002 19:18:17 +0000 (19:18 +0000)
committeradilger <adilger>
Tue, 24 Sep 2002 19:18:17 +0000 (19:18 +0000)
lustre/include/linux/obd_class.h
lustre/lib/mds_updates.c
lustre/llite/file.c
lustre/llite/namei.c
lustre/llite/super.c
lustre/obdclass/debug.c
lustre/obdecho/echo.c
lustre/obdfs/namei.c
lustre/utils/obd.c

index dc2f71c..ec53d6b 100644 (file)
@@ -200,10 +200,6 @@ static inline int obd_create(struct lustre_handle *conn, struct obdo *obdo,
         OBD_CHECK_SETUP(conn, export);
         OBD_CHECK_OP(export->exp_obd, create);
 
-#define OBD_MD_FLNEEDED (OBD_MD_FLID | OBD_MD_FLMODE)
-        //if (obdo->o_valid & OBD_MD_FLNEEDED != OBD_MD_FLNEEDED)
-        //        RETURN(-EINVAL);
-#undef OBD_MD_FLNEEDED
         rc = OBP(export->exp_obd, create)(conn, obdo, ea);
         RETURN(rc);
 }
@@ -478,12 +474,11 @@ static inline void obdo_from_iattr(struct obdo *oa, struct iattr *attr)
         }
         if (ia_valid & ATTR_MODE) {
                 oa->o_mode = attr->ia_mode;
-                oa->o_valid |= OBD_MD_FLMODE;
+                oa->o_valid |= OBD_MD_FLTYPE | OBD_MD_FLMODE;
                 if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID))
                         oa->o_mode &= ~S_ISGID;
         }
-        if (ia_valid & ATTR_UID)
-        {
+        if (ia_valid & ATTR_UID) {
                 oa->o_uid = attr->ia_uid;
                 oa->o_valid |= OBD_MD_FLUID;
         }
@@ -514,8 +509,12 @@ static inline void iattr_from_obdo(struct iattr *attr, struct obdo *oa,
                 attr->ia_size = oa->o_size;
                 attr->ia_valid |= ATTR_SIZE;
         }
+        if (valid & OBD_MD_FLTYPE) {
+                attr->ia_mode = (attr->ia_mode & ~S_IFMT)|(oa->o_mode & S_IFMT);
+                attr->ia_valid |= ATTR_MODE;
+        }
         if (valid & OBD_MD_FLMODE) {
-                attr->ia_mode = oa->o_mode;
+                attr->ia_mode = (attr->ia_mode & S_IFMT)|(oa->o_mode & ~S_IFMT);
                 attr->ia_valid |= ATTR_MODE;
                 if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID))
                         attr->ia_mode &= ~S_ISGID;
@@ -552,8 +551,10 @@ static inline void obdo_from_inode(struct obdo *dst, struct inode *src,
                 dst->o_blocks = src->i_blocks;
         if (valid & OBD_MD_FLBLKSZ)
                 dst->o_blksize = src->i_blksize;
+        if (valid & OBD_MD_FLTYPE)
+                dst->o_mode = (dst->o_mode & ~S_IFMT) | (src->i_mode & S_IFMT);
         if (valid & OBD_MD_FLMODE)
-                dst->o_mode = src->i_mode;
+                dst->o_mode = (dst->o_mode & S_IFMT) | (src->i_mode & ~S_IFMT);
         if (valid & OBD_MD_FLUID)
                 dst->o_uid = src->i_uid;
         if (valid & OBD_MD_FLGID)
@@ -587,8 +588,10 @@ static inline void obdo_to_inode(struct inode *dst, struct obdo *src,
                 dst->i_blocks = src->o_blocks;
         if (valid & OBD_MD_FLBLKSZ)
                 dst->i_blksize = src->o_blksize;
+        if (valid & OBD_MD_FLTYPE)
+                dst->i_mode = (dst->i_mode & ~S_IFMT) | (src->o_mode & S_IFMT);
         if (valid & OBD_MD_FLMODE)
-                dst->i_mode = src->o_mode;
+                dst->i_mode = (dst->i_mode & S_IFMT) | (src->o_mode & ~S_IFMT);
         if (valid & OBD_MD_FLUID)
                 dst->i_uid = src->o_uid;
         if (valid & OBD_MD_FLGID)
@@ -624,8 +627,10 @@ static inline void obdo_cpy_md(struct obdo *dst, struct obdo *src,
                 dst->o_blocks = src->o_blocks;
         if (valid & OBD_MD_FLBLKSZ)
                 dst->o_blksize = src->o_blksize;
+        if (valid & OBD_MD_FLTYPE)
+                dst->o_mode = (dst->o_mode & ~S_IFMT) | (src->o_mode & S_IFMT);
         if (valid & OBD_MD_FLMODE)
-                dst->o_mode = src->o_mode;
+                dst->o_mode = (dst->o_mode & S_IFMT) | (src->o_mode & ~S_IFMT);
         if (valid & OBD_MD_FLUID)
                 dst->o_uid = src->o_uid;
         if (valid & OBD_MD_FLGID)
@@ -670,8 +675,10 @@ static inline int obdo_cmp_md(struct obdo *dst, struct obdo *src,
                 res = (res || (dst->o_blocks != src->o_blocks));
         if ( compare & OBD_MD_FLBLKSZ )
                 res = (res || (dst->o_blksize != src->o_blksize));
+        if ( compare & OBD_MD_FLTYPE )
+                res = (res || (((dst->o_mode ^ src->o_mode) & S_IFMT) != 0));
         if ( compare & OBD_MD_FLMODE )
-                res = (res || (dst->o_mode != src->o_mode));
+                res = (res || (((dst->o_mode ^ src->o_mode) & ~S_IFMT) != 0));
         if ( compare & OBD_MD_FLUID )
                 res = (res || (dst->o_uid != src->o_uid));
         if ( compare & OBD_MD_FLGID )
index b820e57..00620a1 100644 (file)
@@ -48,8 +48,8 @@ void mds_pack_inode2fid(struct ll_fid *fid, struct inode *inode)
 void mds_pack_inode2body(struct mds_body *b, struct inode *inode)
 {
         b->valid = OBD_MD_FLID | OBD_MD_FLATIME | OBD_MD_FLMTIME |
-                OBD_MD_FLCTIME | OBD_MD_FLMODE | OBD_MD_FLSIZE | OBD_MD_FLUID |
-                OBD_MD_FLGID | OBD_MD_FLNLINK | OBD_MD_FLGENER;
+                OBD_MD_FLCTIME | OBD_MD_FLSIZE | OBD_MD_FLUID | OBD_MD_FLGID |
+                OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLNLINK | OBD_MD_FLGENER;
         b->ino = HTON__u32(inode->i_ino);
         b->atime = HTON__u32(inode->i_atime);
         b->mtime = HTON__u32(inode->i_mtime);
index 02c8832..fc19186 100644 (file)
@@ -64,8 +64,8 @@ static int ll_file_open(struct inode *inode, struct file *file)
                         oa->o_mode = S_IFREG | 0600;
                         oa->o_easize = ll_mds_easize(inode->i_sb);
                         oa->o_id = inode->i_ino;
-                        oa->o_valid = OBD_MD_FLMODE | OBD_MD_FLEASIZE |
-                                        OBD_MD_FLID;
+                        oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE |
+                                OBD_MD_FLMODE | OBD_MD_FLEASIZE;
                         rc = obd_create(ll_i2obdconn(inode), oa, &lli->lli_smd);
 
                         if (rc) {
@@ -101,8 +101,8 @@ static int ll_file_open(struct inode *inode, struct file *file)
                 GOTO(out_mdc, rc = -EINVAL);
 
         oa->o_id = lsm->lsm_object_id;
-        oa->o_mode = S_IFREG | inode->i_mode;
-        oa->o_valid = OBD_MD_FLMODE | OBD_MD_FLID | OBD_MD_FLSIZE;
+        oa->o_mode = S_IFREG;
+        oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLSIZE;
         rc = obd_open(ll_i2obdconn(inode), oa, lsm);
         obdo_free(oa);
         oa = NULL;
@@ -206,10 +206,11 @@ int ll_file_size(struct inode *inode, struct lov_stripe_md *lsm)
 
         oa.o_id = lsm->lsm_object_id;
         oa.o_mode = S_IFREG;
-        oa.o_valid = OBD_MD_FLID|OBD_MD_FLSIZE|OBD_MD_FLBLOCKS;
+        oa.o_valid = OBD_MD_FLID|OBD_MD_FLTYPE|OBD_MD_FLSIZE|OBD_MD_FLBLOCKS;
         rc = obd_getattr(&sbi->ll_osc_conn, &oa, lsm);
         if (!rc)
-                obdo_to_inode(inode, &oa, oa.o_valid);
+                obdo_to_inode(inode, &oa,
+                              oa.o_valid & ~(OBD_MD_FLTYPE | OBD_MD_FLMODE));
 
         err = ll_size_unlock(inode, lsm, LCK_PR, lockhs);
         if (err != ELDLM_OK) {
@@ -239,7 +240,7 @@ static int ll_file_release(struct inode *inode, struct file *file)
         memset(&oa, 0, sizeof(oa));
         oa.o_id = lli->lli_smd->lsm_object_id;
         oa.o_mode = S_IFREG;
-        oa.o_valid = (OBD_MD_FLMODE | OBD_MD_FLID);
+        oa.o_valid = OBD_MD_FLTYPE | OBD_MD_FLID;
         rc = obd_close(ll_i2obdconn(inode), &oa, lli->lli_smd);
         if (rc)
                 GOTO(out_fd, abs(rc));
@@ -255,7 +256,7 @@ static int ll_file_release(struct inode *inode, struct file *file)
 
                 oa.o_id = lli->lli_smd->lsm_object_id;
                 oa.o_mode = S_IFREG;
-                oa.o_valid = OBD_MD_FLID | OBD_MD_FLMODE | OBD_MD_FLSIZE |
+                oa.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLSIZE |
                         OBD_MD_FLBLOCKS;
                 rc = obd_getattr(&sbi->ll_osc_conn, &oa, lli->lli_smd);
                 if (!rc) {
@@ -447,7 +448,7 @@ ll_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
 
                 oa.o_id = lsm->lsm_object_id;
                 oa.o_mode = inode->i_mode;
-                oa.o_valid = OBD_MD_FLID | OBD_MD_FLMODE | OBD_MD_FLSIZE |
+                oa.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLSIZE |
                         OBD_MD_FLBLOCKS;
                 retval = obd_getattr(&sbi->ll_osc_conn, &oa, lsm);
                 if (retval)
index f32a6dc..62dac82 100644 (file)
@@ -439,8 +439,8 @@ static int ll_create(struct inode * dir, struct dentry * dentry, int mode)
 
         if (dentry->d_it->it_disposition == 0) {
                 memset(&oa, 0, sizeof(oa));
-                oa.o_valid = OBD_MD_FLMODE;
                 oa.o_mode = S_IFREG | 0600;
+                oa.o_valid = OBD_MD_FLTYPE | OBD_MD_FLMODE;
                 rc = obd_create(ll_i2obdconn(dir), &oa, &lsm);
                 CDEBUG(D_DENTRY, "name %s mode %o o_id %lld: rc = %d\n",
                        dentry->d_name.name, mode, (long long)oa.o_id, rc);
index ac553f7..f2c188e 100644 (file)
@@ -290,7 +290,7 @@ static void ll_delete_inode(struct inode *inode)
                 oa->o_id = lsm->lsm_object_id;
                 oa->o_easize = ll_mds_easize(inode->i_sb);
                 oa->o_mode = inode->i_mode;
-                oa->o_valid = OBD_MD_FLID | OBD_MD_FLEASIZE | OBD_MD_FLMODE;
+                oa->o_valid = OBD_MD_FLID | OBD_MD_FLEASIZE | OBD_MD_FLTYPE;
 
                 err = obd_destroy(ll_i2obdconn(inode), oa, lsm);
                 obdo_free(oa);
@@ -424,7 +424,9 @@ void ll_update_inode(struct inode *inode, struct mds_body *body)
         if (body->valid & OBD_MD_FLCTIME)
                 inode->i_ctime = body->ctime;
         if (body->valid & OBD_MD_FLMODE)
-                inode->i_mode = body->mode;
+                inode->i_mode = (inode->i_mode & S_IFMT)|(body->mode & ~S_IFMT);
+        if (body->valid & OBD_MD_FLTYPE)
+                inode->i_mode = (inode->i_mode & ~S_IFMT)|(body->mode & S_IFMT);
         if (body->valid & OBD_MD_FLUID)
                 inode->i_uid = body->uid;
         if (body->valid & OBD_MD_FLGID)
index 636ee20..8b28706 100644 (file)
@@ -43,32 +43,36 @@ int dump_rniobuf(struct niobuf_remote *nb)
 
 int dump_obdo(struct obdo *oa)
 {
-        CERROR("obdo: o_valid = %08x\n", oa->o_valid);
-        if (oa->o_valid & OBD_MD_FLID)
+        __u32 valid = oa->o_valid;
+
+        CERROR("obdo: o_valid = %08x\n", valid);
+        if (valid & OBD_MD_FLID)
                 CERROR("obdo: o_id = "LPD64"\n", oa->o_id);
-        if (oa->o_valid & OBD_MD_FLATIME)
+        if (valid & OBD_MD_FLATIME)
                 CERROR("obdo: o_atime = "LPD64"\n", oa->o_atime);
-        if (oa->o_valid & OBD_MD_FLMTIME)
+        if (valid & OBD_MD_FLMTIME)
                 CERROR("obdo: o_mtime = "LPD64"\n", oa->o_mtime);
-        if (oa->o_valid & OBD_MD_FLCTIME)
+        if (valid & OBD_MD_FLCTIME)
                 CERROR("obdo: o_ctime = "LPD64"\n", oa->o_ctime);
-        if (oa->o_valid & OBD_MD_FLSIZE)
+        if (valid & OBD_MD_FLSIZE)
                 CERROR("obdo: o_size = "LPD64"\n", oa->o_size);
-        if (oa->o_valid & OBD_MD_FLBLOCKS)   /* allocation of space */
+        if (valid & OBD_MD_FLBLOCKS)   /* allocation of space */
                 CERROR("obdo: o_blocks = "LPD64"\n", oa->o_blocks);
-        if (oa->o_valid & OBD_MD_FLBLKSZ)
+        if (valid & OBD_MD_FLBLKSZ)
                 CERROR("obdo: o_blksize = %d\n", oa->o_blksize);
-        if (oa->o_valid & OBD_MD_FLMODE)
-                CERROR("obdo: o_mode = %o\n", oa->o_mode);
-        if (oa->o_valid & OBD_MD_FLUID)
+        if (valid & (OBD_MD_FLTYPE | OBD_MD_FLMODE))
+                CERROR("obdo: o_mode = %o\n",
+                       oa->o_mode & ((valid & OBD_MD_FLTYPE ?  S_IFMT : 0) |
+                                     (valid & OBD_MD_FLMODE ? ~S_IFMT : 0)));
+        if (valid & OBD_MD_FLUID)
                 CERROR("obdo: o_uid = %d\n", oa->o_uid);
-        if (oa->o_valid & OBD_MD_FLGID)
+        if (valid & OBD_MD_FLGID)
                 CERROR("obdo: o_gid = %d\n", oa->o_gid);
-        if (oa->o_valid & OBD_MD_FLFLAGS)
+        if (valid & OBD_MD_FLFLAGS)
                 CERROR("obdo: o_flags = %x\n", oa->o_flags);
-        if (oa->o_valid & OBD_MD_FLNLINK)
+        if (valid & OBD_MD_FLNLINK)
                 CERROR("obdo: o_nlink = %d\n", oa->o_nlink);
-        if (oa->o_valid & OBD_MD_FLGENER)
+        if (valid & OBD_MD_FLGENER)
                 CERROR("obdo: o_generation = %d\n", oa->o_generation);
 
         return -EINVAL;
index c9d8f62..6d434a2 100644 (file)
@@ -12,8 +12,8 @@
  * and Andreas Dilger <adilger@clusterfs.com>
  */
 
-static char rcsid[] __attribute ((unused)) = "$Id: echo.c,v 1.37 2002/09/11 05:17:03 adilger Exp $";
-#define OBDECHO_VERSION "$Revision: 1.37 $"
+static char rcsid[] __attribute ((unused)) = "$Id: echo.c,v 1.38 2002/09/24 19:18:16 adilger Exp $";
+#define OBDECHO_VERSION "$Revision: 1.38 $"
 
 #define EXPORT_SYMTAB
 
@@ -141,7 +141,7 @@ int echo_create(struct lustre_handle *conn, struct obdo *oa,
                 return -ENOENT;
         }
 
-        if (!(oa->o_valid & OBD_MD_FLMODE)) {
+        if (!(oa->o_valid & OBD_MD_FLTYPE)) {
                 CERROR("invalid o_valid %08x\n", oa->o_valid);
                 return -EINVAL;
         }
index ef8dfa5..d5869bb 100644 (file)
@@ -150,7 +150,7 @@ static struct inode *obdfs_new_inode(struct inode *dir, int mode)
 
         /* Send a hint to the create method on the type of file to create */
         oa->o_mode = mode;
-        oa->o_valid |= OBD_MD_FLMODE;
+        oa->o_valid = OBD_MD_FLTYPE | OBD_MD_FLMODE;
         CDEBUG(D_INODE, "\n");
         err = obd_create(IID(dir), oa, NULL);
         CDEBUG(D_INODE, "\n");
index 24b59e5..7e280c1 100644 (file)
@@ -793,6 +793,8 @@ int jt_obd_create(int argc, char **argv)
                                 cmdname(argv[0]), argv[2]);
                         return CMD_HELP;
                 }
+                if (!(mode & S_IFMT))
+                        mode |= S_IFREG;
         }
 
         if (argc > 3) {
@@ -808,7 +810,8 @@ int jt_obd_create(int argc, char **argv)
         for (i = 1, next_count = verbose; i <= count; i++) {
                 data.ioc_obdo1.o_mode = mode;
                 data.ioc_obdo1.o_id = i;
-                data.ioc_obdo1.o_valid = OBD_MD_FLMODE | OBD_MD_FLID;
+                data.ioc_obdo1.o_valid = OBD_MD_FLTYPE | OBD_MD_FLMODE |
+                                        OBD_MD_FLID;
 
                 rc = ioctl(fd, OBD_IOC_CREATE, &data);
                 SHMEM_BUMP();
@@ -853,7 +856,7 @@ int jt_obd_setattr(int argc, char **argv)
                         cmdname(argv[0]), argv[2]);
                 return CMD_HELP;
         }
-        data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLMODE;
+        data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE;
 
         rc = ioctl(fd, OBD_IOC_SETATTR, &data);
         if (rc < 0)
@@ -1078,7 +1081,7 @@ int jt_obd_test_brw(int argc, char **argv)
         IOCINIT(data);
         data.ioc_obdo1.o_id = objid;
         data.ioc_obdo1.o_mode = S_IFREG;
-        data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLMODE;
+        data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE;
         data.ioc_count = len;
         data.ioc_offset = thr_offset * len * count;