Sunil Mushran
2008-Feb-08 10:49 UTC
[Ocfs2-devel] [PATCH 4/4] ocfs2: Enable localalloc for local mounts
Mainline commit 2fbe8d1ebe004425b4f7b8bba345623d2280be82 disabled localalloc for local mounts. This caused issues as ocfs2 uses localalloc to provide write locality. This patch enables localalloc for local mounts. Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com> --- fs/ocfs2/localalloc.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index ff7f343..d036fe8 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c @@ -120,9 +120,6 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb) mlog_entry_void(); - if (ocfs2_mount_local(osb)) - goto bail; - if (osb->local_alloc_size == 0) goto bail; -- 1.5.2.5
Commit 959aeecc8cdaf7ce6046227062086624d4eb7031 in this tree missed including kapi-include/include/mandatory_lock.h to Makefile. Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com> --- Makefile | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/Makefile b/Makefile index 4a290cf..8e17890 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,8 @@ KAPI_COMPAT_FILES = \ kapi-compat/include/writeback_control.h \ kapi-compat/include/blkcnt_t.h \ kapi-compat/include/read_mapping_page.h \ - kapi-compat/include/aiovec.h + kapi-compat/include/aiovec.h \ + kapi-compat/include/mandatory_lock.h PATCH_FILES -- 1.5.2.5
This is a forward port of the CDSL implementation in OCFS2 1.2. Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com> --- fs/ocfs2/symlink.c | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 244 insertions(+), 0 deletions(-) diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c index 9794649..0cc45d0 100644 --- a/fs/ocfs2/symlink.c +++ b/fs/ocfs2/symlink.c @@ -131,6 +131,246 @@ out: return ret; } +#ifdef OCFS2_CDSL + +struct ocfs2_symlink_ops { + const char *name; + const unsigned int len; + unsigned int (*subst_fn) (char *str, void *data); +}; + +/** + *** sym_hostname - Substitute system host name + *** @str: String for result + *** @len: Length of result buffer + *** + *** Returns: Length of hostname + ***/ +static unsigned int +sym_hostname(char *str, void *data) +{ + unsigned int l = strlen(system_utsname.nodename); + + if (str) + memcpy(str, system_utsname.nodename, l); + + return l; +} + +/** + *** sym_machine - Substitute machine type + *** @str: String for result + *** @len: Length of result buffer + *** + *** Returns: Length of machine type + ***/ + +static unsigned int +sym_machine(char *str, void *data) +{ + unsigned int l = strlen(system_utsname.machine); + + if (str) + memcpy(str, system_utsname.machine, l); + + return l; +} + +/** + *** sym_os - Substitute OS name + *** @str: String for result + *** @len: Length of result buffer + *** + *** Returns: Length of OS name + ***/ + +static unsigned int +sym_os(char *str, void *data) +{ + unsigned int l = strlen(system_utsname.sysname); + + if (str) + memcpy(str, system_utsname.sysname, l); + + return l; +} + +/** + *** sym_nodenum - Substitute node number + *** @str: String for result + *** @len: Length of result buffer + *** + *** Returns: Length of nodeNum + ***/ + +static unsigned int +sym_nodenum(char *str, void *data) +{ + unsigned int l; + char buf[10]; + struct inode *inode = data; + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); + + l = sprintf(buf, "%lu", (unsigned long)osb->node_num); + + if (str) { + memcpy(str, buf, l); + str[l] = '\0'; + } + + return l; +} + +static unsigned int +sym_system(char *str, void *data) +{ + unsigned int ml = strlen(system_utsname.machine); + unsigned int sl = strlen(system_utsname.sysname); + unsigned int l = ml + sl + 1; + + if (str) { + memcpy(str, system_utsname.machine, ml); + str[ml] = '_'; + memcpy(str + ml + 1, system_utsname.sysname, sl); + str[l] = '\0'; + }; + + return l; +} + +static unsigned int +sym_uid(char *str, void *data) +{ + unsigned int l; + char buf[10]; + + l = sprintf(buf, "%lu", (unsigned long)current->fsuid); + + if (str) { + memcpy(str, buf, l); + str[l] = '\0'; + } + + return l; +} + +static unsigned int +sym_gid(char *str, void *data) +{ + unsigned int l; + char buf[10]; + + l = sprintf(buf, "%lu", (unsigned long)current->fsgid); + + if (str) { + memcpy(str, buf, l); + str[l] = '\0'; + } + + return l; +} + +static struct ocfs2_symlink_ops symlink_ops[] = { + {"hostname}", 9, sym_hostname}, + {"mach}", 5, sym_machine}, + {"os}", 3, sym_os}, + {"nodenum}", 8, sym_nodenum}, + {"sys}", 4, sym_system}, + {"uid}", 4, sym_uid}, + {"gid}", 4, sym_gid}, + {NULL, 0, NULL} +}; + + +/** + *** ocfs2_link_expand - Expand a context sensitive symlink + *** @ops: The symlink substitution operations table + *** @out: Buffer to place result in + *** @in: Buffer to get symlink from + *** + *** Returns: 0 or error code + ***/ + +static void ocfs2_link_expand(struct ocfs2_symlink_ops *ops, char *out, char *in, struct inode *inode) +{ + unsigned int i; + + while (*in) { + *out++ = *in; + if (*in++ != '{') + continue; + + for (i = 0; ops[i].name; i++) { + if (memcmp(in, ops[i].name, ops[i].len) == 0) { + out--; + out += ops[i].subst_fn(out, inode); + in += ops[i].len; + } + } + } + + *out = 0; +} + + +/** + *** ocfs2_link_size - Return expanded size required to store a symlink + *** @str: The symlink + *** @ops: The symlink substitution operations table + *** + *** Returns: The size of the expanded symlink. + ***/ + + +static unsigned int ocfs2_link_size(struct ocfs2_symlink_ops *ops, char *str, struct inode *inode) +{ + unsigned int len = 0; + unsigned int i; + + while (*str) { + len++; + if (*str++ != '{') + continue; + + for (i = 0; ops[i].name; i++) { + if (memcmp(str, ops[i].name, ops[i].len) == 0) { + len--; + len += ops[i].subst_fn(NULL, inode); + str += ops[i].len; + break; + } + } + } + + return len + 1; +} + +static inline int ocfs2_cdsl_follow_link(struct nameidata *nd, + char *old_link, + struct inode *inode) +{ + int status; + char *new_link; + unsigned int len; + + len = ocfs2_link_size(symlink_ops, old_link, inode); + new_link = kmalloc(len, GFP_KERNEL); + if (new_link == NULL) { + status = -ENOMEM; + mlog_errno(status); + goto bail; + } + + ocfs2_link_expand(symlink_ops, new_link, old_link, inode); + + status = vfs_follow_link(nd, new_link); + + kfree(new_link); +bail: + return status; +} +#endif + static void *ocfs2_follow_link(struct dentry *dentry, struct nameidata *nd) { @@ -150,7 +390,11 @@ static void *ocfs2_follow_link(struct dentry *dentry, goto bail; } +#ifdef OCFS2_CDSL + status = ocfs2_cdsl_follow_link(nd, link, inode); +#else status = vfs_follow_link(nd, link); +#endif bail: if (page) { -- 1.5.2.5
Few patches for review. Two forward port features, datavolume mount option and cdsl, from 1.2. One fixes a build issue and the last renables localalloc for local mounts. Sunil
Sunil Mushran
2008-Feb-08 10:50 UTC
[Ocfs2-devel] [PATCH 2/4] 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.2.5
On Fri, Feb 08, 2008 at 10:49:33AM -0800, Sunil Mushran wrote:> Two forward port features, datavolume mount option and cdsl, from 1.2. > One fixes a build issue and the last renables localalloc for local > mounts.Localalloc and rpm build fixes look good to me. I didn't get the datavolume patch yet in my inbox. As far as CDSL is concerned, why don't we leave it out for now and see how things go? --Mark -- Mark Fasheh Principal Software Developer, Oracle mark.fasheh@oracle.com