X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosd-ldiskfs%2Fosd_compat.c;h=552877945b3fe0370ee01b2da43d1d1db0fdf2df;hb=c74fd3b0fb5edc7af092e37d9cc453f5edaace85;hp=637b1bd80b17e3eb5ee783763daab081c44e9ae5;hpb=323293bab2c8d65c6f1c0b3c04671ed073719cbe;p=fs%2Flustre-release.git diff --git a/lustre/osd-ldiskfs/osd_compat.c b/lustre/osd-ldiskfs/osd_compat.c index 637b1bd..5528779 100644 --- a/lustre/osd-ldiskfs/osd_compat.c +++ b/lustre/osd-ldiskfs/osd_compat.c @@ -15,11 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -225,6 +221,7 @@ int osd_add_to_remote_parent(const struct lu_env *env, struct osd_device *osd, struct osd_thread_info *oti = osd_oti_get(env); struct lustre_mdt_attrs *lma = &oti->oti_mdt_attrs; char *name = oti->oti_name; + struct osd_thread_info *info = osd_oti_get(env); struct dentry *dentry; struct dentry *parent; int rc; @@ -247,8 +244,8 @@ int osd_add_to_remote_parent(const struct lu_env *env, struct osd_device *osd, dentry = osd_child_dentry_by_inode(env, parent->d_inode, name, strlen(name)); mutex_lock(&parent->d_inode->i_mutex); - rc = osd_ldiskfs_add_entry(oh->ot_handle, dentry, obj->oo_inode, - NULL); + rc = osd_ldiskfs_add_entry(info, osd, oh->ot_handle, dentry, + obj->oo_inode, NULL); CDEBUG(D_INODE, "%s: add %s:%lu to remote parent %lu.\n", osd_name(osd), name, obj->oo_inode->i_ino, parent->d_inode->i_ino); ldiskfs_inc_count(oh->ot_handle, parent->d_inode); @@ -274,8 +271,12 @@ int osd_delete_from_remote_parent(const struct lu_env *env, /* Check lma to see whether it is remote object */ rc = osd_get_lma(oti, obj->oo_inode, &oti->oti_obj_dentry, lma); - if (rc != 0) + if (rc != 0) { + /* No LMA if the directory is created before 2.0 */ + if (rc == -ENODATA) + rc = 0; RETURN(rc); + } if (likely(!(lma->lma_incompat & LMAI_REMOTE_PARENT))) RETURN(0); @@ -287,9 +288,9 @@ int osd_delete_from_remote_parent(const struct lu_env *env, mutex_lock(&parent->d_inode->i_mutex); bh = osd_ldiskfs_find_entry(parent->d_inode, &dentry->d_name, &de, NULL, NULL); - if (bh == NULL) { + if (IS_ERR(bh)) { mutex_unlock(&parent->d_inode->i_mutex); - RETURN(-ENOENT); + RETURN(PTR_ERR(bh)); } CDEBUG(D_INODE, "%s: el %s:%lu to remote parent %lu.\n", osd_name(osd), name, obj->oo_inode->i_ino, parent->d_inode->i_ino); @@ -328,12 +329,22 @@ int osd_lookup_in_remote_parent(struct osd_thread_info *oti, mutex_lock(&parent->d_inode->i_mutex); bh = osd_ldiskfs_find_entry(parent->d_inode, &dentry->d_name, &de, NULL, NULL); - if (bh == NULL) { - rc = -ENOENT; + if (IS_ERR(bh)) { + rc = PTR_ERR(bh); } else { - rc = 0; + struct inode *inode; + osd_id_gen(id, le32_to_cpu(de->inode), OSD_OII_NOGEN); brelse(bh); + inode = osd_iget(oti, osd, id); + if (IS_ERR(inode)) { + rc = PTR_ERR(inode); + if (rc == -ESTALE) + rc = -ENOENT; + } else { + iput(inode); + rc = 0; + } } mutex_unlock(&parent->d_inode->i_mutex); if (rc == 0) @@ -420,13 +431,10 @@ cleanup_alloc: return rc; } -static void osd_seq_free(struct osd_obj_map *map, - struct osd_obj_seq *osd_seq) +static void osd_seq_free(struct osd_obj_seq *osd_seq) { int j; - list_del_init(&osd_seq->oos_seq_list); - if (osd_seq->oos_dirs) { for (j = 0; j < osd_seq->oos_subdir_count; j++) { if (osd_seq->oos_dirs[j]) @@ -455,7 +463,10 @@ static void osd_ost_fini(struct osd_device *osd) write_lock(&map->om_seq_list_lock); list_for_each_entry_safe(osd_seq, tmp, &map->om_seq_list, oos_seq_list) { - osd_seq_free(map, osd_seq); + list_del_init(&osd_seq->oos_seq_list); + write_unlock(&map->om_seq_list_lock); + osd_seq_free(osd_seq); + write_lock(&map->om_seq_list_lock); } write_unlock(&map->om_seq_list_lock); if (map->om_root) @@ -548,8 +559,8 @@ static int osd_obj_update_entry(struct osd_thread_info *info, ll_vfs_dq_init(parent); mutex_lock(&parent->i_mutex); bh = osd_ldiskfs_find_entry(parent, &child->d_name, &de, NULL, NULL); - if (bh == NULL) - GOTO(out, rc = -ENOENT); + if (IS_ERR(bh)) + GOTO(out, rc = PTR_ERR(bh)); if (le32_to_cpu(de->inode) == id->oii_ino) GOTO(out, rc = 1); @@ -563,6 +574,13 @@ static int osd_obj_update_entry(struct osd_thread_info *info, GOTO(out, rc); } + /* The EA inode should NOT be in OI, old OI scrub may added + * such OI mapping by wrong, replace it. */ + if (unlikely(osd_is_ea_inode(inode))) { + iput(inode); + goto update; + } + rc = osd_get_lma(info, inode, dentry, lma); if (rc == -ENODATA) { rc = osd_get_idif(info, inode, dentry, oi_fid); @@ -644,7 +662,8 @@ update: GOTO(out, rc); out: - brelse(bh); + if (!IS_ERR(bh)) + brelse(bh); mutex_unlock(&parent->i_mutex); return rc; } @@ -674,9 +693,10 @@ static int osd_obj_del_entry(struct osd_thread_info *info, ll_vfs_dq_init(dir); mutex_lock(&dir->i_mutex); - rc = -ENOENT; bh = osd_ldiskfs_find_entry(dir, &child->d_name, &de, NULL, NULL); - if (bh) { + if (IS_ERR(bh)) { + rc = PTR_ERR(bh); + } else { rc = ldiskfs_delete_entry(th, dir, de, bh); brelse(bh); } @@ -728,14 +748,14 @@ static int osd_obj_add_entry(struct osd_thread_info *info, ll_vfs_dq_init(dir->d_inode); mutex_lock(&dir->d_inode->i_mutex); - rc = osd_ldiskfs_add_entry(th, child, inode, NULL); + rc = osd_ldiskfs_add_entry(info, osd, th, child, inode, NULL); mutex_unlock(&dir->d_inode->i_mutex); RETURN(rc); } /** - * Use LPU64 for legacy OST sequences, but use LPX64i for new + * Use %llu for legacy OST sequences, but use %llx for new * sequences names, so that the O/{seq}/dN/{oid} more closely * follows the DFID/PFID format. This makes it easier to map from * debug messages to objects in the future, and the legacy space @@ -745,7 +765,7 @@ static inline void osd_seq_name(char *seq_name, size_t name_size, u64 seq) { snprintf(seq_name, name_size, (fid_seq_is_rsvd(seq) || - fid_seq_is_mdt0(seq)) ? LPU64 : LPX64i, + fid_seq_is_mdt0(seq)) ? "%llu" : "%llx", fid_seq_is_idif(seq) ? 0 : seq); } @@ -755,7 +775,7 @@ static inline void osd_oid_name(char *name, size_t name_size, snprintf(name, name_size, (fid_seq_is_rsvd(fid_seq(fid)) || fid_seq_is_mdt0(fid_seq(fid)) || - fid_seq_is_idif(fid_seq(fid))) ? LPU64 : LPX64i, id); + fid_seq_is_idif(fid_seq(fid))) ? "%llu" : "%llx", id); } /* external locking is required */ @@ -945,8 +965,8 @@ int osd_obj_map_lookup(struct osd_thread_info *info, struct osd_device *dev, bh = osd_ldiskfs_find_entry(dir, &child->d_name, &de, NULL, NULL); mutex_unlock(&dir->i_mutex); - if (bh == NULL) - RETURN(-ENOENT); + if (IS_ERR(bh)) + RETURN(PTR_ERR(bh)); osd_id_gen(id, le32_to_cpu(de->inode), OSD_OII_NOGEN); brelse(bh); @@ -1128,7 +1148,7 @@ int osd_obj_map_recover(struct osd_thread_info *info, mutex_lock(&src_parent->i_mutex); mutex_lock(&dir->i_mutex); bh = osd_ldiskfs_find_entry(dir, &tgt_child->d_name, &de, NULL, NULL); - if (bh != NULL) { + if (!IS_ERR(bh)) { /* XXX: If some other object occupied the same slot. And If such * inode is zero-sized and with SUID+SGID, then means it is * a new created one. Maybe we can remove it and insert the @@ -1164,15 +1184,15 @@ int osd_obj_map_recover(struct osd_thread_info *info, bh = osd_ldiskfs_find_entry(src_parent, &src_child->d_name, &de, NULL, NULL); - if (unlikely(bh == NULL)) - GOTO(unlock, rc = -ENOENT); + if (unlikely(IS_ERR(bh))) + GOTO(unlock, rc = PTR_ERR(bh)); rc = ldiskfs_delete_entry(jh, src_parent, de, bh); brelse(bh); if (rc != 0) GOTO(unlock, rc); - rc = osd_ldiskfs_add_entry(jh, tgt_child, inode, NULL); + rc = osd_ldiskfs_add_entry(info, osd, jh, tgt_child, inode, NULL); GOTO(unlock, rc);