From: adilger Date: Thu, 17 Feb 2005 18:01:09 +0000 (+0000) Subject: Land b1_4_smallfix onto b1_4 (20050210_1537) X-Git-Tag: v1_8_0_110~486^5~18 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=43c4acaac3912fd0c0b369dda60d6110651791bf;p=fs%2Flustre-release.git Land b1_4_smallfix onto b1_4 (20050210_1537) Fix build problem for older kernels which don't have i_alloc_sem. Use MDS_{UP,DOWN}_{READ,WRITE}_ORPHAN_SEM() to lock the MDS orphan information to avoid a confusing name conflict. b=5700 --- diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index 51e8054..b95f962 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -297,23 +297,21 @@ static inline int mapping_has_pages(struct address_space *mapping) #endif #ifdef HAVE_I_ALLOC_SEM -#define UP_WRITE_I_ALLOC_SEM(i) do { up_write(&(i)->i_alloc_sem); } while (0) +#define UP_WRITE_I_ALLOC_SEM(i) do { up_write(&(i)->i_alloc_sem); } while (0) #define DOWN_WRITE_I_ALLOC_SEM(i) do { down_write(&(i)->i_alloc_sem); } while(0) -#define LASSERT_MDS_ORPHAN_WRITE_LOCKED(i) LASSERT(down_read_trylock(&(i)->i_alloc_sem) == 0) +#define LASSERT_I_ALLOC_SEM_WRITE_LOCKED(i) LASSERT(down_read_trylock(&(i)->i_alloc_sem) == 0) -#define UP_READ_I_ALLOC_SEM(i) do { up_read(&(i)->i_alloc_sem); } while (0) -#define DOWN_READ_I_ALLOC_SEM(i) do { down_read(&(i)->i_alloc_sem); } while (0) -#define LASSERT_MDS_ORPHAN_READ_LOCKED(i) LASSERT(down_write_trylock(&(i)->i_alloc_sem) == 0) -#define MDS_PACK_MD_LOCK 1 +#define UP_READ_I_ALLOC_SEM(i) do { up_read(&(i)->i_alloc_sem); } while (0) +#define DOWN_READ_I_ALLOC_SEM(i) do { down_read(&(i)->i_alloc_sem); } while (0) +#define LASSERT_I_ALLOC_SEM_READ_LOCKED(i) LASSERT(down_write_trylock(&(i)->i_alloc_sem) == 0) #else -#define UP_READ_I_ALLOC_SEM(i) do { up(&(i)->i_sem); } while (0) -#define DOWN_READ_I_ALLOC_SEM(i) do { down(&(i)->i_sem); } while (0) -#define LASSERT_MDS_ORPHAN_READ_LOCKED(i) LASSERT(down_trylock(&(i)->i_sem) != 0) - -#define UP_WRITE_I_ALLOC_SEM(i) do { up(&(i)->i_sem); } while (0) -#define DOWN_WRITE_I_ALLOC_SEM(i) do { down(&(i)->i_sem); } while (0) -#define LASSERT_MDS_ORPHAN_WRITE_LOCKED(i) LASSERT(down_trylock(&(i)->i_sem) != 0) -#define MDS_PACK_MD_LOCK 0 +#define UP_READ_I_ALLOC_SEM(i) do { } while (0) +#define DOWN_READ_I_ALLOC_SEM(i) do { } while (0) +#define LASSERT_I_ALLOC_SEM_READ_LOCKED(i) do { } while (0) + +#define UP_WRITE_I_ALLOC_SEM(i) do { } while (0) +#define DOWN_WRITE_I_ALLOC_SEM(i) do { } while (0) +#define LASSERT_I_ALLOC_SEM_WRITE_LOCKED(i) do { } while (0) #endif #ifndef HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index deadf5b..bd7aca6 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1019,15 +1019,15 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr) /* bug 1639: avoid write/truncate i_sem/DLM deadlock */ LASSERT(atomic_read(&inode->i_sem.count) <= 0); up(&inode->i_sem); - up_write(&inode->i_alloc_sem); + UP_WRITE_I_ALLOC_SEM(inode); rc = ll_extent_lock(NULL, inode, lsm, LCK_PW, &policy, &lockh, ast_flags); #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) - down_write(&inode->i_alloc_sem); + DOWN_WRITE_I_ALLOC_SEM(inode); down(&inode->i_sem); #else down(&inode->i_sem); - down_write(&inode->i_alloc_sem); + DOWN_WRITE_I_ALLOC_SEM(inode); #endif if (rc != 0) RETURN(rc); @@ -1037,16 +1037,16 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr) /* We need to drop the semaphore here, because this unlock may * result in a cancellation, which will need the i_sem */ up(&inode->i_sem); - up_write(&inode->i_alloc_sem); + UP_WRITE_I_ALLOC_SEM(inode); /* unlock now as we don't mind others file lockers racing with * the mds updates below? */ err = ll_extent_unlock(NULL, inode, lsm, LCK_PW, &lockh); #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) - down_write(&inode->i_alloc_sem); + DOWN_WRITE_I_ALLOC_SEM(inode); down(&inode->i_sem); #else down(&inode->i_sem); - down_write(&inode->i_alloc_sem); + DOWN_WRITE_I_ALLOC_SEM(inode); #endif if (err) { CERROR("ll_extent_unlock failed: %d\n", err); diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 2cf39f1..8fcf2e1 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -346,9 +346,9 @@ static int mds_destroy_export(struct obd_export *export) dentry->d_name.len, dentry->d_name.name, ll_bdevname(dentry->d_inode->i_sb, btmp), dentry->d_inode->i_ino); - /* child inode->i_alloc_sem protects orphan_dec_test and + /* child orphan sem protects orphan_dec_test and * is_orphan race, mds_mfd_close drops it */ - DOWN_WRITE_I_ALLOC_SEM(dentry->d_inode); + MDS_DOWN_WRITE_ORPHAN_SEM(dentry->d_inode); rc = mds_mfd_close(NULL, obd, mfd, !(export->exp_flags & OBD_OPT_FAILOVER)); diff --git a/lustre/mds/mds_internal.h b/lustre/mds/mds_internal.h index 0337772..11ff9e9 100644 --- a/lustre/mds/mds_internal.h +++ b/lustre/mds/mds_internal.h @@ -30,6 +30,26 @@ static inline struct mds_obd *mds_req2mds(struct ptlrpc_request *req) # define mds_inode_oatomic(inode) ((inode)->i_attr_flags) #endif +#ifdef HAVE_I_ALLOC_SEM +#define MDS_UP_READ_ORPHAN_SEM(i) UP_READ_I_ALLOC_SEM(i) +#define MDS_DOWN_READ_ORPHAN_SEM(i) DOWN_READ_I_ALLOC_SEM(i) +#define LASSERT_MDS_ORPHAN_READ_LOCKED(i) LASSERT_I_ALLOC_SEM_READ_LOCKED(i) + +#define MDS_UP_WRITE_ORPHAN_SEM(i) UP_WRITE_I_ALLOC_SEM(i) +#define MDS_DOWN_WRITE_ORPHAN_SEM(i) DOWN_WRITE_I_ALLOC_SEM(i) +#define LASSERT_MDS_ORPHAN_WRITE_LOCKED(i) LASSERT_I_ALLOC_SEM_WRITE_LOCKED(i) +#define MDS_PACK_MD_LOCK 1 +#else +#define MDS_UP_READ_ORPHAN_SEM(i) do { up(&(i)->i_sem); } while (0) +#define MDS_DOWN_READ_ORPHAN_SEM(i) do { down(&(i)->i_sem); } while (0) +#define LASSERT_MDS_ORPHAN_READ_LOCKED(i) LASSERT(down_trylock(&(i)->i_sem)!=0) + +#define MDS_UP_WRITE_ORPHAN_SEM(i) do { up(&(i)->i_sem); } while (0) +#define MDS_DOWN_WRITE_ORPHAN_SEM(i) do { down(&(i)->i_sem); } while (0) +#define LASSERT_MDS_ORPHAN_WRITE_LOCKED(i) LASSERT(down_trylock(&(i)->i_sem)!=0) +#define MDS_PACK_MD_LOCK 0 +#endif + static inline int mds_orphan_open_count(struct inode *inode) { LASSERT_MDS_ORPHAN_READ_LOCKED(inode); @@ -49,16 +69,19 @@ static inline int mds_orphan_open_dec_test(struct inode *inode) } #define mds_inode_is_orphan(inode) ((inode)->i_flags & 0x4000000) -#define mds_inode_set_orphan(inode) \ -do { \ - (inode)->i_flags |= 0x4000000; \ - CDEBUG(D_VFSTRACE, "setting orphan flag on inode %p\n", inode); \ -} while (0) -#define mds_inode_unset_orphan(inode) \ -do { \ - (inode)->i_flags &= ~(0x4000000); \ - CDEBUG(D_VFSTRACE, "removing orphan flag from inode %p\n", inode); \ -} while (0) + +static inline void mds_inode_set_orphan(struct inode *inode) +{ + inode->i_flags |= 0x4000000; + CDEBUG(D_VFSTRACE, "setting orphan flag on inode %p\n", inode); +} + +static inline void mds_inode_unset_orphan(struct inode *inode) +{ + inode->i_flags &= ~(0x4000000); + CDEBUG(D_VFSTRACE, "removing orphan flag from inode %p\n", inode); +} + #endif /* __KERNEL__ */ #define MDS_CHECK_RESENT(req, reconstruct) \ diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c index 896b101..f135417 100644 --- a/lustre/mds/mds_open.c +++ b/lustre/mds/mds_open.c @@ -267,9 +267,9 @@ static struct mds_file_data *mds_dentry_open(struct dentry *dentry, dget(dentry); /* Mark the file as open to handle open-unlink. */ - DOWN_WRITE_I_ALLOC_SEM(dentry->d_inode); + MDS_DOWN_WRITE_ORPHAN_SEM(dentry->d_inode); mds_orphan_open_inc(dentry->d_inode); - UP_WRITE_I_ALLOC_SEM(dentry->d_inode); + MDS_UP_WRITE_ORPHAN_SEM(dentry->d_inode); mfd->mfd_mode = flags; mfd->mfd_dentry = dentry; @@ -1066,7 +1066,7 @@ int mds_mfd_close(struct ptlrpc_request *req, struct obd_device *obd, last_orphan = mds_orphan_open_dec_test(inode) && mds_inode_is_orphan(inode); - UP_WRITE_I_ALLOC_SEM(inode); + MDS_UP_WRITE_ORPHAN_SEM(inode); /* this is half of the actual "close" */ if (mfd->mfd_mode & FMODE_WRITE) { @@ -1258,8 +1258,8 @@ int mds_close(struct ptlrpc_request *req) } inode = mfd->mfd_dentry->d_inode; - /* child i_alloc_sem protects orphan_dec_test && is_orphan race */ - DOWN_WRITE_I_ALLOC_SEM(inode); /* mds_mfd_close drops this */ + /* child orphan sem protects orphan_dec_test && is_orphan race */ + MDS_DOWN_WRITE_ORPHAN_SEM(inode); /* mds_mfd_close drops this */ if (mds_inode_is_orphan(inode) && mds_orphan_open_count(inode) == 1) { body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); LASSERT(body != NULL); diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index 7735318..a65bb88 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -1253,9 +1253,9 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset, body = lustre_msg_buf(req->rq_repmsg, offset, sizeof (*body)); LASSERT(body != NULL); - /* child i_alloc_sem protects orphan_dec_test && is_orphan race */ - DOWN_READ_I_ALLOC_SEM(child_inode); - cleanup_phase = 4; /* up(&child_inode->i_sem) when finished */ + /* child orphan sem protects orphan_dec_test && is_orphan race */ + MDS_DOWN_READ_ORPHAN_SEM(child_inode); + cleanup_phase = 4; /* MDS_UP_READ_ORPHAN_SEM(new_inode) when finished */ /* If this is potentially the last reference to this inode, get the * OBD EA data first so the client can destroy OST objects. We @@ -1373,7 +1373,7 @@ cleanup: case 5: /* pending_dir semaphore */ up(&mds->mds_pending_dir->d_inode->i_sem); case 4: /* child inode semaphore */ - UP_READ_I_ALLOC_SEM(child_inode); + MDS_UP_READ_ORPHAN_SEM(child_inode); case 3: /* child ino-reuse lock */ if (rc && body != NULL) { // Don't unlink the OST objects if the MDS unlink failed @@ -1780,9 +1780,9 @@ static int mds_reint_rename(struct mds_update_record *rec, int offset, body = lustre_msg_buf(req->rq_repmsg, 0, sizeof (*body)); LASSERT(body != NULL); - /* child i_alloc_sem protects orphan_dec_test && is_orphan race */ - DOWN_READ_I_ALLOC_SEM(new_inode); - cleanup_phase = 3; /* up(&new_inode->i_sem) when finished */ + /* child orphan sem protects orphan_dec_test && is_orphan race */ + MDS_DOWN_READ_ORPHAN_SEM(new_inode); + cleanup_phase = 3; /* MDS_UP_READ_ORPHAN_SEM(new_inode) when finished */ if ((S_ISDIR(new_inode->i_mode) && new_inode->i_nlink == 2) || new_inode->i_nlink == 1) { @@ -1854,7 +1854,7 @@ cleanup: case 4: up(&mds->mds_pending_dir->d_inode->i_sem); case 3: - UP_READ_I_ALLOC_SEM(new_inode); + MDS_UP_READ_ORPHAN_SEM(new_inode); case 2: iput(new_inode); case 1: diff --git a/lustre/mds/mds_unlink_open.c b/lustre/mds/mds_unlink_open.c index f6bc83c..737299c 100644 --- a/lustre/mds/mds_unlink_open.c +++ b/lustre/mds/mds_unlink_open.c @@ -220,14 +220,14 @@ int mds_cleanup_orphans(struct obd_device *obd) } child_inode = dchild->d_inode; - DOWN_READ_I_ALLOC_SEM(child_inode); + MDS_DOWN_READ_ORPHAN_SEM(child_inode); if (mds_inode_is_orphan(child_inode) && mds_orphan_open_count(child_inode)) { - UP_READ_I_ALLOC_SEM(child_inode); + MDS_UP_READ_ORPHAN_SEM(child_inode); CWARN("orphan %s re-opened during recovery\n", d_name); GOTO(next, rc = 0); } - UP_READ_I_ALLOC_SEM(child_inode); + MDS_UP_READ_ORPHAN_SEM(child_inode); rc = mds_unlink_orphan(obd, dchild, child_inode, pending_dir); if (rc == 0) {