From da82bd04251ae371190b16ce5418e3233cc392a9 Mon Sep 17 00:00:00 2001 From: yangsheng Date: Tue, 11 Nov 2008 07:43:59 +0000 Subject: [PATCH] Branch b1_8_gate b=17153 i=adilger, robert.read Remove 2.4 check. Author: tappro CVSooi= --- lustre/lvfs/fsfilt_ext3.c | 138 ++++------------------------------------------ 1 file changed, 10 insertions(+), 128 deletions(-) diff --git a/lustre/lvfs/fsfilt_ext3.c b/lustre/lvfs/fsfilt_ext3.c index f684dc7..25b9bc9 100644 --- a/lustre/lvfs/fsfilt_ext3.c +++ b/lustre/lvfs/fsfilt_ext3.c @@ -55,19 +55,12 @@ #include #include #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#include -#else #include -#endif #include #include #include #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#include -#endif #include #include @@ -92,15 +85,6 @@ #define FSFILT_SINGLEDATA_TRANS_BLOCKS(sb) EXT3_SINGLEDATA_TRANS_BLOCKS #endif -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#define fsfilt_ext3_journal_start(inode, nblocks) \ - journal_start(EXT3_JOURNAL(inode),nblocks) -#define fsfilt_ext3_journal_stop(handle) journal_stop(handle) -#else -#define fsfilt_ext3_journal_start(inode, nblocks) ext3_journal_start(inode, nblocks) -#define fsfilt_ext3_journal_stop(handle) ext3_journal_stop(handle) -#endif - static cfs_mem_cache_t *fcb_cache; struct fsfilt_cb_data { @@ -131,9 +115,7 @@ static int fsfilt_ext3_set_label(struct super_block *sb, char *label) int err; journal = EXT3_SB(sb)->s_journal; - lock_24kernel(); handle = journal_start(journal, 1); - unlock_24kernel(); if (IS_ERR(handle)) { CERROR("can't start transaction\n"); return(PTR_ERR(handle)); @@ -149,9 +131,7 @@ static int fsfilt_ext3_set_label(struct super_block *sb, char *label) err = ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); out: - lock_24kernel(); journal_stop(handle); - unlock_24kernel(); return(err); } @@ -298,9 +278,7 @@ static void *fsfilt_ext3_start(struct inode *inode, int op, void *desc_private, journal_start: LASSERTF(nblocks > 0, "can't start %d credit transaction\n", nblocks); - lock_24kernel(); - handle = fsfilt_ext3_journal_start(inode, nblocks); - unlock_24kernel(); + handle = ext3_journal_start(inode, nblocks); if (!IS_ERR(handle)) LASSERT(current->journal_info == handle); @@ -437,9 +415,7 @@ static void *fsfilt_ext3_brw_start(int objcount, struct fsfilt_objinfo *fso, } LASSERTF(needed > 0, "can't start %d credit transaction\n", needed); - lock_24kernel(); - handle = fsfilt_ext3_journal_start(fso->fso_dentry->d_inode, needed); - unlock_24kernel(); + handle = ext3_journal_start(fso->fso_dentry->d_inode, needed); if (IS_ERR(handle)) { CERROR("can't get handle for %d credits: rc = %ld\n", needed, PTR_ERR(handle)); @@ -479,9 +455,7 @@ static int fsfilt_ext3_commit(struct inode *inode, void *h, int force_sync) if (force_sync) handle->h_sync = 1; /* recovery likes this */ - lock_24kernel(); - rc = fsfilt_ext3_journal_stop(handle); - unlock_24kernel(); + rc = ext3_journal_stop(handle); return rc; } @@ -491,36 +465,23 @@ static int fsfilt_ext3_commit_async(struct inode *inode, void *h, { unsigned long tid; transaction_t *transaction; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - unsigned long rtid; -#endif handle_t *handle = h; journal_t *journal; int rc; LASSERT(current->journal_info == handle); - lock_24kernel(); transaction = handle->h_transaction; journal = transaction->t_journal; tid = transaction->t_tid; /* we don't want to be blocked */ handle->h_sync = 0; - rc = fsfilt_ext3_journal_stop(handle); + rc = ext3_journal_stop(handle); if (rc) { CERROR("error while stopping transaction: %d\n", rc); - unlock_24kernel(); return rc; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - rtid = log_start_commit(journal, transaction); - if (rtid != tid) - CERROR("strange race: %lu != %lu\n", - (unsigned long) tid, (unsigned long) rtid); -#else log_start_commit(journal, tid); -#endif - unlock_24kernel(); *wait_handle = (void *) tid; CDEBUG(D_INODE, "commit async: %lu\n", (unsigned long) tid); @@ -549,8 +510,6 @@ static int fsfilt_ext3_setattr(struct dentry *dentry, void *handle, struct inode *inode = dentry->d_inode; int rc = 0; - lock_24kernel(); - /* Avoid marking the inode dirty on the superblock list unnecessarily. * We are already writing the inode to disk as part of this * transaction and want to avoid a lot of extra inode writeout @@ -601,7 +560,6 @@ static int fsfilt_ext3_setattr(struct dentry *dentry, void *handle, } out: - unlock_24kernel(); RETURN(rc); } @@ -632,12 +590,9 @@ static int fsfilt_ext3_set_md(struct inode *inode, void *handle, LASSERT(TRYLOCK_INODE_MUTEX(inode) == 0); - lock_24kernel(); rc = ext3_xattr_set_handle(handle, inode, EXT3_XATTR_INDEX_TRUSTED, name, lmm, lmm_size, XATTR_NO_CTIME); - unlock_24kernel(); - if (rc && rc != -EROFS) CERROR("error adding MD data to inode %lu: rc = %d\n", inode->i_ino, rc); @@ -651,12 +606,9 @@ static int fsfilt_ext3_get_md(struct inode *inode, void *lmm, int lmm_size, int rc; LASSERT(TRYLOCK_INODE_MUTEX(inode) == 0); - lock_24kernel(); rc = ext3_xattr_get(inode, EXT3_XATTR_INDEX_TRUSTED, name, lmm, lmm_size); - unlock_24kernel(); - /* This gives us the MD size */ if (lmm == NULL) return (rc == -ENODATA) ? 0 : rc; @@ -672,43 +624,11 @@ static int fsfilt_ext3_get_md(struct inode *inode, void *lmm, int lmm_size, return rc; } -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) static int fsfilt_ext3_send_bio(int rw, struct inode *inode, struct bio *bio) { submit_bio(rw, bio); return 0; } -#else -static int fsfilt_ext3_send_bio(int rw, struct inode *inode, struct kiobuf *bio) -{ - int rc, blk_per_page; - - rc = brw_kiovec(rw, 1, &bio, inode->i_dev, - KIOBUF_GET_BLOCKS(bio), 1 << inode->i_blkbits); - /* - * brw_kiovec() returns number of bytes actually written. If error - * occurred after something was written, error code is returned though - * kiobuf->errno. (See bug 6854.) - */ - - blk_per_page = CFS_PAGE_SIZE >> inode->i_blkbits; - - if (rc != (1 << inode->i_blkbits) * bio->nr_pages * blk_per_page) { - CERROR("short write? expected %d, wrote %d (%d)\n", - (1 << inode->i_blkbits) * bio->nr_pages * blk_per_page, - rc, bio->errno); - } - if (bio->errno != 0) { - CERROR("IO error. Wrote %d of %d (%d)\n", - rc, - (1 << inode->i_blkbits) * bio->nr_pages * blk_per_page, - bio->errno); - rc = bio->errno; - } - - return rc; -} -#endif static ssize_t fsfilt_ext3_readpage(struct file *file, char *buf, size_t count, loff_t *off) @@ -791,10 +711,8 @@ static int fsfilt_ext3_add_journal_cb(struct obd_device *obd, __u64 last_rcvd, fcb->cb_data = cb_data; CDEBUG(D_EXT2, "set callback for last_rcvd: "LPD64"\n", last_rcvd); - lock_24kernel(); journal_callback_set(handle, fsfilt_ext3_cb_func, (struct journal_callback *)fcb); - unlock_24kernel(); return 0; } @@ -837,10 +755,7 @@ static int fsfilt_ext3_sync(struct super_block *sb) #endif #ifdef EXT3_MULTIBLOCK_ALLOCATOR -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#define ext3_up_truncate_sem(inode) up_write(&EXT3_I(inode)->truncate_sem); -#define ext3_down_truncate_sem(inode) down_write(&EXT3_I(inode)->truncate_sem); -#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)) #define ext3_up_truncate_sem(inode) up(&EXT3_I(inode)->truncate_sem); #define ext3_down_truncate_sem(inode) down(&EXT3_I(inode)->truncate_sem); #else @@ -927,25 +842,8 @@ static int ext3_ext_find_goal(struct inode *inode, struct ext3_ext_path *path, return bg_start + colour + block; } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -#include -static void ll_unmap_underlying_metadata(struct super_block *sb, - unsigned long blocknr) -{ - struct buffer_head *old_bh; - - old_bh = get_hash_table(sb->s_dev, blocknr, sb->s_blocksize); - if (old_bh) { - mark_buffer_clean(old_bh); - wait_on_buffer(old_bh); - clear_bit(BH_Req, &old_bh->b_state); - __brelse(old_bh); - } -} -#else #define ll_unmap_underlying_metadata(sb, blocknr) \ unmap_underlying_metadata((sb)->s_bdev, blocknr) -#endif #ifndef EXT3_MB_HINT_GROUP_ALLOC static unsigned long new_blocks(handle_t *handle, struct ext3_ext_base *base, @@ -958,9 +856,7 @@ static unsigned long new_blocks(handle_t *handle, struct ext3_ext_base *base, goal = ext3_ext_find_goal(inode, path, block, &aflags); aflags |= 2; /* block have been already reserved */ - lock_24kernel(); pblock = ext3_mb_new_blocks(handle, inode, goal, count, aflags, err); - unlock_24kernel(); return pblock; } @@ -1057,9 +953,7 @@ static int ext3_ext_new_extent_cb(struct ext3_ext_base *base, count = ext3_ext_calc_credits_for_insert(base, path); ext3_up_truncate_sem(inode); - lock_24kernel(); - handle = fsfilt_ext3_journal_start(inode, count+EXT3_ALLOC_NEEDED+1); - unlock_24kernel(); + handle = ext3_journal_start(inode, count+EXT3_ALLOC_NEEDED+1); if (IS_ERR(handle)) { ext3_down_truncate_sem(inode); return PTR_ERR(handle); @@ -1068,9 +962,7 @@ static int ext3_ext_new_extent_cb(struct ext3_ext_base *base, ext3_down_truncate_sem(inode); if (tgen != EXT_GENERATION(base)) { /* the tree has changed. so path can be invalid at moment */ - lock_24kernel(); - fsfilt_ext3_journal_stop(handle); - unlock_24kernel(); + ext3_journal_stop(handle); return EXT_REPEAT; } @@ -1107,9 +999,7 @@ static int ext3_ext_new_extent_cb(struct ext3_ext_base *base, BUG_ON(nex.ee_block != cex->ec_block); out: - lock_24kernel(); - fsfilt_ext3_journal_stop(handle); - unlock_24kernel(); + ext3_journal_stop(handle); map: if (err >= 0) { /* map blocks */ @@ -1341,10 +1231,8 @@ static int fsfilt_ext3_write_record(struct file *file, void *buf, int bufsize, block_count = (*offs & (blocksize - 1)) + bufsize; block_count = (block_count + blocksize - 1) >> inode->i_blkbits; - lock_24kernel(); - handle = fsfilt_ext3_journal_start(inode, + handle = ext3_journal_start(inode, block_count * FSFILT_DATA_TRANS_BLOCKS(inode->i_sb) + 2); - unlock_24kernel(); if (IS_ERR(handle)) { CERROR("can't start transaction for %d blocks (%d bytes)\n", block_count * FSFILT_DATA_TRANS_BLOCKS(inode->i_sb) + 2, bufsize); @@ -1403,9 +1291,7 @@ out: unlock_kernel(); } - lock_24kernel(); - fsfilt_ext3_journal_stop(handle); - unlock_24kernel(); + ext3_journal_stop(handle); if (err == 0) *offs = offset; @@ -2250,11 +2136,7 @@ static int fsfilt_ext3_dquot(struct lustre_dquot *dquot, int cmd) static lvfs_sbdev_type fsfilt_ext3_journal_sbdev(struct super_block *sb) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) return (EXT3_SB(sb)->journal_bdev); -#else - return kdev_t_to_nr(EXT3_SB(sb)->s_journal->j_dev); -#endif } static struct fsfilt_operations fsfilt_ext3_ops = { -- 1.8.3.1