X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fosd-ldiskfs%2Fosd_compat.c;h=2c4098b4dc7b8dd8704317da655bbfb55e4d72bb;hp=22e4ff86f6b831d59292765856d0a055c152deff;hb=f52ece3201af131a7bb8a7b2766d3f0a98c00fca;hpb=2fab4932f388da3ada7a9d68d862f9637fca5f10 diff --git a/lustre/osd-ldiskfs/osd_compat.c b/lustre/osd-ldiskfs/osd_compat.c index 22e4ff8..2c4098b 100644 --- a/lustre/osd-ldiskfs/osd_compat.c +++ b/lustre/osd-ldiskfs/osd_compat.c @@ -55,6 +55,7 @@ #include #include "osd_internal.h" +#include "osd_oi.h" struct osd_compat_objid_seq { /* protects on-fly initialization */ @@ -203,13 +204,11 @@ int osd_last_rcvd_subdir_count(struct osd_device *osd) rc = -EFAULT; dput(dlast); return rc; - } else { - count = FILTER_SUBDIR_COUNT; } out: dput(dlast); LASSERT(count > 0); - return rc; + return count; } void osd_compat_fini(struct osd_device *dev) @@ -315,16 +314,16 @@ int osd_compat_del_entry(struct osd_thread_info *info, struct osd_device *osd, child->d_parent = dird; child->d_inode = NULL; - LOCK_INODE_MUTEX(dir); - rc = -ENOENT; - bh = osd_ldiskfs_find_entry(dir, child, &de, NULL); - if (bh) { - rc = ldiskfs_delete_entry(oh->ot_handle, dir, de, bh); - brelse(bh); - } - UNLOCK_INODE_MUTEX(dir); + mutex_lock(&dir->i_mutex); + rc = -ENOENT; + bh = osd_ldiskfs_find_entry(dir, child, &de, NULL); + if (bh) { + rc = ldiskfs_delete_entry(oh->ot_handle, dir, de, bh); + brelse(bh); + } + mutex_unlock(&dir->i_mutex); - RETURN(rc); + RETURN(rc); } int osd_compat_add_entry(struct osd_thread_info *info, struct osd_device *osd, @@ -344,8 +343,7 @@ int osd_compat_add_entry(struct osd_thread_info *info, struct osd_device *osd, inode = &info->oti_inode; inode->i_sb = osd_sb(osd); - inode->i_ino = id->oii_ino; - inode->i_generation = id->oii_gen; + osd_id_to_inode(inode, id); child = &info->oti_child_dentry; child->d_name.hash = 0; @@ -354,11 +352,11 @@ int osd_compat_add_entry(struct osd_thread_info *info, struct osd_device *osd, child->d_parent = dir; child->d_inode = inode; - LOCK_INODE_MUTEX(dir->d_inode); - rc = osd_ldiskfs_add_entry(oh->ot_handle, child, inode, NULL); - UNLOCK_INODE_MUTEX(dir->d_inode); + mutex_lock(&dir->d_inode->i_mutex); + rc = osd_ldiskfs_add_entry(oh->ot_handle, child, inode, NULL); + mutex_unlock(&dir->d_inode->i_mutex); - RETURN(rc); + RETURN(rc); } int osd_compat_objid_lookup(struct osd_thread_info *info, @@ -369,12 +367,12 @@ int osd_compat_objid_lookup(struct osd_thread_info *info, struct dentry *d; struct dentry *d_seq; struct ost_id *ostid = &info->oti_ostid; - int rc = 0; int dirn; char name[32]; struct ldiskfs_dir_entry_2 *de; struct buffer_head *bh; struct inode *dir; + struct inode *inode; ENTRY; /* on the very first lookup we find and open directories */ @@ -400,30 +398,23 @@ int osd_compat_objid_lookup(struct osd_thread_info *info, /* XXX: we can use rc from sprintf() instead of strlen() */ d_seq->d_name.len = strlen(name); - dir = d->d_inode; - LOCK_INODE_MUTEX(dir); - bh = osd_ldiskfs_find_entry(dir, d_seq, &de, NULL); - UNLOCK_INODE_MUTEX(dir); + dir = d->d_inode; + mutex_lock(&dir->i_mutex); + bh = osd_ldiskfs_find_entry(dir, d_seq, &de, NULL); + mutex_unlock(&dir->i_mutex); - rc = -ENOENT; - if (bh) { - struct inode *inode; + if (bh == NULL) + RETURN(-ENOENT); - id->oii_ino = le32_to_cpu(de->inode); - brelse(bh); + osd_id_gen(id, le32_to_cpu(de->inode), OSD_OII_NOGEN); + brelse(bh); - id->oii_gen = OSD_OII_NOGEN; - inode = osd_iget(info, dev, id); + inode = osd_iget(info, dev, id); + if (IS_ERR(inode)) + RETURN(PTR_ERR(inode)); - if (IS_ERR(inode)) - GOTO(cleanup, rc = PTR_ERR(inode)); - rc = 0; - id->oii_gen = inode->i_generation; - iput(inode); - } - -cleanup: - RETURN(rc); + iput(inode); + RETURN(0); } int osd_compat_objid_insert(struct osd_thread_info *info, @@ -492,20 +483,22 @@ struct named_oid { }; static const struct named_oid oids[] = { - { FLD_INDEX_OID, "" /* "fld" */ }, - { FID_SEQ_CTL_OID, "" /* "seq_ctl" */ }, - { FID_SEQ_SRV_OID, "" /* "seq_srv" */ }, - { MDD_ROOT_INDEX_OID, "" /* "ROOT" */ }, - { MDD_ORPHAN_OID, "" /* "PENDING" */ }, - { MDD_LOV_OBJ_OID, "" /* LOV_OBJID */ }, - { MDD_CAPA_KEYS_OID, "" /* CAPA_KEYS */ }, + { FLD_INDEX_OID, "" /* "fld" */ }, + { FID_SEQ_CTL_OID, "" /* "seq_ctl" */ }, + { FID_SEQ_SRV_OID, "" /* "seq_srv" */ }, + { MDD_ROOT_INDEX_OID, "" /* "ROOT" */ }, + { MDD_ORPHAN_OID, "" /* "PENDING" */ }, + { MDD_LOV_OBJ_OID, "" /* LOV_OBJID */ }, + { MDD_CAPA_KEYS_OID, "" /* CAPA_KEYS */ }, { MDT_LAST_RECV_OID, LAST_RCVD }, - { OFD_LAST_RECV_OID, "" /* LAST_RCVD */ }, - { OFD_LAST_GROUP_OID, "" /* "LAST_GROUP" */ }, - { LLOG_CATALOGS_OID, "" /* "CATALOGS" */ }, - { MGS_CONFIGS_OID, "" /* MOUNT_CONFIGS_DIR */ }, - { OFD_HEALTH_CHECK_OID, "" /* HEALTH_CHECK */ }, - { 0, NULL } + { LFSCK_BOOKMARK_OID, "" /* "lfsck_bookmark" */ }, + { OTABLE_IT_OID, "" /* "otable iterator" */}, + { OFD_LAST_RECV_OID, "" /* LAST_RCVD */ }, + { OFD_LAST_GROUP_OID, "LAST_GROUP" }, + { LLOG_CATALOGS_OID, "" /* "CATALOGS" */ }, + { MGS_CONFIGS_OID, "" /* MOUNT_CONFIGS_DIR */ }, + { OFD_HEALTH_CHECK_OID, HEALTH_CHECK }, + { 0, NULL } }; static char *oid2name(const unsigned long oid) @@ -551,33 +544,33 @@ int osd_compat_spec_insert(struct osd_thread_info *info, } int osd_compat_spec_lookup(struct osd_thread_info *info, - struct osd_device *osd, const struct lu_fid *fid, - struct osd_inode_id *id) + struct osd_device *osd, const struct lu_fid *fid, + struct osd_inode_id *id) { - struct dentry *dentry; - char *name; - int rc = -ERESTART; - - ENTRY; + struct dentry *dentry; + struct inode *inode; + char *name; + int rc = -ENOENT; + ENTRY; - name = oid2name(fid_oid(fid)); - if (name == NULL || strlen(name) == 0) - return -ERESTART; - - dentry = ll_lookup_one_len(name, osd_sb(osd)->s_root, strlen(name)); - if (!IS_ERR(dentry)) { - if (dentry->d_inode) { - if (is_bad_inode(dentry->d_inode)) { - rc = -EIO; - } else { - id->oii_ino = dentry->d_inode->i_ino; - id->oii_gen = dentry->d_inode->i_generation; - rc = 0; - } - } - dput(dentry); - } + name = oid2name(fid_oid(fid)); + if (name == NULL || strlen(name) == 0) + RETURN(-ENOENT); + + dentry = ll_lookup_one_len(name, osd_sb(osd)->s_root, strlen(name)); + if (!IS_ERR(dentry)) { + inode = dentry->d_inode; + if (inode) { + if (is_bad_inode(inode)) { + rc = -EIO; + } else { + osd_id_gen(id, inode->i_ino, + inode->i_generation); + rc = 0; + } + } + dput(dentry); + } - RETURN(rc); + RETURN(rc); } -