The next set. All patches prior to this have been pushed to the repo.
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 01/18] ocfs2: Add kapi-default.h in cluster and dlm
Commit 19582597eec08f61b6f5794c15f6f2c9821a67d9 added kapi-default.h in fs/ocfs2. This patch adds a similar named file in fs/ocfs2/cluster and fs/ocfs2/dlm to allow building against the mainline without kapi-compat headers. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- fs/ocfs2/cluster/Makefile | 2 +- fs/ocfs2/cluster/kapi-default.h | 26 ++++++++++++++++++++++++++ fs/ocfs2/dlm/Makefile | 2 +- fs/ocfs2/dlm/kapi-default.h | 26 ++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 fs/ocfs2/cluster/kapi-default.h create mode 100644 fs/ocfs2/dlm/kapi-default.h diff --git a/fs/ocfs2/cluster/Makefile b/fs/ocfs2/cluster/Makefile index d89112d..1f040c6 100644 --- a/fs/ocfs2/cluster/Makefile +++ b/fs/ocfs2/cluster/Makefile @@ -12,7 +12,7 @@ include $(OUR_TOPDIR)/Config.make endif COMPAT_SOURCES -COMPAT_HEADERS +COMPAT_HEADERS = kapi-default.h SOURCES HEADERS diff --git a/fs/ocfs2/cluster/kapi-default.h b/fs/ocfs2/cluster/kapi-default.h new file mode 100644 index 0000000..fcf3ac9 --- /dev/null +++ b/fs/ocfs2/cluster/kapi-default.h @@ -0,0 +1,26 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * kapi-default.h + * + * Defines kapi-compat macros and structures used in OCFS2 + * + * Copyright (C) 2009 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * 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 for more details. + * + */ + +#ifndef KAPI_DEFAULT_H +#define KAPI_DEFAULT_H + + +#endif diff --git a/fs/ocfs2/dlm/Makefile b/fs/ocfs2/dlm/Makefile index 122b370..0c4d1f4 100644 --- a/fs/ocfs2/dlm/Makefile +++ b/fs/ocfs2/dlm/Makefile @@ -13,7 +13,7 @@ include $(OUR_TOPDIR)/Config.make endif COMPAT_SOURCES -COMPAT_HEADERS +COMPAT_HEADERS = kapi-default.h DLM_SOURCES DLMFS_SOURCES HEADERS diff --git a/fs/ocfs2/dlm/kapi-default.h b/fs/ocfs2/dlm/kapi-default.h new file mode 100644 index 0000000..fcf3ac9 --- /dev/null +++ b/fs/ocfs2/dlm/kapi-default.h @@ -0,0 +1,26 @@ +/* -*- mode: c; c-basic-offset: 8; -*- + * vim: noexpandtab sw=8 ts=8 sts=0: + * + * kapi-default.h + * + * Defines kapi-compat macros and structures used in OCFS2 + * + * Copyright (C) 2009 Oracle. All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * 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 for more details. + * + */ + +#ifndef KAPI_DEFAULT_H +#define KAPI_DEFAULT_H + + +#endif -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 02/18] ocfs2: Add KAPI_INIT_WORK macro in kapi-default.h
Commit dbc80b8f391820b719db97004219327c8cf050bc added KAPI_INIT_WORK macros to fs/ocfs2/kapi-default.h. This patch adds the same to the same header in dlm and cluster sub-directories. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- fs/ocfs2/cluster/kapi-default.h | 6 ++++++ fs/ocfs2/dlm/kapi-default.h | 6 ++++++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/fs/ocfs2/cluster/kapi-default.h b/fs/ocfs2/cluster/kapi-default.h index fcf3ac9..21e5e3a 100644 --- a/fs/ocfs2/cluster/kapi-default.h +++ b/fs/ocfs2/cluster/kapi-default.h @@ -22,5 +22,11 @@ #ifndef KAPI_DEFAULT_H #define KAPI_DEFAULT_H +#ifndef KAPI_INIT_WORK +typedef struct work_struct kapi_work_struct_t; +# define work_to_object(a, b, c) container_of(a, b, c) +# define KAPI_INIT_WORK(a, b, c) INIT_WORK(a, b) +# define KAPI_INIT_DELAYED_WORK(a, b, c) INIT_DELAYED_WORK(a, b) +#endif #endif diff --git a/fs/ocfs2/dlm/kapi-default.h b/fs/ocfs2/dlm/kapi-default.h index fcf3ac9..21e5e3a 100644 --- a/fs/ocfs2/dlm/kapi-default.h +++ b/fs/ocfs2/dlm/kapi-default.h @@ -22,5 +22,11 @@ #ifndef KAPI_DEFAULT_H #define KAPI_DEFAULT_H +#ifndef KAPI_INIT_WORK +typedef struct work_struct kapi_work_struct_t; +# define work_to_object(a, b, c) container_of(a, b, c) +# define KAPI_INIT_WORK(a, b, c) INIT_WORK(a, b) +# define KAPI_INIT_DELAYED_WORK(a, b, c) INIT_DELAYED_WORK(a, b) +#endif #endif -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 03/18] ocfs2: Handle missing dtor in kmem_cache_create()
Mainline commit 20c2df83d25c6a95affe6157a4c9cac4cf5ffaac removed the dtor arg from kmem_cache_create(). Patch adds a kapi macro that adds a dtor arg when building against EL5 kernels. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Config.make.in | 1 + Makefile | 3 ++- configure.in | 6 ++++++ fs/ocfs2/Makefile | 4 ++++ fs/ocfs2/dlm/Makefile | 4 ++++ fs/ocfs2/dlm/dlmfs.c | 7 ++++++- fs/ocfs2/dlm/dlmlock.c | 2 +- fs/ocfs2/dlm/dlmmaster.c | 6 +++--- fs/ocfs2/dlm/kapi-default.h | 4 ++++ fs/ocfs2/kapi-default.h | 4 ++++ fs/ocfs2/super.c | 11 ++++++++--- fs/ocfs2/uptodate.c | 2 +- kapi-compat/include/slab.h | 8 ++++++++ 13 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 kapi-compat/include/slab.h diff --git a/Config.make.in b/Config.make.in index a19d096..fb705b5 100644 --- a/Config.make.in +++ b/Config.make.in @@ -72,6 +72,7 @@ VMOP_IS_NOT_CONST = @VMOP_IS_NOT_CONST@ SEQOP_IS_NOT_CONST = @SEQOP_IS_NOT_CONST@ NO_VECTORIZED_AIO = @NO_VECTORIZED_AIO@ OLD_PERMISSION = @OLD_PERMISSION@ +KMEM_CACHE_CREATE_DTOR = @KMEM_CACHE_CREATE_DTOR@ OCFS_DEBUG = @OCFS_DEBUG@ diff --git a/Makefile b/Makefile index adaf9fb..912fb70 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,8 @@ KAPI_COMPAT_FILES = \ kapi-compat/include/fsuid.h \ kapi-compat/include/umh_wait.h \ kapi-compat/include/register_sysctl.h \ - kapi-compat/include/sysctl.h + kapi-compat/include/sysctl.h \ + kapi-compat/include/slab.h PATCH_FILES diff --git a/configure.in b/configure.in index b662f88..98cdc5d 100644 --- a/configure.in +++ b/configure.in @@ -328,6 +328,12 @@ OCFS2_CHECK_KERNEL([enum FS_OCFS2 in sysctl.h], sysctl.h, , sysctl_compat_header=sysctl.h, [FS_OCFS2=]) KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $sysctl_compat_header" +KMEM_CACHE_CREATE_DTOR+OCFS2_CHECK_KERNEL([ older prototype of kmem_cache_create() in slab.h], slab.h, + KMEM_CACHE_CREATE_DTOR=slab.h, , [^.*void (\*)(void \*, kmem_cache_t \*, unsigned long),]) +AC_SUBST(KMEM_CACHE_CREATE_DTOR) +KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $KMEM_CACHE_CREATE_DTOR" + # End kapi_compat checks # using -include has two advantages: diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile index 32d864d..c769fd8 100644 --- a/fs/ocfs2/Makefile +++ b/fs/ocfs2/Makefile @@ -92,6 +92,10 @@ ifdef OLD_PERMISSION EXTRA_CFLAGS += -DOLD_PERMISSION endif +ifdef KMEM_CACHE_CREATE_DTOR +EXTRA_CFLAGS += -DKMEM_CACHE_CREATE_DTOR +endif + # # Since SUBDIRS means something to kbuild, define them safely. Do not # include trailing slashes. diff --git a/fs/ocfs2/dlm/Makefile b/fs/ocfs2/dlm/Makefile index 0c4d1f4..907e390 100644 --- a/fs/ocfs2/dlm/Makefile +++ b/fs/ocfs2/dlm/Makefile @@ -42,6 +42,10 @@ ifdef SEQOP_IS_NOT_CONST EXTRA_CFLAGS += -DSEQOP_IS_NOT_CONST endif +ifdef KMEM_CACHE_CREATE_DTOR +EXTRA_CFLAGS += -DKMEM_CACHE_CREATE_DTOR +endif + DLM_SOURCES += \ dlmast.c \ dlmconvert.c \ diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c index d05653d..6d97173 100644 --- a/fs/ocfs2/dlm/dlmfs.c +++ b/fs/ocfs2/dlm/dlmfs.c @@ -277,7 +277,12 @@ static ssize_t dlmfs_file_write(struct file *filp, return writelen; } +#ifdef KMEM_CACHE_CREATE_DTOR +static void dlmfs_init_once(void *foo, struct kmem_cache *cachep, + unsigned long flags) +#else static void dlmfs_init_once(void *foo) +#endif { struct dlmfs_inode_private *ip (struct dlmfs_inode_private *) foo; @@ -628,7 +633,7 @@ static int __init init_dlmfs_fs(void) if (status) return status; - dlmfs_inode_cache = kmem_cache_create("dlmfs_inode_cache", + dlmfs_inode_cache = kapi_kmem_cache_create("dlmfs_inode_cache", sizeof(struct dlmfs_inode_private), 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT| SLAB_MEM_SPREAD), diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c index 437698e..98840f9 100644 --- a/fs/ocfs2/dlm/dlmlock.c +++ b/fs/ocfs2/dlm/dlmlock.c @@ -67,7 +67,7 @@ static void dlm_lock_detach_lockres(struct dlm_lock *lock); int dlm_init_lock_cache(void) { - dlm_lock_cache = kmem_cache_create("o2dlm_lock", + dlm_lock_cache = kapi_kmem_cache_create("o2dlm_lock", sizeof(struct dlm_lock), 0, SLAB_HWCACHE_ALIGN, NULL); if (dlm_lock_cache == NULL) diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index 83bcaf2..90d3157 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c @@ -406,7 +406,7 @@ static void dlm_mle_node_up(struct dlm_ctxt *dlm, int dlm_init_mle_cache(void) { - dlm_mle_cache = kmem_cache_create("o2dlm_mle", + dlm_mle_cache = kapi_kmem_cache_create("o2dlm_mle", sizeof(struct dlm_master_list_entry), 0, SLAB_HWCACHE_ALIGN, NULL); @@ -457,13 +457,13 @@ static void dlm_mle_release(struct kref *kref) int dlm_init_master_caches(void) { - dlm_lockres_cache = kmem_cache_create("o2dlm_lockres", + dlm_lockres_cache = kapi_kmem_cache_create("o2dlm_lockres", sizeof(struct dlm_lock_resource), 0, SLAB_HWCACHE_ALIGN, NULL); if (!dlm_lockres_cache) goto bail; - dlm_lockname_cache = kmem_cache_create("o2dlm_lockname", + dlm_lockname_cache = kapi_kmem_cache_create("o2dlm_lockname", DLM_LOCKID_NAME_MAX, 0, SLAB_HWCACHE_ALIGN, NULL); if (!dlm_lockname_cache) diff --git a/fs/ocfs2/dlm/kapi-default.h b/fs/ocfs2/dlm/kapi-default.h index 21e5e3a..bcdb486 100644 --- a/fs/ocfs2/dlm/kapi-default.h +++ b/fs/ocfs2/dlm/kapi-default.h @@ -29,4 +29,8 @@ typedef struct work_struct kapi_work_struct_t; # define KAPI_INIT_DELAYED_WORK(a, b, c) INIT_DELAYED_WORK(a, b) #endif +#ifndef kapi_kmem_cache_create +# define kapi_kmem_cache_create(a, b, c, d, e) kmem_cache_create(a, b, c, d, e) +#endif + #endif diff --git a/fs/ocfs2/kapi-default.h b/fs/ocfs2/kapi-default.h index 7489a19..2f60b87 100644 --- a/fs/ocfs2/kapi-default.h +++ b/fs/ocfs2/kapi-default.h @@ -50,4 +50,8 @@ typedef u64 f_version_t; # define kapi_register_sysctl_table(a) register_sysctl_table(a) #endif +#ifndef kapi_kmem_cache_create +# define kapi_kmem_cache_create(a, b, c, d, e) kmem_cache_create(a, b, c, d, e) +#endif + #endif diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index bee2c31..e36bec2 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -1671,7 +1671,12 @@ bail: return status; } +#ifdef KMEM_CACHE_CREATE_DTOR +static void ocfs2_inode_init_once(void *data, struct kmem_cache *cachep, + unsigned long flags) +#else static void ocfs2_inode_init_once(void *data) +#endif { struct ocfs2_inode_info *oi = data; @@ -1701,19 +1706,19 @@ static void ocfs2_inode_init_once(void *data) static int ocfs2_initialize_mem_caches(void) { - ocfs2_inode_cachep = kmem_cache_create("ocfs2_inode_cache", + ocfs2_inode_cachep = kapi_kmem_cache_create("ocfs2_inode_cache", sizeof(struct ocfs2_inode_info), 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT| SLAB_MEM_SPREAD), ocfs2_inode_init_once); - ocfs2_dquot_cachep = kmem_cache_create("ocfs2_dquot_cache", + ocfs2_dquot_cachep = kapi_kmem_cache_create("ocfs2_dquot_cache", sizeof(struct ocfs2_dquot), 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT| SLAB_MEM_SPREAD), NULL); - ocfs2_qf_chunk_cachep = kmem_cache_create("ocfs2_qf_chunk_cache", + ocfs2_qf_chunk_cachep = kapi_kmem_cache_create("ocfs2_qf_chunk_cache", sizeof(struct ocfs2_quota_chunk), 0, (SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD), diff --git a/fs/ocfs2/uptodate.c b/fs/ocfs2/uptodate.c index b6284f2..fe57890 100644 --- a/fs/ocfs2/uptodate.c +++ b/fs/ocfs2/uptodate.c @@ -625,7 +625,7 @@ void ocfs2_remove_xattr_clusters_from_cache(struct ocfs2_caching_info *ci, int __init init_ocfs2_uptodate_cache(void) { - ocfs2_uptodate_cachep = kmem_cache_create("ocfs2_uptodate", + ocfs2_uptodate_cachep = kapi_kmem_cache_create("ocfs2_uptodate", sizeof(struct ocfs2_meta_cache_item), 0, SLAB_HWCACHE_ALIGN, NULL); if (!ocfs2_uptodate_cachep) diff --git a/kapi-compat/include/slab.h b/kapi-compat/include/slab.h new file mode 100644 index 0000000..c682289 --- /dev/null +++ b/kapi-compat/include/slab.h @@ -0,0 +1,8 @@ +#ifndef KAPI_SLAB_H +#define KAPI_SLAB_H + +#ifdef KMEM_CACHE_CREATE_DTOR +# define kapi_kmem_cache_create(a, b, c, d, e) kmem_cache_create(a, b, c, d, e, NULL) +#endif + +#endif -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 04/18] ocfs2/cluster: Handle different prototype of bi_end_io_t
Mainline commit 6712ecf8f648118c3363c142196418f89a510b90 dropped the 'size' argument from bi_end_io_t. Also changed the return from int to void. Patch uses the older prototype when building with EL5 kernels. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Config.make.in | 1 + configure.in | 5 +++++ fs/ocfs2/cluster/Makefile | 4 ++++ fs/ocfs2/cluster/heartbeat.c | 7 +++++++ 4 files changed, 17 insertions(+), 0 deletions(-) diff --git a/Config.make.in b/Config.make.in index fb705b5..618c814 100644 --- a/Config.make.in +++ b/Config.make.in @@ -73,6 +73,7 @@ SEQOP_IS_NOT_CONST = @SEQOP_IS_NOT_CONST@ NO_VECTORIZED_AIO = @NO_VECTORIZED_AIO@ OLD_PERMISSION = @OLD_PERMISSION@ KMEM_CACHE_CREATE_DTOR = @KMEM_CACHE_CREATE_DTOR@ +OLD_BIO_END_IO_T = @OLD_BIO_END_IO_T@ OCFS_DEBUG = @OCFS_DEBUG@ diff --git a/configure.in b/configure.in index 98cdc5d..8696935 100644 --- a/configure.in +++ b/configure.in @@ -334,6 +334,11 @@ OCFS2_CHECK_KERNEL([ older prototype of kmem_cache_create() in slab.h], slab.h, AC_SUBST(KMEM_CACHE_CREATE_DTOR) KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $KMEM_CACHE_CREATE_DTOR" +OLD_BIO_END_IO_T+OCFS2_CHECK_KERNEL([ older prototype of bio_end_io_t in bio.h], bio.h, + OLD_BIO_END_IO_T=yes, , [^typedef int (bio_end_io_t) (struct bio \*, unsigned int, int);]) +AC_SUBST(OLD_BIO_END_IO_T) + # End kapi_compat checks # using -include has two advantages: diff --git a/fs/ocfs2/cluster/Makefile b/fs/ocfs2/cluster/Makefile index 1f040c6..d107cca 100644 --- a/fs/ocfs2/cluster/Makefile +++ b/fs/ocfs2/cluster/Makefile @@ -26,6 +26,10 @@ ifdef SEQOP_IS_NOT_CONST EXTRA_CFLAGS += -DSEQOP_IS_NOT_CONST endif +ifdef OLD_BIO_END_IO_T +EXTRA_CFLAGS += -DOLD_BIO_END_IO_T +endif + SOURCES += \ heartbeat.c \ masklog.c \ diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 68e9af5..d07241f 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -221,7 +221,11 @@ static void o2hb_wait_on_io(struct o2hb_region *reg, wait_for_completion(&wc->wc_io_complete); } +#ifdef OLD_BIO_END_IO_T +static int o2hb_bio_end_io(struct bio *bio, unsigned int size, +#else static void o2hb_bio_end_io(struct bio *bio, +#endif int error) { struct o2hb_bio_wait_ctxt *wc = bio->bi_private; @@ -233,6 +237,9 @@ static void o2hb_bio_end_io(struct bio *bio, o2hb_bio_wait_dec(wc, 1); bio_put(bio); +#ifdef OLD_BIO_END_IO_T + return 0; +#endif } /* Setup a Bio to cover I/O against num_slots slots starting at -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 05/18] ocfs2: Handle missing fmode_t in blkdev_put()
Mainline commit 9a1c3542768b5a58e45a9216921cd10a3bae1205 added arg fmode_t to blkdev_put(). Patch allows building against EL5 by ignoring that argument. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Makefile | 3 ++- configure.in | 5 +++++ fs/ocfs2/cluster/heartbeat.c | 4 ++-- fs/ocfs2/cluster/kapi-default.h | 4 ++++ kapi-compat/include/blkdev_put.h | 6 ++++++ 5 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 kapi-compat/include/blkdev_put.h diff --git a/Makefile b/Makefile index 912fb70..a94d345 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,8 @@ KAPI_COMPAT_FILES = \ kapi-compat/include/umh_wait.h \ kapi-compat/include/register_sysctl.h \ kapi-compat/include/sysctl.h \ - kapi-compat/include/slab.h + kapi-compat/include/slab.h \ + kapi-compat/include/blkdev_put.h PATCH_FILES diff --git a/configure.in b/configure.in index 8696935..6c93e2f 100644 --- a/configure.in +++ b/configure.in @@ -339,6 +339,11 @@ OCFS2_CHECK_KERNEL([ older prototype of bio_end_io_t in bio.h], bio.h, OLD_BIO_END_IO_T=yes, , [^typedef int (bio_end_io_t) (struct bio \*, unsigned int, int);]) AC_SUBST(OLD_BIO_END_IO_T) +blkdev_put_header+OCFS2_CHECK_KERNEL([ older prototype of blkdev_put() in fs.h], fs.h, + blkdev_put_header=blkdev_put.h, , [^extern int blkdev_put(struct block_device \*);]) +KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $blkdev_put_header" + # End kapi_compat checks # using -include has two advantages: diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index d07241f..ed05786 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -1076,7 +1076,7 @@ static void o2hb_region_release(struct config_item *item) } if (reg->hr_bdev) - blkdev_put(reg->hr_bdev, FMODE_READ|FMODE_WRITE); + kapi_blkdev_put(reg->hr_bdev, FMODE_READ|FMODE_WRITE); if (reg->hr_slots) kfree(reg->hr_slots); @@ -1459,7 +1459,7 @@ out: iput(inode); if (ret < 0) { if (reg->hr_bdev) { - blkdev_put(reg->hr_bdev, FMODE_READ|FMODE_WRITE); + kapi_blkdev_put(reg->hr_bdev, FMODE_READ|FMODE_WRITE); reg->hr_bdev = NULL; } } diff --git a/fs/ocfs2/cluster/kapi-default.h b/fs/ocfs2/cluster/kapi-default.h index 21e5e3a..ded908a 100644 --- a/fs/ocfs2/cluster/kapi-default.h +++ b/fs/ocfs2/cluster/kapi-default.h @@ -29,4 +29,8 @@ typedef struct work_struct kapi_work_struct_t; # define KAPI_INIT_DELAYED_WORK(a, b, c) INIT_DELAYED_WORK(a, b) #endif +#ifndef kapi_blkdev_put +# define kapi_blkdev_put blkdev_put +#endif + #endif diff --git a/kapi-compat/include/blkdev_put.h b/kapi-compat/include/blkdev_put.h new file mode 100644 index 0000000..cf30192 --- /dev/null +++ b/kapi-compat/include/blkdev_put.h @@ -0,0 +1,6 @@ +#ifndef KAPI_BLKDEV_PUT_H +#define KAPI_BLKDEV_PUT_H + +#define kapi_blkdev_put(a, b) blkdev_put(a) + +#endif -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 06/18] ocfs2: Handle older prototype of blkdev_get()
Mainline commit 572c48921574dbe6dceb958cf965aa962baefde4 removed the flags argument in blkdev_get(). Patch allows building against EL5 by forcing a 0 in place of that argument. This is ok as we are not using that argument. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Makefile | 3 ++- configure.in | 5 +++++ fs/ocfs2/cluster/heartbeat.c | 2 +- fs/ocfs2/cluster/kapi-default.h | 4 ++++ kapi-compat/include/blkdev_get.h | 6 ++++++ 5 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 kapi-compat/include/blkdev_get.h diff --git a/Makefile b/Makefile index a94d345..5e1bb62 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,8 @@ KAPI_COMPAT_FILES = \ kapi-compat/include/register_sysctl.h \ kapi-compat/include/sysctl.h \ kapi-compat/include/slab.h \ - kapi-compat/include/blkdev_put.h + kapi-compat/include/blkdev_put.h \ + kapi-compat/include/blkdev_get.h PATCH_FILES diff --git a/configure.in b/configure.in index 6c93e2f..8ce5e67 100644 --- a/configure.in +++ b/configure.in @@ -344,6 +344,11 @@ OCFS2_CHECK_KERNEL([ older prototype of blkdev_put() in fs.h], fs.h, blkdev_put_header=blkdev_put.h, , [^extern int blkdev_put(struct block_device \*);]) KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $blkdev_put_header" +blkdev_get_header+OCFS2_CHECK_KERNEL([ older prototype of blkdev_get() in fs.h], fs.h, + blkdev_get_header=blkdev_get.h, , [^extern int blkdev_get(struct block_device \*, mode_t, unsigned);]) +KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $blkdev_get_header" + # End kapi_compat checks # using -include has two advantages: diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index ed05786..3d3e306 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -1368,7 +1368,7 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg, goto out; reg->hr_bdev = I_BDEV(filp->f_mapping->host); - ret = blkdev_get(reg->hr_bdev, FMODE_WRITE | FMODE_READ); + ret = kapi_blkdev_get(reg->hr_bdev, FMODE_WRITE | FMODE_READ); if (ret) { reg->hr_bdev = NULL; goto out; diff --git a/fs/ocfs2/cluster/kapi-default.h b/fs/ocfs2/cluster/kapi-default.h index ded908a..fc3da05 100644 --- a/fs/ocfs2/cluster/kapi-default.h +++ b/fs/ocfs2/cluster/kapi-default.h @@ -33,4 +33,8 @@ typedef struct work_struct kapi_work_struct_t; # define kapi_blkdev_put blkdev_put #endif +#ifndef kapi_blkdev_get +# define kapi_blkdev_get blkdev_get +#endif + #endif diff --git a/kapi-compat/include/blkdev_get.h b/kapi-compat/include/blkdev_get.h new file mode 100644 index 0000000..dcf7425 --- /dev/null +++ b/kapi-compat/include/blkdev_get.h @@ -0,0 +1,6 @@ +#ifndef KAPI_BLKDEV_GET_H +#define KAPI_BLKDEV_GET_H + +#define kapi_blkdev_get(a, b) blkdev_get(a, b, 0) + +#endif -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 07/18] ocfs2: Handles missing configfs_depend_item() and configfs_undepend_item()
Mainline commit 631d1febab8e546e3bb800bdfe2c212b8adf87de added configfs_depend_item() and configfs_undepend_item(). Patch adds empty macros when building against EL5 that does not have the functionality. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Makefile | 3 ++- configure.in | 5 +++++ kapi-compat/include/configfs.h | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletions(-) create mode 100644 kapi-compat/include/configfs.h diff --git a/Makefile b/Makefile index 5e1bb62..00535ff 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,8 @@ KAPI_COMPAT_FILES = \ kapi-compat/include/sysctl.h \ kapi-compat/include/slab.h \ kapi-compat/include/blkdev_put.h \ - kapi-compat/include/blkdev_get.h + kapi-compat/include/blkdev_get.h \ + kapi-compat/include/configfs.h PATCH_FILES diff --git a/configure.in b/configure.in index 8ce5e67..aad0ea1 100644 --- a/configure.in +++ b/configure.in @@ -349,6 +349,11 @@ OCFS2_CHECK_KERNEL([ older prototype of blkdev_get() in fs.h], fs.h, blkdev_get_header=blkdev_get.h, , [^extern int blkdev_get(struct block_device \*, mode_t, unsigned);]) KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $blkdev_get_header" +configfs_compat_header+OCFS2_CHECK_KERNEL([configfs_depend_item() in configfs.h], configfs.h, + , configfs_compat_header=configfs.h, [^int configfs_depend_item(]) +KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $configfs_compat_header" + # End kapi_compat checks # using -include has two advantages: diff --git a/kapi-compat/include/configfs.h b/kapi-compat/include/configfs.h new file mode 100644 index 0000000..cbc11e6 --- /dev/null +++ b/kapi-compat/include/configfs.h @@ -0,0 +1,7 @@ +#ifndef KAPI_CONFIGFS_H +#define KAPI_CONFIGFS_H + +#define configfs_depend_item(a, b) (0) +#define configfs_undepend_item(a, b) + +#endif -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 08/18] ocfs2: Handle missing mutex in struct configfs_subsystem
Mainline commit e6bd07aee739566803425acdbf5cdb29919164e1 changed a semaphore (su_sem) into a mutex (su_mutex) in struct configfs_subsystem. Patch adds macros to allow building with EL5. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Makefile | 3 ++- configure.in | 5 +++++ fs/ocfs2/cluster/kapi-default.h | 5 +++++ fs/ocfs2/cluster/nodemanager.c | 2 +- kapi-compat/include/su_mutex.h | 9 +++++++++ 5 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 kapi-compat/include/su_mutex.h diff --git a/Makefile b/Makefile index 00535ff..623bda4 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,8 @@ KAPI_COMPAT_FILES = \ kapi-compat/include/slab.h \ kapi-compat/include/blkdev_put.h \ kapi-compat/include/blkdev_get.h \ - kapi-compat/include/configfs.h + kapi-compat/include/configfs.h \ + kapi-compat/include/su_mutex.h PATCH_FILES diff --git a/configure.in b/configure.in index aad0ea1..af32060 100644 --- a/configure.in +++ b/configure.in @@ -354,6 +354,11 @@ OCFS2_CHECK_KERNEL([configfs_depend_item() in configfs.h], configfs.h, , configfs_compat_header=configfs.h, [^int configfs_depend_item(]) KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $configfs_compat_header" +su_mutex_header+OCFS2_CHECK_KERNEL([su_mutex in struct configfs_subsystem in configfs.h], configfs.h, + , su_mutex_header=su_mutex.h, [struct mutex su_mutex;]) +KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $su_mutex_header" + # End kapi_compat checks # using -include has two advantages: diff --git a/fs/ocfs2/cluster/kapi-default.h b/fs/ocfs2/cluster/kapi-default.h index fc3da05..81dce2f 100644 --- a/fs/ocfs2/cluster/kapi-default.h +++ b/fs/ocfs2/cluster/kapi-default.h @@ -37,4 +37,9 @@ typedef struct work_struct kapi_work_struct_t; # define kapi_blkdev_get blkdev_get #endif +#ifndef kapi_mutex_init +# define kapi_mutex_init mutex_init +# define su_mutex su_mutex +#endif + #endif diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index 7ee6188..31140df 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c @@ -903,7 +903,7 @@ static int __init init_o2nm(void) goto out_o2net; config_group_init(&o2nm_cluster_group.cs_subsys.su_group); - mutex_init(&o2nm_cluster_group.cs_subsys.su_mutex); + kapi_mutex_init(&o2nm_cluster_group.cs_subsys.su_mutex); ret = configfs_register_subsystem(&o2nm_cluster_group.cs_subsys); if (ret) { printk(KERN_ERR "nodemanager: Registration returned %d\n", ret); diff --git a/kapi-compat/include/su_mutex.h b/kapi-compat/include/su_mutex.h new file mode 100644 index 0000000..6713348 --- /dev/null +++ b/kapi-compat/include/su_mutex.h @@ -0,0 +1,9 @@ +#ifndef KAPI_SUMUTEX_H +#define KAPI_SUMUTEX_H + +#include "asm/semaphore.h" + +#define kapi_mutex_init init_MUTEX +#define su_mutex su_sem + +#endif -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 09/18] ocfs2: Handle missing helper kernel_sock_shutdown()
Mainline commit 91cf45f02af5c871251165d000c3f42a2a0b0552 added helper kernel_sock_shutdown(). Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Makefile | 3 ++- configure.in | 5 +++++ kapi-compat/include/sock_shutdown.h | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletions(-) create mode 100644 kapi-compat/include/sock_shutdown.h diff --git a/Makefile b/Makefile index 623bda4..0dd7443 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,8 @@ KAPI_COMPAT_FILES = \ kapi-compat/include/blkdev_put.h \ kapi-compat/include/blkdev_get.h \ kapi-compat/include/configfs.h \ - kapi-compat/include/su_mutex.h + kapi-compat/include/su_mutex.h \ + kapi-compat/include/sock_shutdown.h PATCH_FILES diff --git a/configure.in b/configure.in index af32060..e045fa8 100644 --- a/configure.in +++ b/configure.in @@ -359,6 +359,11 @@ OCFS2_CHECK_KERNEL([su_mutex in struct configfs_subsystem in configfs.h], config , su_mutex_header=su_mutex.h, [struct mutex su_mutex;]) KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $su_mutex_header" +sock_shutdown_header+OCFS2_CHECK_KERNEL([kernel_sock_shutdown() in net.t], net.h, + , sock_shutdown_header=sock_shutdown.h, [^extern int kernel_sock_shutdown(struct socket \*sock]) +KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $sock_shutdown_header" + # End kapi_compat checks # using -include has two advantages: diff --git a/kapi-compat/include/sock_shutdown.h b/kapi-compat/include/sock_shutdown.h new file mode 100644 index 0000000..83efccd --- /dev/null +++ b/kapi-compat/include/sock_shutdown.h @@ -0,0 +1,17 @@ +#ifndef KAPI_SOCK_SHUTDOWN_H +#define KAPI_SOCK_SHUTDOWN_H + +#include <linux/net.h> + +enum sock_shutdown_cmd { + SHUT_RD = 0, + SHUT_WR = 1, + SHUT_RDWR = 2, +}; + +static inline int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how) +{ + return sock->ops->shutdown(sock, how); +} + +#endif -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 10/18] ocfs2: Handle missing bdi_init()/bdi_destroy()
Mainline commit e0bf68ddec4f4f90e5871404be4f1854c17f3120 added bdi_init() and bdi_destroy(). Patch adds empty inlines to allow building with EL5. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Makefile | 3 ++- configure.in | 5 +++++ kapi-compat/include/bdi_init.h | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 1 deletions(-) create mode 100644 kapi-compat/include/bdi_init.h diff --git a/Makefile b/Makefile index 0dd7443..68f746e 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,8 @@ KAPI_COMPAT_FILES = \ kapi-compat/include/blkdev_get.h \ kapi-compat/include/configfs.h \ kapi-compat/include/su_mutex.h \ - kapi-compat/include/sock_shutdown.h + kapi-compat/include/sock_shutdown.h \ + kapi-compat/include/bdi_init.h PATCH_FILES diff --git a/configure.in b/configure.in index e045fa8..53deffd 100644 --- a/configure.in +++ b/configure.in @@ -364,6 +364,11 @@ OCFS2_CHECK_KERNEL([kernel_sock_shutdown() in net.t], net.h, , sock_shutdown_header=sock_shutdown.h, [^extern int kernel_sock_shutdown(struct socket \*sock]) KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $sock_shutdown_header" +bdi_init_compat_header+OCFS2_CHECK_KERNEL([bdi_init() in backing-dev.h], backing-dev.h, + , bdi_init_compat_header=bdi_init.h, [^int bdi_init(struct backing_dev_info \*bdi);]) +KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $bdi_init_compat_header" + # End kapi_compat checks # using -include has two advantages: diff --git a/kapi-compat/include/bdi_init.h b/kapi-compat/include/bdi_init.h new file mode 100644 index 0000000..2966533 --- /dev/null +++ b/kapi-compat/include/bdi_init.h @@ -0,0 +1,14 @@ +#ifndef KAPI_BDI_INIT_H +#define KAPI_BDI_INIT_H + +static inline int bdi_init(struct backing_dev_info *bdi) +{ + return 0; +} + +static inline void bdi_destroy(struct backing_dev_info *bdi) +{ + return ; +} + +#endif -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 11/18] ocfs2: Handle missing BDI_CAP_NO_ACCT_AND_WRITEBACK
Mainline commit e4ad08fe64afca4ef79ecc4c624e6e871688da0d added macro BDI_CAP_NO_ACCT_AND_WRITEBACK. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Makefile | 3 ++- configure.in | 5 +++++ kapi-compat/include/bdi_define.h | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletions(-) create mode 100644 kapi-compat/include/bdi_define.h diff --git a/Makefile b/Makefile index 68f746e..1cd2584 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,8 @@ KAPI_COMPAT_FILES = \ kapi-compat/include/configfs.h \ kapi-compat/include/su_mutex.h \ kapi-compat/include/sock_shutdown.h \ - kapi-compat/include/bdi_init.h + kapi-compat/include/bdi_init.h \ + kapi-compat/include/bdi_define.h PATCH_FILES diff --git a/configure.in b/configure.in index 53deffd..5fe4934 100644 --- a/configure.in +++ b/configure.in @@ -369,6 +369,11 @@ OCFS2_CHECK_KERNEL([bdi_init() in backing-dev.h], backing-dev.h, , bdi_init_compat_header=bdi_init.h, [^int bdi_init(struct backing_dev_info \*bdi);]) KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $bdi_init_compat_header" +bdi_define_compat_header+OCFS2_CHECK_KERNEL([BDI_CAP_NO_ACCT_AND_WRITEBACK in backing-dev.h], backing-dev.h, + , bdi_define_compat_header=bdi_define.h, [^#define BDI_CAP_NO_ACCT_AND_WRITEBACK]) +KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $bdi_define_compat_header" + # End kapi_compat checks # using -include has two advantages: diff --git a/kapi-compat/include/bdi_define.h b/kapi-compat/include/bdi_define.h new file mode 100644 index 0000000..28de9da --- /dev/null +++ b/kapi-compat/include/bdi_define.h @@ -0,0 +1,6 @@ +#ifndef KAPI_BDI_DEFINE_H +#define KAPI_BDI_DEFINE_H + +#define BDI_CAP_NO_ACCT_AND_WRITEBACK (BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK) + +#endif -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 12/18] ocfs2: Handle missing vmops->fault()
Mainline commit 54cb8821de07f2ffcd28c380ce9b93d5784b40d7 introduced vmops->fault() to replace vmops->populate() and vmops->nopage(). Patch adds nopage() and uses it when building against EL5. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Config.make.in | 1 + configure.in | 5 ++++ fs/ocfs2/Makefile | 4 +++ fs/ocfs2/mmap.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 65 insertions(+), 1 deletions(-) diff --git a/Config.make.in b/Config.make.in index 618c814..a0330b9 100644 --- a/Config.make.in +++ b/Config.make.in @@ -74,6 +74,7 @@ NO_VECTORIZED_AIO = @NO_VECTORIZED_AIO@ OLD_PERMISSION = @OLD_PERMISSION@ KMEM_CACHE_CREATE_DTOR = @KMEM_CACHE_CREATE_DTOR@ OLD_BIO_END_IO_T = @OLD_BIO_END_IO_T@ +NO_FAULT_IN_VMOPS = @NO_FAULT_IN_VMOPS@ OCFS_DEBUG = @OCFS_DEBUG@ diff --git a/configure.in b/configure.in index 5fe4934..a65ba15 100644 --- a/configure.in +++ b/configure.in @@ -374,6 +374,11 @@ OCFS2_CHECK_KERNEL([BDI_CAP_NO_ACCT_AND_WRITEBACK in backing-dev.h], backing-dev , bdi_define_compat_header=bdi_define.h, [^#define BDI_CAP_NO_ACCT_AND_WRITEBACK]) KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $bdi_define_compat_header" +NO_FAULT_IN_VMOPS+OCFS2_CHECK_KERNEL([fault() in struct vm_operations_struct in mm.h], mm.h, + , NO_FAULT_IN_VMOPS=yes, [^.*int (\*fault)]) +AC_SUBST(NO_FAULT_IN_VMOPS) + # End kapi_compat checks # using -include has two advantages: diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile index c769fd8..401a1f5 100644 --- a/fs/ocfs2/Makefile +++ b/fs/ocfs2/Makefile @@ -96,6 +96,10 @@ ifdef KMEM_CACHE_CREATE_DTOR EXTRA_CFLAGS += -DKMEM_CACHE_CREATE_DTOR endif +ifdef NO_FAULT_IN_VMOPS +EXTRA_CFLAGS += -DNO_FAULT_IN_VMOPS +endif + # # Since SUBDIRS means something to kbuild, define them safely. Do not # include trailing slashes. diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c index b4a25c8..4d37071 100644 --- a/fs/ocfs2/mmap.c +++ b/fs/ocfs2/mmap.c @@ -60,6 +60,7 @@ static inline int ocfs2_vm_op_unblock_sigs(sigset_t *oldset) return sigprocmask(SIG_SETMASK, oldset, NULL); } +#ifndef NO_FAULT_IN_VMOPS static int ocfs2_fault(struct vm_area_struct *area, struct vm_fault *vmf) { sigset_t blocked, oldset; @@ -83,6 +84,35 @@ out: mlog_exit_ptr(vmf->page); return ret; } +#else +static struct page *ocfs2_nopage(struct vm_area_struct * area, + unsigned long address, + int *type) +{ + struct page *page = NOPAGE_SIGBUS; + sigset_t blocked, oldset; + int error, ret; + + mlog_entry("(area=%p, address=%lu, type=%p)\n", area, address, + type); + + error = ocfs2_vm_op_block_sigs(&blocked, &oldset); + if (error < 0) { + mlog_errno(error); + ret = VM_FAULT_SIGBUS; + goto out; + } + + page = filemap_nopage(area, address, type); + + error = ocfs2_vm_op_unblock_sigs(&oldset); + if (error < 0) + mlog_errno(error); +out: + mlog_exit_ptr(page); + return page; +} +#endif static int __ocfs2_page_mkwrite(struct inode *inode, struct buffer_head *di_bh, struct page *page) @@ -96,6 +126,9 @@ static int __ocfs2_page_mkwrite(struct inode *inode, struct buffer_head *di_bh, void *fsdata; loff_t size = i_size_read(inode); + mlog_entry("(inode=0x%p, i_ino=%lu, page=0x%p)\n", inode, inode->i_ino, + page); + /* * Another node might have truncated while we were waiting on * cluster locks. @@ -151,17 +184,26 @@ static int __ocfs2_page_mkwrite(struct inode *inode, struct buffer_head *di_bh, BUG_ON(ret != len); ret = 0; out: + mlog_exit(ret); return ret; } +#ifndef NO_FAULT_IN_VMOPS static int ocfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) +#else +static int ocfs2_page_mkwrite(struct vm_area_struct *vma, struct page *page) +#endif { +#ifndef NO_FAULT_IN_VMOPS struct page *page = vmf->page; +#endif struct inode *inode = filp_dentry(vma->vm_file)->d_inode; struct buffer_head *di_bh = NULL; sigset_t blocked, oldset; int ret, ret2; + mlog_entry("(vma=0x%p, page=0x%p)\n", vma, page); + ret = ocfs2_vm_op_block_sigs(&blocked, &oldset); if (ret < 0) { mlog_errno(ret); @@ -199,6 +241,7 @@ out: mlog_errno(ret2); if (ret) ret = VM_FAULT_SIGBUS; + mlog_exit(ret); return ret; } @@ -207,7 +250,11 @@ static struct vm_operations_struct ocfs2_file_vm_ops = { #else static const struct vm_operations_struct ocfs2_file_vm_ops = { #endif +#ifndef NO_FAULT_IN_VMOPS .fault = ocfs2_fault, +#else + .nopage = ocfs2_nopage, +#endif .page_mkwrite = ocfs2_page_mkwrite, }; @@ -215,6 +262,10 @@ int ocfs2_mmap(struct file *file, struct vm_area_struct *vma) { int ret = 0, lock_level = 0; + mlog_entry("(file=0x%p, vma=%p, '%.*s')\n", file, vma, + filp_dentry(file)->d_name.len, + filp_dentry(file)->d_name.name); + ret = ocfs2_inode_lock_atime(filp_dentry(file)->d_inode, filp_mnt(file), &lock_level); if (ret < 0) { @@ -224,7 +275,10 @@ int ocfs2_mmap(struct file *file, struct vm_area_struct *vma) ocfs2_inode_unlock(filp_dentry(file)->d_inode, lock_level); out: vma->vm_ops = &ocfs2_file_vm_ops; +#ifndef NO_FAULT_IN_VMOPS vma->vm_flags |= VM_CAN_NONLINEAR; - return 0; +#endif + mlog_exit(ret); + return ret; } -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 13/18] ocfs2: Handle missing inode_permission()
Mainline commit f419a2e3b64def707e1384ee38abb77f99af5f6d renamed permission() to inode_permission(). Patch uses an inline to redirect inode_permission() to permission() when building with EL5. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Makefile | 3 ++- configure.in | 5 +++++ kapi-compat/include/inode_permission.h | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletions(-) create mode 100644 kapi-compat/include/inode_permission.h diff --git a/Makefile b/Makefile index 1cd2584..898879d 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,8 @@ KAPI_COMPAT_FILES = \ kapi-compat/include/su_mutex.h \ kapi-compat/include/sock_shutdown.h \ kapi-compat/include/bdi_init.h \ - kapi-compat/include/bdi_define.h + kapi-compat/include/bdi_define.h \ + kapi-compat/include/inode_permission.h PATCH_FILES diff --git a/configure.in b/configure.in index a65ba15..56315a6 100644 --- a/configure.in +++ b/configure.in @@ -379,6 +379,11 @@ OCFS2_CHECK_KERNEL([fault() in struct vm_operations_struct in mm.h], mm.h, , NO_FAULT_IN_VMOPS=yes, [^.*int (\*fault)]) AC_SUBST(NO_FAULT_IN_VMOPS) +inode_permission_header+OCFS2_CHECK_KERNEL([inode_permision in fs.h], fs.h, + , inode_permission_header=inode_permission.h, [^extern int inode_permission(struct inode \*]) +KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $inode_permission_header" + # End kapi_compat checks # using -include has two advantages: diff --git a/kapi-compat/include/inode_permission.h b/kapi-compat/include/inode_permission.h new file mode 100644 index 0000000..43f80d3 --- /dev/null +++ b/kapi-compat/include/inode_permission.h @@ -0,0 +1,11 @@ +#ifndef INODE_PERMISSION_H +#define INODE_PERMISSION_H + +#include <linux/fs.h> + +static inline int inode_permission(struct inode *inode, int flags) +{ + return permission(inode, flags, NULL); +} + +#endif -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 14/18] ocfs2: Handle older prototype of simple attribute get()
Mainline commit 8b88b0998e35d239e74446cc30f354bdab86df89 changed prototype of simple attribute get() by returning the value via an argument. Patch detects older kernels and uses the older prototype that just return(ed) the value. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Config.make.in | 1 + configure.in | 5 +++++ fs/ocfs2/Makefile | 4 ++++ fs/ocfs2/blockcheck.c | 8 ++++++++ 4 files changed, 18 insertions(+), 0 deletions(-) diff --git a/Config.make.in b/Config.make.in index a0330b9..355bf2a 100644 --- a/Config.make.in +++ b/Config.make.in @@ -75,6 +75,7 @@ OLD_PERMISSION = @OLD_PERMISSION@ KMEM_CACHE_CREATE_DTOR = @KMEM_CACHE_CREATE_DTOR@ OLD_BIO_END_IO_T = @OLD_BIO_END_IO_T@ NO_FAULT_IN_VMOPS = @NO_FAULT_IN_VMOPS@ +GET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN = @GET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN@ OCFS_DEBUG = @OCFS_DEBUG@ diff --git a/configure.in b/configure.in index 56315a6..b8f1bd8 100644 --- a/configure.in +++ b/configure.in @@ -384,6 +384,11 @@ OCFS2_CHECK_KERNEL([inode_permision in fs.h], fs.h, , inode_permission_header=inode_permission.h, [^extern int inode_permission(struct inode \*]) KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $inode_permission_header" +GET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN+OCFS2_CHECK_KERNEL([ get() return u64 in simple_attr_open() in fs.h], fs.h, + GET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN=yes, , [u64 (\*get)(void \*), void (\*set)(void \*, u64),]) +AC_SUBST(GET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN) + # End kapi_compat checks # using -include has two advantages: diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile index 401a1f5..6960f40 100644 --- a/fs/ocfs2/Makefile +++ b/fs/ocfs2/Makefile @@ -100,6 +100,10 @@ ifdef NO_FAULT_IN_VMOPS EXTRA_CFLAGS += -DNO_FAULT_IN_VMOPS endif +ifdef GET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN +EXTRA_CFLAGS += -DGET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN +endif + # # Since SUBDIRS means something to kbuild, define them safely. Do not # include trailing slashes. diff --git a/fs/ocfs2/blockcheck.c b/fs/ocfs2/blockcheck.c index a1163b8..4927bf9 100644 --- a/fs/ocfs2/blockcheck.c +++ b/fs/ocfs2/blockcheck.c @@ -232,11 +232,19 @@ void ocfs2_hamming_fix_block(void *data, unsigned int blocksize, #ifdef CONFIG_DEBUG_FS +#ifdef GET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN +static u64 blockcheck_u64_get(void *data) +{ + return *(u64 *)data; +} +#else static int blockcheck_u64_get(void *data, u64 *val) { *val = *(u64 *)data; return 0; } +#endif + DEFINE_SIMPLE_ATTRIBUTE(blockcheck_fops, blockcheck_u64_get, NULL, "%llu\n"); static struct dentry *blockcheck_debugfs_create(const char *name, -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 15/18] ocfs2: Handle missing export should_remove_suid()
Mainline commit d23a147bb6e8d467e8df73b6589888717da3b9ce exported the symbol should_remove_suid(). Patch adds compat_should_remove_suid.c that includes the same function that gets built when building with EL5. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Config.make.in | 1 + Makefile | 3 +- configure.in | 10 +++++++ fs/ocfs2/Makefile | 6 ++++ fs/ocfs2/compat_should_remove_suid.c | 40 ++++++++++++++++++++++++++++++ kapi-compat/include/should_remove_suid.h | 12 +++++++++ 6 files changed, 71 insertions(+), 1 deletions(-) create mode 100644 fs/ocfs2/compat_should_remove_suid.c create mode 100644 kapi-compat/include/should_remove_suid.h diff --git a/Config.make.in b/Config.make.in index 355bf2a..4b5f4c3 100644 --- a/Config.make.in +++ b/Config.make.in @@ -76,6 +76,7 @@ KMEM_CACHE_CREATE_DTOR = @KMEM_CACHE_CREATE_DTOR@ OLD_BIO_END_IO_T = @OLD_BIO_END_IO_T@ NO_FAULT_IN_VMOPS = @NO_FAULT_IN_VMOPS@ GET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN = @GET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN@ +NO_SHOULD_REMOVE_SUID = @NO_SHOULD_REMOVE_SUID@ OCFS_DEBUG = @OCFS_DEBUG@ diff --git a/Makefile b/Makefile index 898879d..8536d51 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,8 @@ KAPI_COMPAT_FILES = \ kapi-compat/include/sock_shutdown.h \ kapi-compat/include/bdi_init.h \ kapi-compat/include/bdi_define.h \ - kapi-compat/include/inode_permission.h + kapi-compat/include/inode_permission.h \ + kapi-compat/include/should_remove_suid.h PATCH_FILES diff --git a/configure.in b/configure.in index b8f1bd8..3b8fd4e 100644 --- a/configure.in +++ b/configure.in @@ -389,6 +389,16 @@ OCFS2_CHECK_KERNEL([ get() return u64 in simple_attr_open() in fs.h], fs.h, GET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN=yes, , [u64 (\*get)(void \*), void (\*set)(void \*, u64),]) AC_SUBST(GET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN) +NO_SHOULD_REMOVE_SUID+AC_MSG_CHECKING(for including should_remove_suid()) +AC_ARG_ENABLE(srsuid, [ --enable-srsuid=[yes/no] Include should_remove_suid() [default=yes]],,enable_srsuid=yes) +if test "x$enable_srsuid" = "xyes"; then + NO_SHOULD_REMOVE_SUID=yes + KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS should_remove_suid.h" +fi +AC_SUBST(NO_SHOULD_REMOVE_SUID) +AC_MSG_RESULT($enable_srsuid) + # End kapi_compat checks # using -include has two advantages: diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile index 6960f40..4a4c250 100644 --- a/fs/ocfs2/Makefile +++ b/fs/ocfs2/Makefile @@ -104,6 +104,12 @@ ifdef GET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN EXTRA_CFLAGS += -DGET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN endif +COMPAT_SOURCES += compat_should_remove_suid.c +ifdef NO_SHOULD_REMOVE_SUID +FS_SOURCES += compat_should_remove_suid.c +EXTRA_CFLAGS += -DNO_SHOULD_REMOVE_SUID +endif + # # Since SUBDIRS means something to kbuild, define them safely. Do not # include trailing slashes. diff --git a/fs/ocfs2/compat_should_remove_suid.c b/fs/ocfs2/compat_should_remove_suid.c new file mode 100644 index 0000000..6b4fdc7 --- /dev/null +++ b/fs/ocfs2/compat_should_remove_suid.c @@ -0,0 +1,40 @@ +/* + * compat_should_remove_suid.c + * + * This code has been copied from mainline linux kernel git commit + * e7b34019606ab1dd06196635e931b0c302799228 to allow ocfs2 to build + * against older kernels. For license, refer to mm/filemap.c in mainline + * linux kernel. + * + */ + +#include <linux/fs.h> +#include <linux/capability.h> + +/* + * The logic we want is + * + * if suid or (sgid and xgrp) + * remove privs + */ +int should_remove_suid(struct dentry *dentry) +{ + mode_t mode = dentry->d_inode->i_mode; + int kill = 0; + + /* suid always must be killed */ + if (unlikely(mode & S_ISUID)) + kill = ATTR_KILL_SUID; + + /* + * sgid without any exec bits is just a mandatory locking mark; leave + * it alone. If some exec bits are set, it's a real sgid; kill it. + */ + if (unlikely((mode & S_ISGID) && (mode & S_IXGRP))) + kill |= ATTR_KILL_SGID; + + if (unlikely(kill && !capable(CAP_FSETID))) + return kill; + + return 0; +} diff --git a/kapi-compat/include/should_remove_suid.h b/kapi-compat/include/should_remove_suid.h new file mode 100644 index 0000000..8491125 --- /dev/null +++ b/kapi-compat/include/should_remove_suid.h @@ -0,0 +1,12 @@ +#ifndef KAPI_SHOULD_REMOVE_SUID_H +#define KAPI_SHOULD_REMOVE_SUID_H + +#ifdef NO_SHOULD_REMOVE_SUID + +#include <linux/fs.h> + +int should_remove_suid(struct dentry *dentry); + +#endif + +#endif -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 16/18] ocfs2: Handle missing struct path in struct nameidata
Mainline commit 4ac9137858e08a19f29feac4e1f4df7c268b0ba5 embedded struct path into struct nameidata. Mainline commit 2d8f30380ab8c706f4e0a8f1aaa22b5886e9ac8a added new helpers like user_path_at() that passed struct path instead of struct nameidata. Patch adds access wrappers to allow building against current and EL5 kernels. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Makefile | 3 ++- configure.in | 5 +++++ fs/ocfs2/kapi-default.h | 9 +++++++++ fs/ocfs2/refcounttree.c | 18 +++++++++--------- kapi-compat/include/user_path_at.h | 11 +++++++++++ 5 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 kapi-compat/include/user_path_at.h diff --git a/Makefile b/Makefile index 8536d51..3447409 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,8 @@ KAPI_COMPAT_FILES = \ kapi-compat/include/bdi_init.h \ kapi-compat/include/bdi_define.h \ kapi-compat/include/inode_permission.h \ - kapi-compat/include/should_remove_suid.h + kapi-compat/include/should_remove_suid.h \ + kapi-compat/include/user_path_at.h PATCH_FILES diff --git a/configure.in b/configure.in index 3b8fd4e..86dc11b 100644 --- a/configure.in +++ b/configure.in @@ -399,6 +399,11 @@ fi AC_SUBST(NO_SHOULD_REMOVE_SUID) AC_MSG_RESULT($enable_srsuid) +user_path_header+OCFS2_CHECK_KERNEL([struct path in struct nameidata in namei.h], namei.h, + , user_path_header=user_path_at.h, [struct path.*path;]) +KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $user_path_header" + # End kapi_compat checks # using -include has two advantages: diff --git a/fs/ocfs2/kapi-default.h b/fs/ocfs2/kapi-default.h index 2f60b87..7b16678 100644 --- a/fs/ocfs2/kapi-default.h +++ b/fs/ocfs2/kapi-default.h @@ -54,4 +54,13 @@ typedef u64 f_version_t; # define kapi_kmem_cache_create(a, b, c, d, e) kmem_cache_create(a, b, c, d, e) #endif +#ifndef kapi_path +# define kapi_path path +# define kapi_path_put path_put +# define kapi_user_path_at(a, b, c, d) user_path_at(a, b, c, d) +# define kapi_to_mnt(a) (a).path.mnt +# define kapi_to_dentry(a) (a).path.dentry +# define kapi_to_path_ptr(a) (&(a).path) +#endif + #endif diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 60287fc..49771c3 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4260,14 +4260,14 @@ int ocfs2_reflink_ioctl(struct inode *inode, { struct dentry *new_dentry; struct nameidata nd; - struct path old_path; + struct kapi_path old_path; int error; char *to = NULL; if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb))) return -EOPNOTSUPP; - error = user_path_at(AT_FDCWD, oldname, 0, &old_path); + error = kapi_user_path_at(AT_FDCWD, oldname, 0, &old_path); if (error) { mlog_errno(error); return error; @@ -4280,7 +4280,7 @@ int ocfs2_reflink_ioctl(struct inode *inode, } error = -EXDEV; - if (old_path.mnt != nd.path.mnt) + if (old_path.mnt != kapi_to_mnt(nd)) goto out_release; new_dentry = lookup_create(&nd, 0); error = PTR_ERR(new_dentry); @@ -4289,25 +4289,25 @@ int ocfs2_reflink_ioctl(struct inode *inode, goto out_unlock; } - error = mnt_want_write(nd.path.mnt); + error = mnt_want_write(kapi_to_mnt(nd)); if (error) { mlog_errno(error); goto out_dput; } error = ocfs2_vfs_reflink(old_path.dentry, - nd.path.dentry->d_inode, + kapi_to_dentry(nd)->d_inode, new_dentry, preserve); - mnt_drop_write(nd.path.mnt); + mnt_drop_write(kapi_to_mnt(nd)); out_dput: dput(new_dentry); out_unlock: - mutex_unlock(&nd.path.dentry->d_inode->i_mutex); + mutex_unlock(&kapi_to_dentry(nd)->d_inode->i_mutex); out_release: - path_put(&nd.path); + kapi_path_put(kapi_to_path_ptr(nd)); putname(to); out: - path_put(&old_path); + kapi_path_put(&old_path); return error; } diff --git a/kapi-compat/include/user_path_at.h b/kapi-compat/include/user_path_at.h new file mode 100644 index 0000000..fc11d36 --- /dev/null +++ b/kapi-compat/include/user_path_at.h @@ -0,0 +1,11 @@ +#ifndef KAPI_USER_WALK_AT_H +#define KAPI_USER_WALK_AT_H + +#define kapi_path nameidata +#define kapi_path_put path_release +#define kapi_user_path_at(a, b, c, d) __user_walk(b, c, d) +#define kapi_to_mnt(a) (a).mnt +#define kapi_to_dentry(a) (a).dentry +#define kapi_to_path_ptr(a) (&(a)) + +#endif -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 17/18] ocfs2: Handle missing filemap_fdatawait_range()
Mainline commit 918941a3f3d46c2a69971b4718aaf13b1be2f1a7 replaced generic_file_aio_write_nolock() with __generic_file_aio_write() and made use of helpers filemap_fdatawrite_range() and filemap_fdatawait_range(). Patch adds macros to allow building with current and older EL5 kernels. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Makefile | 3 ++- configure.in | 5 +++++ fs/ocfs2/file.c | 6 +++--- fs/ocfs2/kapi-default.h | 6 ++++++ kapi-compat/include/filemap_fdatawait_range.h | 8 ++++++++ 5 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 kapi-compat/include/filemap_fdatawait_range.h diff --git a/Makefile b/Makefile index 3447409..7d9e0a9 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,8 @@ KAPI_COMPAT_FILES = \ kapi-compat/include/bdi_define.h \ kapi-compat/include/inode_permission.h \ kapi-compat/include/should_remove_suid.h \ - kapi-compat/include/user_path_at.h + kapi-compat/include/user_path_at.h \ + kapi-compat/include/filemap_fdatawait_range.h PATCH_FILES diff --git a/configure.in b/configure.in index 86dc11b..a992f4b 100644 --- a/configure.in +++ b/configure.in @@ -404,6 +404,11 @@ OCFS2_CHECK_KERNEL([struct path in struct nameidata in namei.h], namei.h, , user_path_header=user_path_at.h, [struct path.*path;]) KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $user_path_header" +fdatawait_header+OCFS2_CHECK_KERNEL([filemap_fdatawait_range() in fs.h], fs.h, + , fdatawait_header=filemap_fdatawait_range.h, [extern int filemap_fdatawait_range(struct address_space \*,]) +KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $fdatawait_header" + # End kapi_compat checks # using -include has two advantages: diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 4c12c2d..1367586 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2002,7 +2002,7 @@ relock: goto out_dio; } } else { - written = __generic_file_aio_write(iocb, iov, nr_segs, ppos); + written = kapi_generic_file_aio_write(iocb, iov, nr_segs, ppos); } out_dio: @@ -2010,7 +2010,7 @@ out_dio: BUG_ON(ret == -EIOCBQUEUED && !(file->f_flags & O_DIRECT)); if ((file->f_flags & O_SYNC && !direct_io) || IS_SYNC(inode)) { - ret = filemap_fdatawrite_range(file->f_mapping, pos, + ret = kapi_filemap_fdatawrite_range(file->f_mapping, pos, pos + count - 1); if (ret < 0) written = ret; @@ -2023,7 +2023,7 @@ out_dio: } if (!ret) - ret = filemap_fdatawait_range(file->f_mapping, pos, + ret = kapi_filemap_fdatawait_range(file->f_mapping, pos, pos + count - 1); } diff --git a/fs/ocfs2/kapi-default.h b/fs/ocfs2/kapi-default.h index 7b16678..b1afdcf 100644 --- a/fs/ocfs2/kapi-default.h +++ b/fs/ocfs2/kapi-default.h @@ -63,4 +63,10 @@ typedef u64 f_version_t; # define kapi_to_path_ptr(a) (&(a).path) #endif +#ifndef kapi_generic_file_aio_write +# define kapi_generic_file_aio_write __generic_file_aio_write +# define kapi_filemap_fdatawrite_range filemap_fdatawrite_range +# define kapi_filemap_fdatawait_range filemap_fdatawait_range +#endif + #endif diff --git a/kapi-compat/include/filemap_fdatawait_range.h b/kapi-compat/include/filemap_fdatawait_range.h new file mode 100644 index 0000000..47840af --- /dev/null +++ b/kapi-compat/include/filemap_fdatawait_range.h @@ -0,0 +1,8 @@ +#ifndef FILEMAP_FDATAWAIT_RANGE_H +#define FILEMAP_FDATAWAIT_RANGE_H + +#define kapi_generic_file_aio_write generic_file_aio_write_nolock +#define kapi_filemap_fdatawrite_range(a, b, c) 0 +#define kapi_filemap_fdatawait_range(a, b, c) 0 + +#endif -- 1.5.6.5
Sunil Mushran
2009-Nov-13 01:47 UTC
[Ocfs2-devel] [PATCH 18/18] ocfs2: Add fops->sendfile()
fops->sendfile() was removed in 2.6.23. Patch re-adds it and uses it if built with EL5. Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com> --- Config.make.in | 1 + configure.in | 5 +++++ fs/ocfs2/Makefile | 4 ++++ fs/ocfs2/file.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 0 deletions(-) diff --git a/Config.make.in b/Config.make.in index 4b5f4c3..02b8c9c 100644 --- a/Config.make.in +++ b/Config.make.in @@ -77,6 +77,7 @@ OLD_BIO_END_IO_T = @OLD_BIO_END_IO_T@ NO_FAULT_IN_VMOPS = @NO_FAULT_IN_VMOPS@ GET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN = @GET_RETURNS_U64_IN_SIMPLE_ATTR_OPEN@ NO_SHOULD_REMOVE_SUID = @NO_SHOULD_REMOVE_SUID@ +HAS_FOPS_SENDFILE = @HAS_FOPS_SENDFILE@ OCFS_DEBUG = @OCFS_DEBUG@ diff --git a/configure.in b/configure.in index a992f4b..5bc9d42 100644 --- a/configure.in +++ b/configure.in @@ -409,6 +409,11 @@ OCFS2_CHECK_KERNEL([filemap_fdatawait_range() in fs.h], fs.h, , fdatawait_header=filemap_fdatawait_range.h, [extern int filemap_fdatawait_range(struct address_space \*,]) KAPI_COMPAT_HEADERS="$KAPI_COMPAT_HEADERS $fdatawait_header" +HAS_FOPS_SENDFILE+OCFS2_CHECK_KERNEL([ fops->sendfile() in fs.h], fs.h, + HAS_FOPS_SENDFILE=yes, , [^.*ssize_t (\*sendfile)]) +AC_SUBST(HAS_FOPS_SENDFILE) + # End kapi_compat checks # using -include has two advantages: diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile index 4a4c250..2e85623 100644 --- a/fs/ocfs2/Makefile +++ b/fs/ocfs2/Makefile @@ -110,6 +110,10 @@ FS_SOURCES += compat_should_remove_suid.c EXTRA_CFLAGS += -DNO_SHOULD_REMOVE_SUID endif +ifdef HAS_FOPS_SENDFILE +EXTRA_CFLAGS += -DHAS_FOPS_SENDFILE +endif + # # Since SUBDIRS means something to kbuild, define them safely. Do not # include trailing slashes. diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 1367586..de75f5a 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2249,6 +2249,45 @@ bail: return ret; } +#ifdef HAS_FOPS_SENDFILE +static ssize_t ocfs2_file_sendfile(struct file *in_file, + loff_t *ppos, + size_t count, + read_actor_t actor, + void *target) +{ + int ret; + struct inode *inode = in_file->f_mapping->host; + + mlog_entry("inode %llu, ppos %lld, count = %u\n", + (unsigned long long)OCFS2_I(inode)->ip_blkno, + (long long) *ppos, + (unsigned int) count); + + /* Obviously, there is no user buffer to worry about here -- + * this simplifies locking, so no need to walk vmas a la + * read/write. We take the cluster lock against the inode + * and call generic_file_sendfile. */ + ret = ocfs2_inode_lock(inode, NULL, 0); + if (ret < 0) { + mlog_errno(ret); + goto bail; + } + + down_read(&OCFS2_I(inode)->ip_alloc_sem); + + ret = generic_file_sendfile(in_file, ppos, count, actor, target); + + up_read(&OCFS2_I(inode)->ip_alloc_sem); + + ocfs2_inode_unlock(inode, 0); + +bail: + mlog_exit(ret); + return ret; +} +#endif + #ifdef IOP_IS_NOT_CONST struct inode_operations ocfs2_file_iops = { #else @@ -2297,6 +2336,9 @@ const struct file_operations ocfs2_fops = { .flock = ocfs2_flock, .splice_read = ocfs2_file_splice_read, .splice_write = ocfs2_file_splice_write, +#ifdef HAS_FOPS_SENDFILE + .sendfile = ocfs2_file_sendfile, +#endif }; const struct file_operations ocfs2_dops = { @@ -2343,6 +2385,9 @@ const struct file_operations ocfs2_fops_no_plocks = { .flock = ocfs2_flock, .splice_read = ocfs2_file_splice_read, .splice_write = ocfs2_file_splice_write, +#ifdef HAS_FOPS_SENDFILE + .sendfile = ocfs2_file_sendfile, +#endif }; const struct file_operations ocfs2_dops_no_plocks = { -- 1.5.6.5