[Ocfs2-commits] mfasheh commits r2508 - trunk/fs/ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Aug 11 20:44:34 CDT 2005
Author: mfasheh
Signed-off-by: manish
Date: 2005-08-11 20:44:33 -0500 (Thu, 11 Aug 2005)
New Revision: 2508
Modified:
trunk/fs/ocfs2/Makefile
trunk/fs/ocfs2/aio.c
trunk/fs/ocfs2/file.c
trunk/fs/ocfs2/file.h
trunk/fs/ocfs2/symlink.c
Log:
* move our o_direct extend code under the ORACORE_WORKAROUNDS define so that it can easily be filtered out.
* make cdsl support optional
Signed-off-by: manish
Modified: trunk/fs/ocfs2/Makefile
===================================================================
--- trunk/fs/ocfs2/Makefile 2005-08-12 01:40:47 UTC (rev 2507)
+++ trunk/fs/ocfs2/Makefile 2005-08-12 01:44:33 UTC (rev 2508)
@@ -27,6 +27,7 @@
endif
EXTRA_CFLAGS += -DOCFS2_DELETE_INODE_WORKAROUND
+#EXTRA_CFLAGS += -DOCFS2_CDSL
#
# Since SUBDIRS means something to kbuild, define them safely. Do not
Modified: trunk/fs/ocfs2/aio.c
===================================================================
--- trunk/fs/ocfs2/aio.c 2005-08-12 01:40:47 UTC (rev 2507)
+++ trunk/fs/ocfs2/aio.c 2005-08-12 01:44:33 UTC (rev 2508)
@@ -346,7 +346,7 @@
*/
ocfs2_file_finish_extension(inode,
!okp->kp_info.wl_newsize,
- !okp->kp_info.wl_do_direct_io);
+ okp->kp_info.wl_do_direct_io);
okp->kp_info.wl_extended = 0;
}
if (ret) {
Modified: trunk/fs/ocfs2/file.c
===================================================================
--- trunk/fs/ocfs2/file.c 2005-08-12 01:40:47 UTC (rev 2507)
+++ trunk/fs/ocfs2/file.c 2005-08-12 01:44:33 UTC (rev 2508)
@@ -156,29 +156,34 @@
void ocfs2_file_finish_extension(struct inode *inode,
loff_t newsize,
- unsigned should_zero)
+ unsigned direct_extend)
{
- mlog(0, "inode %"MLFu64", newsize = %lld, should_zero = %u\n",
- OCFS2_I(inode)->ip_blkno, (long long)newsize, should_zero);
+ int status;
+ mlog(0, "inode %"MLFu64", newsize = %lld, direct_extend = %u\n",
+ OCFS2_I(inode)->ip_blkno, (long long)newsize, direct_extend);
+
ocfs2_update_inode_size(inode, newsize);
- if (!should_zero) {
+#ifdef OCFS2_ORACORE_WORKAROUNDS
+ if (direct_extend) {
/*
* This leaves dirty data in holes.
* Caveat Emptor.
*/
OCFS2_I(inode)->ip_mmu_private = newsize;
- } else {
- int status = ocfs2_zero_extend(inode);
- /*
- * Don't overwrite the result of
- * generic_file_write
- */
- if (status)
- mlog(ML_ERROR, "Unable to pre-zero extension of inode "
- "(%d)\n", status);
+ return;
}
+#endif
+
+ status = ocfs2_zero_extend(inode);
+ /*
+ * Don't overwrite the result of
+ * generic_file_write
+ */
+ if (status)
+ mlog(ML_ERROR, "Unable to pre-zero extension of inode "
+ "(%d)\n", status);
}
static ssize_t ocfs2_file_write(struct file *filp,
@@ -244,7 +249,7 @@
* an error was returned by, say, data locking */
if (info.wl_extended)
ocfs2_file_finish_extension(inode, info.wl_newsize,
- !info.wl_do_direct_io);
+ info.wl_do_direct_io);
if (info.wl_unlock_ctxt)
ocfs2_unlock_buffer_inodes(&ctxt);
if (info.wl_have_i_sem)
@@ -1042,12 +1047,14 @@
if (bytes_added)
ocfs2_update_inode_size(inode, newsize);
+#ifdef OCFS2_ORACORE_WORKAROUNDS
spin_lock(&OCFS2_I(inode)->ip_lock);
if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_OPEN_DIRECT) {
/* This is a total broken hack for O_DIRECT crack */
OCFS2_I(inode)->ip_mmu_private = i_size_read(inode);
}
spin_unlock(&OCFS2_I(inode)->ip_lock);
+#endif
status = ocfs2_zero_extend(inode);
if (status < 0) {
mlog_errno(status);
Modified: trunk/fs/ocfs2/file.h
===================================================================
--- trunk/fs/ocfs2/file.h 2005-08-12 01:40:47 UTC (rev 2507)
+++ trunk/fs/ocfs2/file.h 2005-08-12 01:44:33 UTC (rev 2508)
@@ -59,6 +59,6 @@
u64 new_i_size);
void ocfs2_file_finish_extension(struct inode *inode, loff_t newsize,
- unsigned should_zero);
+ unsigned direct_extend);
#endif /* OCFS2_FILE_H */
Modified: trunk/fs/ocfs2/symlink.c
===================================================================
--- trunk/fs/ocfs2/symlink.c 2005-08-12 01:40:47 UTC (rev 2507)
+++ trunk/fs/ocfs2/symlink.c 2005-08-12 01:44:33 UTC (rev 2508)
@@ -53,27 +53,96 @@
#include "buffer_head_io.h"
+static char *ocfs2_page_getlink(struct dentry * dentry,
+ struct page **ppage);
+static char *ocfs2_fast_symlink_getlink(struct inode *inode,
+ struct buffer_head **bh);
+
+/* get the link contents into pagecache */
+static char *ocfs2_page_getlink(struct dentry * dentry,
+ struct page **ppage)
+{
+ struct page * page;
+ struct address_space *mapping = dentry->d_inode->i_mapping;
+ page = read_cache_page(mapping, 0,
+ (filler_t *)mapping->a_ops->readpage, NULL);
+ if (IS_ERR(page))
+ goto sync_fail;
+ wait_on_page_locked(page);
+ if (!PageUptodate(page))
+ goto async_fail;
+ *ppage = page;
+ return kmap(page);
+
+async_fail:
+ page_cache_release(page);
+ return ERR_PTR(-EIO);
+
+sync_fail:
+ return (char*)page;
+}
+
+static char *ocfs2_fast_symlink_getlink(struct inode *inode,
+ struct buffer_head **bh)
+{
+ int status;
+ char *link = NULL;
+ ocfs2_dinode *fe;
+
+ mlog_entry_void();
+
+ status = ocfs2_read_block(OCFS2_SB(inode->i_sb),
+ OCFS2_I(inode)->ip_blkno,
+ bh,
+ OCFS2_BH_CACHED,
+ inode);
+ if (status < 0) {
+ mlog_errno(status);
+ link = ERR_PTR(status);
+ goto bail;
+ }
+
+ fe = (ocfs2_dinode *) (*bh)->b_data;
+ link = (char *) fe->id2.i_symlink;
+bail:
+ mlog_exit(status);
+
+ return link;
+}
+
+static int ocfs2_readlink(struct dentry *dentry,
+ char __user *buffer,
+ int buflen)
+{
+ int ret;
+ char *link;
+ struct buffer_head *bh = NULL;
+ struct inode *inode = dentry->d_inode;
+
+ mlog_entry_void();
+
+ link = ocfs2_fast_symlink_getlink(inode, &bh);
+ if (IS_ERR(link)) {
+ ret = PTR_ERR(link);
+ goto out;
+ }
+
+ ret = vfs_readlink(dentry, buffer, buflen, link);
+
+ brelse(bh);
+out:
+ mlog_exit(ret);
+ return ret;
+}
+
+#ifdef OCFS2_CDSL
+
struct ocfs2_symlink_ops {
const char *name;
const unsigned int len;
unsigned int (*subst_fn) (char *str, void *data);
};
-static unsigned int ocfs2_link_size(struct ocfs2_symlink_ops *ops,
- char *str,
- struct inode *inode);
-static void ocfs2_link_expand(struct ocfs2_symlink_ops *ops,
- char *out,
- char *in,
- struct inode *inode);
-static char *ocfs2_fast_symlink_getlink(struct inode *inode,
- struct buffer_head **bh);
-static int ocfs2_readlink(struct dentry *dentry,
- char __user *buffer,
- int buflen);
-
-/* Context Dependent Symbolic Link (CDSL) code */
-
/**
*** sym_hostname - Substitute system host name
*** @str: String for result
@@ -216,103 +285,7 @@
{NULL, 0, NULL}
};
-/* CDSL code - end
- **/
-static char *ocfs2_page_getlink(struct dentry * dentry,
- struct page **ppage);
-
-/* get the link contents into pagecache */
-static char *ocfs2_page_getlink(struct dentry * dentry,
- struct page **ppage)
-{
- struct page * page;
- struct address_space *mapping = dentry->d_inode->i_mapping;
- page = read_cache_page(mapping, 0,
- (filler_t *)mapping->a_ops->readpage, NULL);
- if (IS_ERR(page))
- goto sync_fail;
- wait_on_page_locked(page);
- if (!PageUptodate(page))
- goto async_fail;
- *ppage = page;
- return kmap(page);
-
-async_fail:
- page_cache_release(page);
- return ERR_PTR(-EIO);
-
-sync_fail:
- return (char*)page;
-}
-
-static char *ocfs2_fast_symlink_getlink(struct inode *inode,
- struct buffer_head **bh)
-{
- int status;
- char *link = NULL;
- ocfs2_dinode *fe;
-
- mlog_entry_void();
-
- status = ocfs2_read_block(OCFS2_SB(inode->i_sb),
- OCFS2_I(inode)->ip_blkno,
- bh,
- OCFS2_BH_CACHED,
- inode);
- if (status < 0) {
- mlog_errno(status);
- link = ERR_PTR(status);
- goto bail;
- }
-
- fe = (ocfs2_dinode *) (*bh)->b_data;
- link = (char *) fe->id2.i_symlink;
-bail:
- mlog_exit(status);
-
- return link;
-}
-
-static int ocfs2_follow_link(struct dentry *dentry, struct nameidata *nd)
-{
- struct inode *inode = dentry->d_inode;
- struct page *page = NULL;
- struct buffer_head *bh = NULL;
- char *orig_link, *new_link;
- unsigned int len, res = 0;
-
- if (ocfs2_inode_is_fast_symlink(inode))
- orig_link = ocfs2_fast_symlink_getlink(inode, &bh);
- else
- orig_link = ocfs2_page_getlink(dentry, &page);
-
- if (IS_ERR(orig_link)) {
- res = PTR_ERR(orig_link);
- goto out;
- }
-
- len = ocfs2_link_size(symlink_ops, orig_link, inode);
- new_link = kmalloc(len, GFP_KERNEL);
- if (new_link == NULL) {
- res = ENOMEM;
- goto out;
- }
- ocfs2_link_expand(symlink_ops, new_link, orig_link, inode);
- res = vfs_follow_link(nd, new_link);
- out:
- if (page) {
- kunmap(page);
- page_cache_release(page);
- }
- if (bh)
- brelse(bh);
-
- return res;
-}
-
-
-
/**
*** ocfs2_link_expand - Expand a context sensitive symlink
*** @ops: The symlink substitution operations table
@@ -376,29 +349,69 @@
return len + 1;
}
-static int ocfs2_readlink(struct dentry *dentry,
- char __user *buffer,
- int buflen)
+static inline int ocfs2_cdsl_follow_link(struct nameidata *nd,
+ char *old_link,
+ struct inode *inode)
{
- int ret;
+ 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);
+ if (status < 0)
+ mlog_errno(status);
+
+ kfree(new_link);
+bail:
+ return status;
+}
+#endif
+
+static int ocfs2_follow_link(struct dentry *dentry,
+ struct nameidata *nd)
+{
+ int status;
char *link;
+ struct inode *inode = dentry->d_inode;
+ struct page *page = NULL;
struct buffer_head *bh = NULL;
- struct inode *inode = dentry->d_inode;
-
- mlog_entry_void();
-
- link = ocfs2_fast_symlink_getlink(inode, &bh);
+
+ if (ocfs2_inode_is_fast_symlink(inode))
+ link = ocfs2_fast_symlink_getlink(inode, &bh);
+ else
+ link = ocfs2_page_getlink(dentry, &page);
if (IS_ERR(link)) {
- ret = PTR_ERR(link);
- goto out;
+ status = PTR_ERR(link);
+ mlog_errno(status);
+ goto bail;
}
- ret = vfs_readlink(dentry, buffer, buflen, link);
+#ifdef OCFS2_CDSL
+ status = ocfs2_cdsl_follow_link(nd, link, inode);
+#else
+ status = vfs_follow_link(nd, link);
+#endif
+ if (status)
+ mlog_errno(status);
+bail:
+ if (page) {
+ kunmap(page);
+ page_cache_release(page);
+ }
+ if (bh)
+ brelse(bh);
- brelse(bh);
-out:
- mlog_exit(ret);
- return ret;
+ return status;
}
struct inode_operations ocfs2_symlink_inode_operations = {
More information about the Ocfs2-commits
mailing list