From da539a44bb4a4eb9384e626efc5a5b63aa13ce2d Mon Sep 17 00:00:00 2001 From: yangsheng Date: Tue, 20 Jan 2009 10:27:35 +0000 Subject: [PATCH] Branch b1_6 b=17153 i=adilger, tappro Remove 2.4 compatibility from b1_6. --- lustre/autoconf/lustre-core.m4 | 94 +------ lustre/llite/Makefile.in | 2 +- lustre/llite/rw24.c | 161 ------------ lustre/llite/super.c | 141 ---------- lustre/lvfs/Makefile.in | 2 - lustre/obdclass/Makefile.in | 14 - lustre/obdfilter/Makefile.in | 7 +- lustre/obdfilter/filter_io_24.c | 558 ---------------------------------------- lustre/ptlrpc/Makefile.in | 4 - 9 files changed, 3 insertions(+), 980 deletions(-) delete mode 100644 lustre/llite/rw24.c delete mode 100644 lustre/llite/super.c delete mode 100644 lustre/obdfilter/filter_io_24.c diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 1ed8833..4583eaa 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -83,77 +83,6 @@ $2 ]) # -# LC_STRUCT_KIOBUF -# -# rh 2.4.18 has iobuf->dovary, but other kernels do not -# -AC_DEFUN([LC_STRUCT_KIOBUF], -[AC_MSG_CHECKING([if struct kiobuf has a dovary field]) -LB_LINUX_TRY_COMPILE([ - #include -],[ - struct kiobuf iobuf; - iobuf.dovary = 1; -],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_KIOBUF_DOVARY, 1, [struct kiobuf has a dovary field]) -],[ - AC_MSG_RESULT([no]) -]) -]) - -# -# LC_FUNC_COND_RESCHED -# -# cond_resched() was introduced in 2.4.20 -# -AC_DEFUN([LC_FUNC_COND_RESCHED], -[AC_MSG_CHECKING([if kernel offers cond_resched]) -LB_LINUX_TRY_COMPILE([ - #include -],[ - cond_resched(); -],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(HAVE_COND_RESCHED, 1, [cond_resched found]) -],[ - AC_MSG_RESULT([no]) -]) -]) - -# -# LC_FUNC_ZAP_PAGE_RANGE -# -# if zap_page_range() takes a vma arg -# -AC_DEFUN([LC_FUNC_ZAP_PAGE_RANGE], -[AC_MSG_CHECKING([if zap_page_range with vma parameter]) -ZAP_PAGE_RANGE_VMA="`grep -c 'zap_page_range.*struct vm_area_struct' $LINUX/include/linux/mm.h`" -if test "$ZAP_PAGE_RANGE_VMA" != 0 ; then - AC_DEFINE(ZAP_PAGE_RANGE_VMA, 1, [zap_page_range with vma parameter]) - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) -fi -]) - -# -# LC_FUNC_PDE -# -# if proc_fs.h defines PDE() -# -AC_DEFUN([LC_FUNC_PDE], -[AC_MSG_CHECKING([if kernel defines PDE]) -HAVE_PDE="`grep -c 'proc_dir_entry..PDE' $LINUX/include/linux/proc_fs.h`" -if test "$HAVE_PDE" != 0 ; then - AC_DEFINE(HAVE_PDE, 1, [the kernel defines PDE]) - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) -fi -]) - -# # LC_FUNC_FILEMAP_FDATASYNC # # if filemap_fdatasync() exists @@ -173,22 +102,6 @@ LB_LINUX_TRY_COMPILE([ ]) # -# LC_FUNC_DIRECT_IO -# -# if direct_IO takes a struct file argument -# -AC_DEFUN([LC_FUNC_DIRECT_IO], -[AC_MSG_CHECKING([if kernel passes struct file to direct_IO]) -HAVE_DIO_FILE="`grep -c 'direct_IO.*struct file' $LINUX/include/linux/fs.h`" -if test "$HAVE_DIO_FILE" != 0 ; then - AC_DEFINE(HAVE_DIO_FILE, 1, [the kernel passes struct file to direct_IO]) - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi -]) - -# # LC_HEADER_MM_INLINE # # RHEL kernels define page_count in mm_inline.h @@ -310,7 +223,7 @@ BACKINGFS="ldiskfs" if test x$with_ldiskfs = xno ; then BACKINGFS="ext3" - if test x$linux25$enable_server = xyesyes ; then + if test x$enable_server = xyes ; then AC_MSG_ERROR([ldiskfs is required for 2.6-based servers.]) fi @@ -1334,11 +1247,6 @@ AC_DEFUN([LC_PROG_LINUX], LC_EXPORT___D_MOVE LC_EXPORT_NODE_TO_CPUMASK - LC_STRUCT_KIOBUF - LC_FUNC_COND_RESCHED - LC_FUNC_ZAP_PAGE_RANGE - LC_FUNC_PDE - LC_FUNC_DIRECT_IO LC_HEADER_MM_INLINE LC_STRUCT_INODE LC_FUNC_REGISTER_CACHE diff --git a/lustre/llite/Makefile.in b/lustre/llite/Makefile.in index 723a97e..a9ba5a6 100644 --- a/lustre/llite/Makefile.in +++ b/lustre/llite/Makefile.in @@ -5,7 +5,7 @@ llite_lloop-objs := lloop.o lustre-objs += rw26.o super25.o -EXTRA_DIST := $(lustre-objs:.o=.c) llite_internal.h rw24.c super.c rw26.c super25.c +EXTRA_DIST := $(lustre-objs:.o=.c) llite_internal.h EXTRA_DIST += $(llite_lloop-objs:.o=.c) @INCLUDE_RULES@ diff --git a/lustre/llite/rw24.c b/lustre/llite/rw24.c deleted file mode 100644 index 4652d5f..0000000 --- a/lustre/llite/rw24.c +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * 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. - * - * GPL HEADER END - */ -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/llite/rw24.c - * - * Lustre Lite I/O page cache for the 2.4 kernel version - */ - -#ifndef AUTOCONF_INCLUDED -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include "llite_internal.h" -#include - -static int ll_direct_IO_24(int rw, -#ifdef HAVE_DIO_FILE - struct file *file, -#else - struct inode *inode, -#endif - struct kiobuf *iobuf, unsigned long blocknr, - int blocksize) -{ -#ifdef HAVE_DIO_FILE - struct inode *inode = file->f_dentry->d_inode; -#endif - struct ll_inode_info *lli = ll_i2info(inode); - struct lov_stripe_md *lsm = lli->lli_smd; - struct brw_page *pga; - struct obdo oa; - int length, i, flags, rc = 0; - loff_t offset, offset_orig; - ENTRY; - - if (!lsm || !lsm->lsm_object_id) - RETURN(-EBADF); - - offset = ((obd_off)blocknr << inode->i_blkbits); - offset_orig = offset; - CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), size="LPSZ - ", offset=%lld=%llx, pages %u\n", - inode->i_ino, inode->i_generation, inode, iobuf->length, - offset, offset, iobuf->nr_pages); - - /* FIXME: io smaller than CFS_PAGE_SIZE is broken on ia64 */ - if ((iobuf->offset & (~CFS_PAGE_MASK)) || - (iobuf->length & (~CFS_PAGE_MASK))) - RETURN(-EINVAL); - - OBD_ALLOC(pga, sizeof(*pga) * iobuf->nr_pages); - if (!pga) - RETURN(-ENOMEM); - - flags = 0 /* | OBD_BRW_DIRECTIO */; - length = iobuf->length; - rw = rw ? OBD_BRW_WRITE : OBD_BRW_READ; - - for (i = 0, length = iobuf->length; length > 0; - length -= pga[i].count, offset += pga[i].count, i++) { /*i last!*/ - pga[i].pg = iobuf->maplist[i]; - pga[i].off = offset; - /* To the end of the page, or the length, whatever is less */ - pga[i].count = min_t(int, CFS_PAGE_SIZE - (offset & ~CFS_PAGE_MASK), - length); - pga[i].flag = flags; - if (rw == OBD_BRW_READ) - POISON_PAGE(iobuf->maplist[i], 0x0d); - } - - ll_inode_fill_obdo(inode, rw, &oa); - - if (rw == OBD_BRW_WRITE) - ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_DIRECT_WRITE, iobuf->length); - else - ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_DIRECT_READ, iobuf->length); - rc = obd_brw_rqset(rw, ll_i2obdexp(inode), &oa, lsm, iobuf->nr_pages, - pga, NULL); - if ((rc > 0) && (rw == OBD_BRW_WRITE)) { - lov_stripe_lock(lsm); - obd_adjust_kms(ll_i2obdexp(inode), lsm, offset_orig + rc, 0); - lov_stripe_unlock(lsm); - } - - OBD_FREE(pga, sizeof(*pga) * iobuf->nr_pages); - RETURN(rc); -} - -#ifdef KERNEL_HAS_AS_MAX_READAHEAD -static int ll_max_readahead(struct inode *inode) -{ - return 0; -} -#endif - -struct address_space_operations ll_aops = { - .readpage = ll_readpage, - .direct_IO = ll_direct_IO_24, - .writepage = ll_writepage, - .prepare_write = ll_prepare_write, - .commit_write = ll_commit_write, - .removepage = ll_removepage, - .sync_page = NULL, - .bmap = NULL, -#ifdef KERNEL_HAS_AS_MAX_READAHEAD - .max_readahead = ll_max_readahead, -#endif -}; diff --git a/lustre/llite/super.c b/lustre/llite/super.c deleted file mode 100644 index 18236ea..0000000 --- a/lustre/llite/super.c +++ /dev/null @@ -1,141 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * 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. - * - * GPL HEADER END - */ -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#define DEBUG_SUBSYSTEM S_LLITE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "llite_internal.h" -#include - -extern struct address_space_operations ll_aops; -extern struct address_space_operations ll_dir_aops; - - -/* exported operations */ -struct super_operations lustre_super_operations = -{ - .read_inode2 = ll_read_inode2, - .clear_inode = ll_clear_inode, - .put_super = ll_put_super, - .statfs = ll_statfs, - .umount_begin = ll_umount_begin, - .fh_to_dentry = ll_fh_to_dentry, - .dentry_to_fh = ll_dentry_to_fh, - .remount_fs = ll_remount_fs, - .show_options = ll_show_options, -}; - - -void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg)); - -static int __init init_lustre_lite(void) -{ - int i, seed[2]; - struct timeval tv; - lnet_process_id_t lnet_id; - - printk(KERN_INFO "Lustre: Lustre Client File System; " - "http://www.lustre.org/\n"); - ll_file_data_slab = cfs_mem_cache_create("ll_file_data", - sizeof(struct ll_file_data), 0, - SLAB_HWCACHE_ALIGN); - if (ll_file_data_slab == NULL) - return -ENOMEM; - - if (proc_lustre_root) - proc_lustre_fs_root = proc_mkdir("llite", proc_lustre_root); - - ll_register_cache(&ll_cache_definition); - - lustre_register_client_fill_super(ll_fill_super); - lustre_register_client_process_config(ll_process_config); - - get_random_bytes(seed, sizeof(seed)); - - /* Nodes with small feet have little entropy - * the NID for this node gives the most entropy in the low bits */ - for (i = 0; ; i++) { - if (LNetGetId(i, &lnet_id) == -ENOENT) { - break; - } - if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND) { - seed[0] ^= LNET_NIDADDR(lnet_id.nid); - } - } - - do_gettimeofday(&tv); - ll_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]); - - return 0; -} - -static void __exit exit_lustre_lite(void) -{ - int rc; - - lustre_register_client_fill_super(NULL); - lustre_register_client_process_config(NULL); - - ll_unregister_cache(&ll_cache_definition); - - rc = cfs_mem_cache_destroy(ll_file_data_slab); - LASSERTF(rc == 0, "couldn't destroy ll_file_data slab\n"); - if (ll_async_page_slab) { - rc = cfs_mem_cache_destroy(ll_async_page_slab); - LASSERTF(rc == 0, "couldn't destroy ll_async_page slab\n"); - } - - if (proc_lustre_fs_root) - lprocfs_remove(&proc_lustre_fs_root); -} - -MODULE_AUTHOR("Sun Microsystems, Inc. "); -MODULE_DESCRIPTION("Lustre Lite Client File System"); -MODULE_LICENSE("GPL"); - -module_init(init_lustre_lite); -module_exit(exit_lustre_lite); diff --git a/lustre/lvfs/Makefile.in b/lustre/lvfs/Makefile.in index 79491fb..46c4412 100644 --- a/lustre/lvfs/Makefile.in +++ b/lustre/lvfs/Makefile.in @@ -7,12 +7,10 @@ lvfs-objs := lvfs_common.o lvfs_linux.o fsfilt.o upcall_cache.o prng.o lvfs_lib. @QUOTA_TRUE@quotafmt-objs := quotafmt_test.o -ifeq ($(PATCHLEVEL),6) fsfilt_@BACKINGFS@-objs := fsfilt-@BACKINGFS@.o $(obj)/fsfilt-%.c: $(obj)/fsfilt_%.c ln -s $< $@ -endif EXTRA_DIST = $(lvfs-objs:.o=.c) $(quotafmt-objs:.o=.c) \ fsfilt_ext3.c fsfilt_reiserfs.c \ diff --git a/lustre/obdclass/Makefile.in b/lustre/obdclass/Makefile.in index cc43100..b7afa5d 100644 --- a/lustre/obdclass/Makefile.in +++ b/lustre/obdclass/Makefile.in @@ -1,23 +1,11 @@ MODULES := obdclass llog_test obdclass-linux-objs := linux-module.o linux-obdo.o linux-sysctl.o -ifeq ($(PATCHLEVEL),6) obdclass-linux-objs := $(addprefix linux/,$(obdclass-linux-objs)) -endif default: all -ifeq (@linux25@,no) sources: - @for i in $(obdclass-linux-objs:%.o=%.c) ; do \ - echo "ln -s @srcdir@/linux/$$i ." ; \ - ln -sf @srcdir@/linux/$$i . || exit 1 ; \ - done - -else -sources: - -endif obdclass-all-objs := llog.o llog_cat.o llog_lvfs.o llog_obd.o llog_swab.o obdclass-all-objs += class_obd.o class_hash.o @@ -27,12 +15,10 @@ obdclass-all-objs += statfs_pack.o obdo.o obd_config.o obd_mount.o obdclass-objs := $(obdclass-linux-objs) $(obdclass-all-objs) -ifeq ($(PATCHLEVEL),6) llog_test-objs := llog-test.o $(obj)/llog-test.c: $(obj)/llog_test.c ln -sf $< $@ -endif EXTRA_DIST = $(filter-out llog-test.c,$(obdclass-all-objs:.o=.c)) $(llog-test-objs:.o=.c) llog_test.c llog_internal.h diff --git a/lustre/obdfilter/Makefile.in b/lustre/obdfilter/Makefile.in index 2b4756c..39ed404 100644 --- a/lustre/obdfilter/Makefile.in +++ b/lustre/obdfilter/Makefile.in @@ -2,13 +2,8 @@ MODULES := obdfilter obdfilter-objs := filter.o filter_io.o filter_log.o obdfilter-objs += lproc_obdfilter.o filter_lvb.o - -ifeq ($(PATCHLEVEL),4) -obdfilter-objs += filter_io_24.o -else obdfilter-objs += filter_io_26.o -endif # PATCHLEVEL -EXTRA_DIST = $(obdfilter-objs:%.o=%.c) filter_io_24.c filter_io_26.c filter_internal.h +EXTRA_DIST = $(obdfilter-objs:%.o=%.c) filter_internal.h @INCLUDE_RULES@ diff --git a/lustre/obdfilter/filter_io_24.c b/lustre/obdfilter/filter_io_24.c deleted file mode 100644 index 6031c1f..0000000 --- a/lustre/obdfilter/filter_io_24.c +++ /dev/null @@ -1,558 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * 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. - * - * GPL HEADER END - */ -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/obdfilter/filter_io_24.c - * - * Author: Peter Braam - * Author: Andreas Dilger - * Author: Phil Schwan - */ - -#ifndef AUTOCONF_INCLUDED -#include -#endif -#include -#include // XXX kill me soon -#include - -#define DEBUG_SUBSYSTEM S_FILTER - -#include -#include - -#include -#include -#include "filter_internal.h" - -/* Bug 2254 -- this is better done in ext3_map_inode_page, but this - * workaround will suffice until everyone has upgraded their kernels */ -static void check_pending_bhs(unsigned long *blocks, int nr_pages, dev_t dev, - int size) -{ -#if (LUSTRE_KERNEL_VERSION < 32) - struct buffer_head *bh; - int i; - - for (i = 0; i < nr_pages; i++) { - bh = get_hash_table(dev, blocks[i], size); - if (bh == NULL) - continue; - if (!buffer_dirty(bh)) { - put_bh(bh); - continue; - } - mark_buffer_clean(bh); - wait_on_buffer(bh); - clear_bit(BH_Req, &bh->b_state); - __brelse(bh); - } -#endif -} - -/* when brw_kiovec() is asked to read from block -1UL it just zeros - * the page. this gives us a chance to verify the write mappings - * as well */ -static int filter_cleanup_mappings(int rw, struct kiobuf *iobuf, - struct inode *inode) -{ - int i, blocks_per_page_bits = CFS_PAGE_SHIFT - inode->i_blkbits; - ENTRY; - - for (i = 0 ; i < iobuf->nr_pages << blocks_per_page_bits; i++) { - if (KIOBUF_GET_BLOCKS(iobuf)[i] > 0) - continue; - - if (rw == OBD_BRW_WRITE) - RETURN(-EINVAL); - - KIOBUF_GET_BLOCKS(iobuf)[i] = -1UL; - } - RETURN(0); -} - -#if 0 -static void dump_page(int rw, unsigned long block, struct page *page) -{ - char *blah = kmap(page); - CDEBUG(D_PAGE, "rw %d block %lu: %02x %02x %02x %02x\n", rw, block, - blah[0], blah[1], blah[2], blah[3]); - kunmap(page); -} -#endif - -/* These are our hacks to keep our directio/bh IO coherent with ext3's - * page cache use. Most notably ext3 reads file data into the page - * cache when it is zeroing the tail of partial-block truncates and - * leaves it there, sometimes generating io from it at later truncates. - * This removes the partial page and its buffers from the page cache, - * so it should only ever cause a wait in rare cases, as otherwise we - * always do full-page IO to the OST. - * - * The call to truncate_complete_page() will call journal_flushpage() to - * free the buffers and drop the page from cache. The buffers should not - * be dirty, because we already called fdatasync/fdatawait on them. - */ -static int filter_sync_inode_data(struct inode *inode) -{ - int rc, rc2; - - /* This is nearly generic_osync_inode, without the waiting on the inode - rc = generic_osync_inode(inode, inode->i_mapping, - OSYNC_DATA|OSYNC_METADATA); - */ - rc = filemap_fdatasync(inode->i_mapping); - rc2 = fsync_inode_data_buffers(inode); - if (rc == 0) - rc = rc2; - rc2 = filemap_fdatawait(inode->i_mapping); - if (rc == 0) - rc = rc2; - - return rc; -} - -static int filter_clear_page_cache(struct inode *inode, struct kiobuf *iobuf) -{ - struct page *page; - int i, rc; - - check_pending_bhs(KIOBUF_GET_BLOCKS(iobuf), iobuf->nr_pages, - inode->i_dev, 1 << inode->i_blkbits); - - rc = filter_sync_inode_data(inode); - if (rc != 0) - RETURN(rc); - - /* be careful to call this after fsync_inode_data_buffers has waited - * for IO to complete before we evict it from the cache */ - for (i = 0; i < iobuf->nr_pages ; i++) { - page = find_lock_page(inode->i_mapping, - iobuf->maplist[i]->index); - if (page == NULL) - continue; - if (page->mapping != NULL) { - /* Now that the only source of such pages in truncate - * path flushes these pages to disk and and then - * discards, this is error condition */ - CERROR("Data page in page cache during write!\n"); - ll_truncate_complete_page(page); - } - - unlock_page(page); - page_cache_release(page); - } - - return 0; -} - -int filter_clear_truncated_page(struct inode *inode) -{ - struct page *page; - int rc; - - /* Truncate on page boundary, so nothing to flush? */ - if (!(i_size_read(inode) & ~CFS_PAGE_MASK)) - return 0; - - rc = filter_sync_inode_data(inode); - if (rc != 0) - RETURN(rc); - - /* be careful to call this after fsync_inode_data_buffers has waited - * for IO to complete before we evict it from the cache */ - page = find_lock_page(inode->i_mapping, - i_size_read(inode) >> CFS_PAGE_SHIFT); - if (page) { - if (page->mapping != NULL) - ll_truncate_complete_page(page); - - unlock_page(page); - page_cache_release(page); - } - - return 0; -} - -/* Must be called with i_sem taken for writes; this will drop it */ -int filter_direct_io(int rw, struct dentry *dchild, struct filter_iobuf *buf, - struct obd_export *exp, struct iattr *attr, - struct obd_trans_info *oti, void **wait_handle) -{ - struct obd_device *obd = exp->exp_obd; - struct inode *inode = dchild->d_inode; - struct kiobuf *iobuf = (void *)buf; - int rc, create = (rw == OBD_BRW_WRITE), committed = 0; - int blocks_per_page = CFS_PAGE_SIZE >> inode->i_blkbits, cleanup_phase = 0; - struct semaphore *sem = NULL; - ENTRY; - - LASSERTF(rw == OBD_BRW_WRITE || rw == OBD_BRW_READ, "%x\n", rw); - - if (iobuf->nr_pages == 0) - GOTO(cleanup, rc = 0); - - if (iobuf->nr_pages * blocks_per_page > KIO_MAX_SECTORS) - GOTO(cleanup, rc = -EINVAL); - - if (iobuf->nr_pages * blocks_per_page > - OBDFILTER_CREATED_SCRATCHPAD_ENTRIES) - GOTO(cleanup, rc = -EINVAL); - - cleanup_phase = 1; - - rc = lock_kiovec(1, &iobuf, 1); - if (rc < 0) - GOTO(cleanup, rc); - cleanup_phase = 2; - - if (rw == OBD_BRW_WRITE) { - create = 1; - sem = &obd->u.filter.fo_alloc_lock; - } - rc = fsfilt_map_inode_pages(obd, inode, iobuf->maplist, - iobuf->nr_pages, KIOBUF_GET_BLOCKS(iobuf), - obdfilter_created_scratchpad, create, sem); - if (rc) - GOTO(cleanup, rc); - - rc = filter_cleanup_mappings(rw, iobuf, inode); - if (rc) - GOTO(cleanup, rc); - - if (rw == OBD_BRW_WRITE) { - if (rc == 0) { - filter_tally(exp, iobuf->maplist, iobuf->nr_pages, - KIOBUF_GET_BLOCKS(iobuf), blocks_per_page, - 1); - - if (attr->ia_size > i_size_read(inode)) - attr->ia_valid |= ATTR_SIZE; - rc = fsfilt_setattr(obd, dchild, - oti->oti_handle, attr, 0); - if (rc) - GOTO(cleanup, rc); - } - - up(&inode->i_sem); - cleanup_phase = 3; - - rc = filter_finish_transno(exp, oti, 0, 0); - if (rc) - GOTO(cleanup, rc); - - rc = fsfilt_commit_async(obd,inode,oti->oti_handle,wait_handle); - committed = 1; - if (rc) - GOTO(cleanup, rc); - } else { - filter_tally(exp, iobuf->maplist, iobuf->nr_pages, - KIOBUF_GET_BLOCKS(iobuf), blocks_per_page, 0); - } - - rc = filter_clear_page_cache(inode, iobuf); - if (rc < 0) - GOTO(cleanup, rc); - - rc = fsfilt_send_bio(rw, obd, inode, iobuf); - - CDEBUG(D_INFO, "tried to %s %d pages, rc = %d\n", - rw & OBD_BRW_WRITE ? "write" : "read", iobuf->nr_pages, rc); - - if (rc > 0) - rc = 0; - - EXIT; -cleanup: - if (!committed && (rw == OBD_BRW_WRITE)) { - int err = fsfilt_commit_async(obd, inode, - oti->oti_handle, wait_handle); - if (err) - CERROR("can't close transaction: %d\n", err); - /* - * this is error path, so we prefer to return - * original error, not this one - */ - } - - switch(cleanup_phase) { - case 3: - case 2: - unlock_kiovec(1, &iobuf); - case 1: - case 0: - if (cleanup_phase != 3 && rw == OBD_BRW_WRITE) - up(&inode->i_sem); - break; - default: - CERROR("corrupt cleanup_phase (%d)?\n", cleanup_phase); - LBUG(); - break; - } - return rc; -} - -/* See if there are unallocated parts in given file region */ -int filter_range_is_mapped(struct inode *inode, obd_size offset, int len) -{ - int (*fs_bmap)(struct address_space *, long) = - inode->i_mapping->a_ops->bmap; - int j; - - /* We can't know if the range is mapped already or not */ - if (fs_bmap == NULL) - return 0; - - offset >>= inode->i_blkbits; - len >>= inode->i_blkbits; - - for (j = 0; j < len; j++) - if (fs_bmap(inode->i_mapping, offset + j) == 0) - return 0; - - return 1; -} - -/* some kernels require alloc_kiovec callers to zero members through the use of - * map_user_kiobuf and unmap_.. we don't use those, so we have a little helper - * that makes sure we don't break the rules. */ -static void clear_kiobuf(struct kiobuf *iobuf) -{ - int i; - - for (i = 0; i < iobuf->array_len; i++) - iobuf->maplist[i] = NULL; - - iobuf->nr_pages = 0; - iobuf->offset = 0; - iobuf->length = 0; -} - -struct filter_iobuf *filter_alloc_iobuf(struct filter_obd *filter, - int rw, int num_pages) -{ - struct kiobuf *iobuf; - int rc; - ENTRY; - - LASSERTF(rw == OBD_BRW_WRITE || rw == OBD_BRW_READ, "%x\n", rw); - - rc = alloc_kiovec(1, &iobuf); - if (rc) - RETURN(ERR_PTR(rc)); - - rc = expand_kiobuf(iobuf, num_pages); - if (rc) { - free_kiovec(1, &iobuf); - RETURN(ERR_PTR(rc)); - } - -#ifdef HAVE_KIOBUF_DOVARY - iobuf->dovary = 0; /* this prevents corruption, not present in 2.4.20 */ -#endif - clear_kiobuf(iobuf); - RETURN((void *)iobuf); -} - -void filter_free_iobuf(struct filter_iobuf *buf) -{ - struct kiobuf *iobuf = (void *)buf; - - clear_kiobuf(iobuf); - free_kiovec(1, &iobuf); -} - -void filter_iobuf_put(struct filter_obd *filter, struct filter_iobuf *iobuf, - struct obd_trans_info *oti) -{ - int thread_id = (oti && oti->oti_thread) ? - oti->oti_thread->t_id : -1; - - if (unlikely(thread_id < 0)) { - filter_free_iobuf(iobuf); - return; - } - - LASSERTF(filter->fo_iobuf_pool[thread_id] == iobuf, - "iobuf mismatch for thread %d: pool %p iobuf %p\n", - thread_id, filter->fo_iobuf_pool[thread_id], iobuf); - clear_kiobuf((void *)iobuf); -} - -int filter_iobuf_add_page(struct obd_device *obd, struct filter_iobuf *buf, - struct inode *inode, struct page *page) -{ - struct kiobuf *iobuf = (void *)buf; - - iobuf->maplist[iobuf->nr_pages++] = page; - iobuf->length += CFS_PAGE_SIZE; - - return 0; -} - -int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount, - struct obd_ioobj *obj, int niocount, - struct niobuf_local *res, struct obd_trans_info *oti, - int rc) -{ - struct obd_device *obd = exp->exp_obd; - struct lvfs_run_ctxt saved; - struct niobuf_local *lnb; - struct fsfilt_objinfo fso; - struct iattr iattr = { 0 }; - void *iobuf = NULL; - struct inode *inode = NULL; - int i, n, cleanup_phase = 0, err; - unsigned long now = jiffies; /* DEBUGGING OST TIMEOUTS */ - void *wait_handle; - ENTRY; - LASSERT(oti != NULL); - LASSERT(objcount == 1); - LASSERT(current->journal_info == NULL); - - if (rc != 0) - GOTO(cleanup, rc); - - iobuf = filter_iobuf_get(&obd->u.filter, oti); - if (IS_ERR(iobuf)) - GOTO(cleanup, rc = PTR_ERR(iobuf)); - cleanup_phase = 1; - - fso.fso_dentry = res->dentry; - fso.fso_bufcnt = obj->ioo_bufcnt; - inode = res->dentry->d_inode; - - for (i = 0, lnb = res, n = 0; i < obj->ioo_bufcnt; i++, lnb++) { - loff_t this_size; - - /* If overwriting an existing block, we don't need a grant */ - if (!(lnb->flags & OBD_BRW_GRANTED) && lnb->rc == -ENOSPC && - filter_range_is_mapped(inode, lnb->offset, lnb->len)) - lnb->rc = 0; - - if (lnb->rc) /* ENOSPC, network RPC error */ - continue; - - filter_iobuf_add_page(obd, iobuf, inode, lnb->page); - - /* We expect these pages to be in offset order, but we'll - * be forgiving */ - this_size = lnb->offset + lnb->len; - if (this_size > iattr.ia_size) - iattr.ia_size = this_size; - } - - push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - cleanup_phase = 2; - - down(&inode->i_sem); - oti->oti_handle = fsfilt_brw_start(obd, objcount, &fso, niocount, res, - oti); - if (IS_ERR(oti->oti_handle)) { - up(&inode->i_sem); - rc = PTR_ERR(oti->oti_handle); - CDEBUG(rc == -ENOSPC ? D_INODE : D_ERROR, - "error starting transaction: rc = %d\n", rc); - oti->oti_handle = NULL; - GOTO(cleanup, rc); - } - - fsfilt_check_slow(obd, now, "brw_start"); - - i = OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME; - - /* If the inode still has SUID+SGID bits set (see filter_precreate()) - * then we will accept the UID+GID if sent by the client for - * initializing the ownership of this inode. We only allow this to - * happen once (so clear these bits) and later only allow setattr. */ - if (inode->i_mode & S_ISUID) - i |= OBD_MD_FLUID; - if (inode->i_mode & S_ISGID) - i |= OBD_MD_FLGID; - - iattr_from_obdo(&iattr, oa, i); - if (iattr.ia_valid & (ATTR_UID | ATTR_GID)) { - CDEBUG(D_INODE, "update UID/GID to %lu/%lu\n", - (unsigned long)oa->o_uid, (unsigned long)oa->o_gid); - - cfs_cap_raise(CFS_CAP_SYS_RESOURCE); - - iattr.ia_valid |= ATTR_MODE; - iattr.ia_mode = inode->i_mode; - if (iattr.ia_valid & ATTR_UID) - iattr.ia_mode &= ~S_ISUID; - if (iattr.ia_valid & ATTR_GID) - iattr.ia_mode &= ~S_ISGID; - - rc = filter_update_fidea(exp, inode, oti->oti_handle, oa); - } - - /* filter_direct_io drops i_sem */ - rc = filter_direct_io(OBD_BRW_WRITE, res->dentry, iobuf, exp, &iattr, - oti, &wait_handle); - if (rc == 0) - obdo_from_inode(oa, inode, FILTER_VALID_FLAGS); - - fsfilt_check_slow(obd, now, "direct_io"); - - err = fsfilt_commit_wait(obd, inode, wait_handle); - if (err) { - CERROR("Failure to commit OST transaction (%d)?\n", err); - rc = err; - } - if (obd->obd_replayable && !rc) - LASSERTF(oti->oti_transno <= obd->obd_last_committed, - "oti_transno "LPU64" last_committed "LPU64"\n", - oti->oti_transno, obd->obd_last_committed); - fsfilt_check_slow(obd, now, "commitrw commit"); - -cleanup: - filter_grant_commit(exp, niocount, res); - - switch (cleanup_phase) { - case 2: - pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - LASSERT(current->journal_info == NULL); - case 1: - filter_iobuf_put(&obd->u.filter, iobuf, oti); - case 0: - /* - * lnb->page automatically returns back into per-thread page - * pool (bug 5137) - */ - f_dput(res->dentry); - } - - RETURN(rc); -} diff --git a/lustre/ptlrpc/Makefile.in b/lustre/ptlrpc/Makefile.in index 0c42f15..c951d7b 100644 --- a/lustre/ptlrpc/Makefile.in +++ b/lustre/ptlrpc/Makefile.in @@ -1,9 +1,5 @@ MODULES := ptlrpc -ifeq ($(PATCHLEVEL),6) LDLM := @top_srcdir@/lustre/ldlm/ -else -LDLM := -endif ldlm_objs := $(LDLM)l_lock.o $(LDLM)ldlm_lock.o ldlm_objs += $(LDLM)ldlm_resource.o $(LDLM)ldlm_lib.o ldlm_objs += $(LDLM)ldlm_plain.o $(LDLM)ldlm_extent.o -- 1.8.3.1