From d61fd72a57c131d01c3366fb34e50c6d373656c5 Mon Sep 17 00:00:00 2001 From: ccooper Date: Wed, 15 Sep 2004 21:53:38 +0000 Subject: [PATCH] r=adilger,nic - landing b1_4_smallfix --- lustre/mds/mds_unlink_open.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/lustre/mds/mds_unlink_open.c b/lustre/mds/mds_unlink_open.c index 7e52834..6f7e3da 100644 --- a/lustre/mds/mds_unlink_open.c +++ b/lustre/mds/mds_unlink_open.c @@ -100,25 +100,14 @@ static int mds_unlink_orphan(struct obd_device *obd, struct dentry *dchild, LASSERT(mds->mds_osc_obd != NULL); - OBD_ALLOC(lmm, mds->mds_max_mdsize); + lmm_size = mds->mds_max_mdsize; + OBD_ALLOC(lmm, lmm_size); if (lmm == NULL) RETURN(-ENOMEM); - down(&inode->i_sem); - rc = fsfilt_get_md(obd, inode, lmm, mds->mds_max_mdsize); - up(&inode->i_sem); - - if (rc < 0) { - CERROR("Error %d reading eadata for ino %lu\n", - rc, inode->i_ino); + rc = mds_get_md(obd, inode, lmm, &lmm_size, 1); + if (rc < 0) GOTO(out_free_lmm, rc); - } else if (rc > 0) { - lmm_size = rc; - rc = mds_convert_lov_ea(obd, inode, lmm, lmm_size); - if (rc > 0) - lmm_size = rc; - rc = 0; - } handle = fsfilt_start_log(obd, pending_dir, FSFILT_OP_UNLINK, NULL, le32_to_cpu(lmm->lmm_stripe_count)); @@ -175,8 +164,8 @@ int mds_cleanup_orphans(struct obd_device *obd) struct l_linux_dirent *dirent, *n; struct list_head dentry_list; char d_name[LL_FID_NAMELEN]; - __u64 i = 0; - int rc = 0, item = 0, namlen; + unsigned long inum; + int i = 0, rc = 0, item = 0, namlen; ENTRY; push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); @@ -199,21 +188,20 @@ int mds_cleanup_orphans(struct obd_device *obd) GOTO(err_out, rc); list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) { - i ++; + i++; list_del(&dirent->lld_list); namlen = strlen(dirent->lld_name); LASSERT(sizeof(d_name) >= namlen + 1); strcpy(d_name, dirent->lld_name); + inum = dirent->lld_ino; OBD_FREE(dirent, sizeof(*dirent)); - CDEBUG(D_INODE, "entry "LPU64" of PENDING DIR: %s\n", - i, d_name); + CDEBUG(D_INODE, "entry %d of PENDING DIR: %s\n", i, d_name); if (((namlen == 1) && !strcmp(d_name, ".")) || - ((namlen == 2) && !strcmp(d_name, ".."))) { + ((namlen == 2) && !strcmp(d_name, "..")) || inum == 0) continue; - } down(&pending_dir->i_sem); dchild = lookup_one_len(d_name, mds->mds_pending_dir, namlen); @@ -226,6 +214,13 @@ int mds_cleanup_orphans(struct obd_device *obd) GOTO(next, rc = 0); } + if (is_bad_inode(dchild->d_inode)) { + CERROR("bad orphan inode found %lu/%u\n", + dchild->d_inode->i_ino, + dchild->d_inode->i_generation); + GOTO(next, rc = -ENOENT); + } + child_inode = dchild->d_inode; DOWN_READ_I_ALLOC_SEM(child_inode); if (mds_inode_is_orphan(child_inode) && -- 1.8.3.1