1. First patch is for forward port of detavolume. I am resending this because few people did not get it the last time around. 2. Workaround to get loop mounts working on enterprise kernels. IIRC this is relevant for SLES too. 3. fops->sendfile() was stripped out of the kernel in 2.6.23. Readding as this tree needs to support older kernels. Jeff, Please could you ensure the configure changes are ok for SLES. Thanks Sunil
Sunil Mushran
2008-Feb-11 10:53 UTC
[Ocfs2-devel] [PATCH 1/3] ocfs2: Add datavolume mount option
This is a forward port of the datavolume mount option in OCFS2 1.2. Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com> --- fs/ocfs2/ocfs2.h | 3 +++ fs/ocfs2/super.c | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index d084805..b9eafc0 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h @@ -172,6 +172,9 @@ enum ocfs2_mount_options OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */ OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */ OCFS2_MOUNT_LOCALFLOCKS = 1 << 5, /* No cluster aware user file locks */ +#ifdef OCFS2_ORACORE_WORKAROUNDS + OCFS2_MOUNT_COMPAT_OCFS = 1 << 30, /* ocfs1 compatibility mode */ +#endif }; #define OCFS2_OSB_SOFT_RO 0x0001 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 6791be8..d5e2644 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -143,6 +143,10 @@ static const struct super_operations ocfs2_sops = { .show_options = ocfs2_show_options, }; +#ifdef OCFS2_ORACORE_WORKAROUNDS +# define OCFS_SUPER_MAGIC 0xa156f7eb +#endif + enum { Opt_barrier, Opt_err_panic, @@ -158,6 +162,9 @@ enum { Opt_commit, Opt_localalloc, Opt_localflocks, +#ifdef OCFS2_ORACORE_WORKAROUNDS + Opt_datavolume, +#endif Opt_err, }; @@ -176,6 +183,9 @@ static match_table_t tokens = { {Opt_commit, "commit=%u"}, {Opt_localalloc, "localalloc=%d"}, {Opt_localflocks, "localflocks"}, +#ifdef OCFS2_ORACORE_WORKAROUNDS + {Opt_datavolume, "datavolume"}, +#endif {Opt_err, NULL} }; @@ -613,7 +623,12 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) osb->osb_commit_interval = parsed_options.commit_interval; osb->local_alloc_size = parsed_options.localalloc_opt; - sb->s_magic = OCFS2_SUPER_MAGIC; +#ifdef OCFS2_ORACORE_WORKAROUNDS + if (osb->s_mount_opt & OCFS2_MOUNT_COMPAT_OCFS) + sb->s_magic = OCFS_SUPER_MAGIC; + else +#endif + sb->s_magic = OCFS2_SUPER_MAGIC; /* Hard readonly mode only if: bdev_read_only, MS_RDONLY, * heartbeat=none */ @@ -826,6 +841,17 @@ static int ocfs2_parse_options(struct super_block *sb, case Opt_data_writeback: mopt->mount_opt |= OCFS2_MOUNT_DATA_WRITEBACK; break; +#ifdef OCFS2_ORACORE_WORKAROUNDS + case Opt_datavolume: + if (is_remount) { + mlog(ML_ERROR, "Cannot specify datavolume " + "on remount.\n"); + status = 0; + goto bail; + } + mopt->mount_opt |= OCFS2_MOUNT_COMPAT_OCFS; + break; +#endif case Opt_atime_quantum: if (match_int(&args[0], &option)) { status = 0; @@ -920,6 +946,11 @@ static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt) else seq_printf(s, ",errors=remount-ro"); +#ifdef OCFS2_ORACORE_WORKAROUNDS + if (opts & OCFS2_MOUNT_COMPAT_OCFS) + seq_printf(s, ",datavolume"); +#endif + if (osb->preferred_slot != OCFS2_INVALID_SLOT) seq_printf(s, ",preferred_slot=%d", osb->preferred_slot); @@ -1048,7 +1079,12 @@ static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf) numbits = le32_to_cpu(bm_lock->id1.bitmap1.i_total); freebits = numbits - le32_to_cpu(bm_lock->id1.bitmap1.i_used); - buf->f_type = OCFS2_SUPER_MAGIC; +#ifdef OCFS2_ORACORE_WORKAROUNDS + if (osb->s_mount_opt & OCFS2_MOUNT_COMPAT_OCFS) + buf->f_type = OCFS_SUPER_MAGIC; + else +#endif + buf->f_type = OCFS2_SUPER_MAGIC; buf->f_bsize = dentry->d_sb->s_blocksize; buf->f_namelen = OCFS2_MAX_FILENAME_LEN; buf->f_blocks = ((sector_t) numbits) * -- 1.5.3.4
Sunil Mushran
2008-Feb-11 10:53 UTC
[Ocfs2-devel] [PATCH 2/3] ocfs2: Detect and use MS_LOOP_NO_AOPS
Some vendor kernels provide a superblock flag, MS_LOOP_NO_AOPS which will enable writable loopback support for ocfs2 1.4. Detect that flag and use it if possible. This patch was forward-ported from 1.2. Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com> --- Config.make.in | 1 + configure.in | 5 +++++ fs/ocfs2/Makefile | 4 ++++ fs/ocfs2/super.c | 4 ++++ 4 files changed, 14 insertions(+), 0 deletions(-) diff --git a/Config.make.in b/Config.make.in index 0d6b2df..a9740e8 100644 --- a/Config.make.in +++ b/Config.make.in @@ -93,6 +93,7 @@ INVALIDATEPAGE_RETURNS_INT = @INVALIDATEPAGE_RETURNS_INT@ DIO_OLD_GET_BLOCKS = @DIO_OLD_GET_BLOCKS@ NO_LINUX_UACCESS_H = @NO_LINUX_UACCESS_H@ NO_SYSTEM_UTSNAME = @NO_SYSTEM_UTSNAME@ +HAS_MS_LOOP_NO_AOPS = @HAS_MS_LOOP_NO_AOPS@ OCFS_DEBUG = @OCFS_DEBUG@ diff --git a/configure.in b/configure.in index 29ab597..a1c5d19 100644 --- a/configure.in +++ b/configure.in @@ -410,6 +410,11 @@ OCFS2_CHECK_KERNEL([system_utsname in utsname.h], utsname.h, , NO_SYSTEM_UTSNAME=yes, [^extern struct new_utsname system_utsname]) AC_SUBST(NO_SYSTEM_UTSNAME) +HAS_MS_LOOP_NO_AOPS+OCFS2_CHECK_KERNEL([MS_LOOP_NO_AOPS flag defined], fs.h, + HAS_MS_LOOP_NO_AOPS==yes, , [MS_LOOP_NO_AOPS]) +AC_SUBST(HAS_MS_LOOP_NO_AOPS) + # using -include has two advantages: # the source doesn't need to know to include compat headers # the compat header file names don't go through the search path diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile index c80e2a0..05a94c7 100644 --- a/fs/ocfs2/Makefile +++ b/fs/ocfs2/Makefile @@ -160,6 +160,10 @@ ifdef NO_LINUX_UACCESS_H EXTRA_CFLAGS += -DNO_LINUX_UACCESS_H endif +ifdef HAS_MS_LOOP_NO_AOPS +EXTRA_CFLAGS += -DHAS_MS_LOOP_NO_AOPS +endif + # # Since SUBDIRS means something to kbuild, define them safely. Do not # include trailing slashes. diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index d5e2644..9ce5cc8 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -724,6 +724,10 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) atomic_set(&osb->vol_state, VOLUME_MOUNTED); wake_up(&osb->osb_mount_event); +#ifdef HAS_MS_LOOP_NO_AOPS + /* OCFS2's prepare and commit write operations don't do any locking. */ + sb->s_flags |= MS_LOOP_NO_AOPS; +#endif mlog_exit(status); return status; -- 1.5.3.4
fops->sendfile() was removed in 2.6.23. Re-adding as this version of the fs is meant to also work with older kernels. Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com> --- Config.make.in | 1 + configure.in | 5 +++++ fs/ocfs2/Makefile | 4 ++++ fs/ocfs2/file.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 0 deletions(-) diff --git a/Config.make.in b/Config.make.in index a9740e8..b7d553d 100644 --- a/Config.make.in +++ b/Config.make.in @@ -94,6 +94,7 @@ DIO_OLD_GET_BLOCKS = @DIO_OLD_GET_BLOCKS@ NO_LINUX_UACCESS_H = @NO_LINUX_UACCESS_H@ NO_SYSTEM_UTSNAME = @NO_SYSTEM_UTSNAME@ HAS_MS_LOOP_NO_AOPS = @HAS_MS_LOOP_NO_AOPS@ +HAS_FOPS_SENDFILE = @HAS_FOPS_SENDFILE@ OCFS_DEBUG = @OCFS_DEBUG@ diff --git a/configure.in b/configure.in index a1c5d19..f3544b0 100644 --- a/configure.in +++ b/configure.in @@ -415,6 +415,11 @@ OCFS2_CHECK_KERNEL([MS_LOOP_NO_AOPS flag defined], fs.h, HAS_MS_LOOP_NO_AOPS==yes, , [MS_LOOP_NO_AOPS]) AC_SUBST(HAS_MS_LOOP_NO_AOPS) +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) + # using -include has two advantages: # the source doesn't need to know to include compat headers # the compat header file names don't go through the search path diff --git a/fs/ocfs2/Makefile b/fs/ocfs2/Makefile index 05a94c7..0b90da3 100644 --- a/fs/ocfs2/Makefile +++ b/fs/ocfs2/Makefile @@ -164,6 +164,10 @@ ifdef HAS_MS_LOOP_NO_AOPS EXTRA_CFLAGS += -DHAS_MS_LOOP_NO_AOPS 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 e068a76..11856c2 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2465,6 +2465,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 @@ -2511,6 +2550,9 @@ const struct file_operations ocfs2_fops = { .splice_read = ocfs2_file_splice_read, .splice_write = ocfs2_file_splice_write, #endif +#ifdef HAS_FOPS_SENDFILE + .sendfile = ocfs2_file_sendfile, +#endif }; #ifdef FOP_IS_NOT_CONST -- 1.5.3.4
On Mon, Feb 11, 2008 at 10:52:49AM -0800, Sunil Mushran wrote:> fops->sendfile() was removed in 2.6.23. Re-adding as this version > of the fs is meant to also work with older kernels. > > Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com>Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com> -- Mark Fasheh Principal Software Developer, Oracle mark.fasheh@oracle.com