From: braam Date: Wed, 27 Mar 2002 22:54:23 +0000 (+0000) Subject: - added a find_inode function that iget4() will use to compare inodes. X-Git-Tag: 0.4.2~466 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=408c1153295c8788a33d4d6b540aa88e03f0b087;p=fs%2Flustre-release.git - added a find_inode function that iget4() will use to compare inodes. find_inode simply compares generation number with what we get from MDS - set rep->generation in mds_reint.c:mds_reint_create() --- diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 2f2fa47..461fb67 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -80,6 +80,16 @@ static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode) } /* methods */ +static int ll_find_inode(struct inode *inode, unsigned long ino, void *opaque) +{ + struct mds_rep *rep = (struct mds_rep *)opaque; + + if (inode->i_generation != rep->generation) + return 0; + + return 1; +} + static struct dentry *ll_lookup(struct inode * dir, struct dentry *dentry) { struct ptlrpc_request *request; @@ -106,7 +116,7 @@ static struct dentry *ll_lookup(struct inode * dir, struct dentry *dentry) return ERR_PTR(-abs(err)); } - inode = iget4(dir->i_sb, ino, NULL, request->rq_rep.mds); + inode = iget4(dir->i_sb, ino, ll_find_inode, request->rq_rep.mds); ptlrpc_free_req(request); if (!inode) @@ -117,23 +127,6 @@ static struct dentry *ll_lookup(struct inode * dir, struct dentry *dentry) return NULL; } - -/* - * NOTE! unlike strncmp, ext2_match returns 1 for success, 0 for failure. - * - * `len <= EXT2_NAME_LEN' is guaranteed by caller. - * `de != NULL' is guaranteed by caller. - */ -static inline int ext2_match (int len, const char * const name, - struct ext2_dir_entry_2 * de) -{ - if (len != de->name_len) - return 0; - if (!de->inode) - return 0; - return !memcmp(name, de->name, len); -} - static struct inode *ll_create_node(struct inode *dir, const char *name, int namelen, const char *tgt, int tgtlen, int mode, __u64 id) @@ -164,7 +157,7 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, CDEBUG(D_INODE, "-- new_inode: objid %lld, ino %d, mode %o\n", rep->objid, rep->ino, rep->mode); - inode = iget4(dir->i_sb, rep->ino, NULL, rep); + inode = iget4(dir->i_sb, rep->ino, ll_find_inode, rep); if (IS_ERR(inode)) { CERROR("new_inode -fatal: %ld\n", PTR_ERR(inode)); inode = ERR_PTR(-EIO); @@ -174,7 +167,7 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, } if (!list_empty(&inode->i_dentry)) { - CERROR("new_inode -fatal: aliases %d, ct %d lnk %d\n", + CERROR("new_inode -fatal: inode %d, ct %d lnk %d\n", rep->ino, atomic_read(&inode->i_count), inode->i_nlink); iput(inode); @@ -417,7 +410,6 @@ static int ll_unlink(struct inode * dir, struct dentry *dentry) if (err) goto out; - err = ext2_delete_entry (de, page); if (err) goto out; @@ -429,8 +421,7 @@ out: return err; } - -static int ll_rmdir (struct inode * dir, struct dentry *dentry) +static int ll_rmdir(struct inode * dir, struct dentry *dentry) { struct inode * inode = dentry->d_inode; int err = -ENOTEMPTY; diff --git a/lustre/llite/super.c b/lustre/llite/super.c index 02cda54..5977ebe 100644 --- a/lustre/llite/super.c +++ b/lustre/llite/super.c @@ -45,17 +45,17 @@ static char *ll_read_opt(const char *opt, char *data) { char *value; char *retval; - ENTRY; + ENTRY; CDEBUG(D_INFO, "option: %s, data %s\n", opt, data); if ( strncmp(opt, data, strlen(opt)) ) { - EXIT; + EXIT; return NULL; - } + } if ( (value = strchr(data, '=')) == NULL ) { - EXIT; + EXIT; return NULL; - } + } value++; OBD_ALLOC(retval, strlen(value) + 1); @@ -66,19 +66,19 @@ static char *ll_read_opt(const char *opt, char *data) memcpy(retval, value, strlen(value)+1); CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval); - EXIT; + EXIT; return retval; } static void ll_options(char *options, char **dev, char **vers) { char *this_char; - ENTRY; + ENTRY; if (!options) { - EXIT; + EXIT; return; - } + } for (this_char = strtok (options, ","); this_char != NULL; @@ -89,7 +89,7 @@ static void ll_options(char *options, char **dev, char **vers) continue; } - EXIT; + EXIT; } static struct super_block * ll_read_super(struct super_block *sb, @@ -97,36 +97,36 @@ static struct super_block * ll_read_super(struct super_block *sb, { struct inode *root = 0; struct ll_sb_info *sbi; - char *device = NULL; + char *device = NULL; char *version = NULL; - int connected = 0; + int connected = 0; int devno; int err; - struct ptlrpc_request *request = NULL; + struct ptlrpc_request *request = NULL; ENTRY; MOD_INC_USE_COUNT; - OBD_ALLOC(sbi, sizeof(*sbi)); - if (!sbi) { - EXIT; - return NULL; - } + OBD_ALLOC(sbi, sizeof(*sbi)); + if (!sbi) { + EXIT; + return NULL; + } memset(sbi, 0, sizeof(*sbi)); - sb->u.generic_sbp = sbi; + sb->u.generic_sbp = sbi; ll_options(data, &device, &version); if ( !device ) { CERROR("no device\n"); - sb = NULL; + sb = NULL; goto ERR; } - devno = simple_strtoul(device, NULL, 0); + devno = simple_strtoul(device, NULL, 0); if ( devno >= MAX_OBD_DEVICES ) { CERROR("device of %s too high\n", device); - sb = NULL; + sb = NULL; goto ERR; } @@ -134,49 +134,49 @@ static struct super_block * ll_read_super(struct super_block *sb, err = obd_connect(&sbi->ll_conn); if ( err ) { CERROR("cannot connect to %s\n", device); - sb = NULL; + sb = NULL; + goto ERR; + } + connected = 1; + + /* the first parameter should become an mds device no */ + err = ptlrpc_connect_client(-1, "mds", + MDS_REQUEST_PORTAL, + MDC_REPLY_PORTAL, + mds_pack_req, + mds_unpack_rep, + &sbi->ll_mds_client); + + if (err) { + CERROR("cannot find MDS\n"); + sb = NULL; goto ERR; } - connected = 1; - - /* the first parameter should become an mds device no */ - err = ptlrpc_connect_client(-1, "mds", - MDS_REQUEST_PORTAL, - MDC_REPLY_PORTAL, - mds_pack_req, - mds_unpack_rep, - &sbi->ll_mds_client); - - if (err) { - CERROR("cannot find MDS\n"); - sb = NULL; - goto ERR; - } sbi->ll_super = sb; - sbi->ll_rootino = 2; + sbi->ll_rootino = 2; - sb->s_maxbytes = 1LL << 36; + sb->s_maxbytes = 1LL << 36; sb->s_blocksize = PAGE_SIZE; sb->s_blocksize_bits = (unsigned char)PAGE_SHIFT; sb->s_magic = LL_SUPER_MAGIC; sb->s_op = &ll_super_operations; /* make root inode */ - err = mdc_getattr(&sbi->ll_mds_client, sbi->ll_rootino, S_IFDIR, + err = mdc_getattr(&sbi->ll_mds_client, sbi->ll_rootino, S_IFDIR, OBD_MD_FLNOTOBD|OBD_MD_FLBLOCKS, &request); if (err) { CERROR("mdc_getattr failed for root %d\n", err); - sb = NULL; + sb = NULL; goto ERR; } root = iget4(sb, sbi->ll_rootino, NULL, request->rq_rep.mds); if (root) { - sb->s_root = d_alloc_root(root); - } else { - CERROR("lustre_light: bad iget4 for root\n"); - sb = NULL; - goto ERR; + sb->s_root = d_alloc_root(root); + } else { + CERROR("lustre_light: bad iget4 for root\n"); + sb = NULL; + goto ERR; } ERR: @@ -185,25 +185,25 @@ ERR: OBD_FREE(device, strlen(device) + 1); if (version) OBD_FREE(version, strlen(version) + 1); - if (!sb && connected) - obd_disconnect(&sbi->ll_conn); + if (!sb && connected) + obd_disconnect(&sbi->ll_conn); if (!sb && root) { iput(root); } - if (!sb) - MOD_DEC_USE_COUNT; + if (!sb) + MOD_DEC_USE_COUNT; - EXIT; + EXIT; return sb; } /* ll_read_super */ static void ll_put_super(struct super_block *sb) { - struct ll_sb_info *sbi = sb->u.generic_sbp; + struct ll_sb_info *sbi = sb->u.generic_sbp; ENTRY; obd_disconnect(&sbi->ll_conn); - OBD_FREE(sb->u.generic_sbp, sizeof(struct ll_sb_info)); + OBD_FREE(sb->u.generic_sbp, sizeof(struct ll_sb_info)); MOD_DEC_USE_COUNT; EXIT; } /* ll_put_super */ @@ -212,68 +212,68 @@ static void ll_put_super(struct super_block *sb) extern inline struct obdo * ll_oa_from_inode(struct inode *inode, int valid); static void ll_delete_inode(struct inode *inode) { - if (S_ISREG(inode->i_mode)) { - int err; - struct obdo *oa; - oa = ll_oa_from_inode(inode, OBD_MD_FLNOTOBD); - if (!oa) { - CERROR("no memory\n"); - } - - err = obd_destroy(ll_i2obdconn(inode), oa); + if (S_ISREG(inode->i_mode)) { + int err; + struct obdo *oa; + oa = ll_oa_from_inode(inode, OBD_MD_FLNOTOBD); + if (!oa) { + CERROR("no memory\n"); + } + + err = obd_destroy(ll_i2obdconn(inode), oa); CDEBUG(D_INODE, "obd destroy of %Ld error %d\n", oa->o_id, err); - obdo_free(oa); - } + obdo_free(oa); + } - clear_inode(inode); + clear_inode(inode); } /* like inode_setattr, but doesn't mark the inode dirty */ static int ll_attr2inode(struct inode * inode, struct iattr * attr, int trunc) { - unsigned int ia_valid = attr->ia_valid; - int error = 0; - - if ((ia_valid & ATTR_SIZE) && trunc ) { - error = vmtruncate(inode, attr->ia_size); - if (error) - goto out; - } else if (ia_valid & ATTR_SIZE) { - inode->i_size = attr->ia_size; - } - - if (ia_valid & ATTR_UID) - inode->i_uid = attr->ia_uid; - if (ia_valid & ATTR_GID) - inode->i_gid = attr->ia_gid; - if (ia_valid & ATTR_ATIME) - inode->i_atime = attr->ia_atime; - if (ia_valid & ATTR_MTIME) - inode->i_mtime = attr->ia_mtime; - if (ia_valid & ATTR_CTIME) - inode->i_ctime = attr->ia_ctime; - if (ia_valid & ATTR_MODE) { - inode->i_mode = attr->ia_mode; - if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID)) - inode->i_mode &= ~S_ISGID; - } + unsigned int ia_valid = attr->ia_valid; + int error = 0; + + if ((ia_valid & ATTR_SIZE) && trunc ) { + error = vmtruncate(inode, attr->ia_size); + if (error) + goto out; + } else if (ia_valid & ATTR_SIZE) { + inode->i_size = attr->ia_size; + } + + if (ia_valid & ATTR_UID) + inode->i_uid = attr->ia_uid; + if (ia_valid & ATTR_GID) + inode->i_gid = attr->ia_gid; + if (ia_valid & ATTR_ATIME) + inode->i_atime = attr->ia_atime; + if (ia_valid & ATTR_MTIME) + inode->i_mtime = attr->ia_mtime; + if (ia_valid & ATTR_CTIME) + inode->i_ctime = attr->ia_ctime; + if (ia_valid & ATTR_MODE) { + inode->i_mode = attr->ia_mode; + if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID)) + inode->i_mode &= ~S_ISGID; + } out: - return error; + return error; } int ll_inode_setattr(struct inode *inode, struct iattr *attr, int do_trunc) { - struct ptlrpc_request *request; + struct ptlrpc_request *request; struct ll_sb_info *sbi = ll_i2sbi(inode); - int err; + int err; ENTRY; - /* change incore inode */ - ll_attr2inode(inode, attr, do_trunc); + /* change incore inode */ + ll_attr2inode(inode, attr, do_trunc); - err = mdc_setattr(&sbi->ll_mds_client, inode, attr, &request); + err = mdc_setattr(&sbi->ll_mds_client, inode, attr, &request); if (err) CERROR("mdc_setattr fails (%d)\n", err); @@ -285,7 +285,7 @@ int ll_inode_setattr(struct inode *inode, struct iattr *attr, int do_trunc) int ll_setattr(struct dentry *de, struct iattr *attr) { - return ll_inode_setattr(de->d_inode, attr, 1); + return ll_inode_setattr(de->d_inode, attr, 1); } static int ll_statfs(struct super_block *sb, struct statfs *buf) @@ -300,8 +300,8 @@ static int ll_statfs(struct super_block *sb, struct statfs *buf) CERROR("obd_statfs fails (%d)\n", err); return err; } - memcpy(buf, &tmp, sizeof(*buf)); - CDEBUG(D_SUPER, "statfs returns avail %ld\n", tmp.f_bavail); + memcpy(buf, &tmp, sizeof(*buf)); + CDEBUG(D_SUPER, "statfs returns avail %ld\n", tmp.f_bavail); EXIT; return err; @@ -309,10 +309,10 @@ static int ll_statfs(struct super_block *sb, struct statfs *buf) static void inline ll_to_inode(struct inode *dst, struct mds_rep *rep) { - struct ll_inode_info *ii = - (struct ll_inode_info *) &dst->u.generic_ip; + struct ll_inode_info *ii = + (struct ll_inode_info *) &dst->u.generic_ip; - /* core attributes first */ + /* core attributes first */ if ( rep->valid & OBD_MD_FLID ) dst->i_ino = rep->ino; if ( rep->valid & OBD_MD_FLATIME ) @@ -336,22 +336,22 @@ static void inline ll_to_inode(struct inode *dst, struct mds_rep *rep) if ( rep->valid & OBD_MD_FLGENER ) dst->i_generation = rep->generation; - /* this will become more elaborate for striping etc */ - if (rep->valid & OBD_MD_FLOBJID) - ii->lli_objid = rep->objid; + /* this will become more elaborate for striping etc */ + if (rep->valid & OBD_MD_FLOBJID) + ii->lli_objid = rep->objid; #if 0 if (obdo_has_inline(oa)) { - if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || - S_ISFIFO(inode->i_mode)) { - obd_rdev rdev = *((obd_rdev *)oa->o_inline); - CDEBUG(D_INODE, - "copying device %x from obdo to inode\n", rdev); - init_special_inode(inode, inode->i_mode, rdev); - } else { - CDEBUG(D_INFO, "copying inline from obdo to inode\n"); - memcpy(oinfo->lli_inline, oa->o_inline, OBD_INLINESZ); - } + if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || + S_ISFIFO(inode->i_mode)) { + obd_rdev rdev = *((obd_rdev *)oa->o_inline); + CDEBUG(D_INODE, + "copying device %x from obdo to inode\n", rdev); + init_special_inode(inode, inode->i_mode, rdev); + } else { + CDEBUG(D_INFO, "copying inline from obdo to inode\n"); + memcpy(oinfo->lli_inline, oa->o_inline, OBD_INLINESZ); + } oinfo->lli_flags |= OBD_FL_INLINEDATA; } #endif @@ -359,10 +359,10 @@ static void inline ll_to_inode(struct inode *dst, struct mds_rep *rep) static inline void ll_read_inode2(struct inode *inode, void *opaque) { - struct mds_rep *rep = opaque; - - ENTRY; - ll_to_inode(inode, rep); + struct mds_rep *rep = opaque; + + ENTRY; + ll_to_inode(inode, rep); /* OIDEBUG(inode); */ @@ -377,21 +377,21 @@ static inline void ll_read_inode2(struct inode *inode, void *opaque) inode->i_mapping->a_ops = &ll_dir_aops; EXIT; } else if (S_ISLNK(inode->i_mode)) { - inode->i_op = &ll_fast_symlink_inode_operations; + inode->i_op = &ll_fast_symlink_inode_operations; EXIT; } else { init_special_inode(inode, inode->i_mode, ((int *)ll_i2info(inode)->lli_inline)[0]); } - EXIT; + EXIT; return; } /* exported operations */ struct super_operations ll_super_operations = { - read_inode2: ll_read_inode2, + read_inode2: ll_read_inode2, delete_inode: ll_delete_inode, put_super: ll_put_super, // statfs: ll_statfs @@ -404,11 +404,11 @@ struct file_system_type lustre_light_fs_type = { static int __init init_lustre_light(void) { printk(KERN_INFO "Lustre Light 0.0.1, braam@clusterfs.com\n"); - ll_file_data_slab = kmem_cache_create("ll_file_data", - sizeof(struct ll_file_data), 0, - SLAB_HWCACHE_ALIGN, NULL, NULL); - if (ll_file_data_slab == NULL) - return -ENOMEM; + ll_file_data_slab = kmem_cache_create("ll_file_data", + sizeof(struct ll_file_data), 0, + SLAB_HWCACHE_ALIGN, NULL, NULL); + if (ll_file_data_slab == NULL) + return -ENOMEM; return register_filesystem(&lustre_light_fs_type); } @@ -416,7 +416,7 @@ static int __init init_lustre_light(void) static void __exit exit_lustre_light(void) { unregister_filesystem(&lustre_light_fs_type); - kmem_cache_destroy(ll_file_data_slab); + kmem_cache_destroy(ll_file_data_slab); } MODULE_AUTHOR("Peter J. Braam "); diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index 7ae78f7..2aa4c39 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -170,6 +170,7 @@ static int mds_reint_create(struct mds_update_record *rec, dchild->d_inode->i_uid = rec->ur_uid; dchild->d_inode->i_gid = rec->ur_gid; rep->ino = dchild->d_inode->i_ino; + rep->generation = dchild->d_inode->i_generation; } out_reint_create: