gfs1-utils: master - Revert "gfs-kernel: Make gfs1 work with recent upstream kernels 2.6.28/2.6.29"
Abhijith Das
adas@fedoraproject.org
Thu Jan 22 18:30:00 GMT 2009
Gitweb: http://git.fedorahosted.org/git/gfs1-utils.git?p=gfs1-utils.git;a=commitdiff;h=7e75e4cb903938161c261870a71127f5a1cc7424
Commit: 7e75e4cb903938161c261870a71127f5a1cc7424
Parent: 5618eb654879c2929bba736639c51a5ca90c4720
Author: Abhijith Das <adas@redhat.com>
AuthorDate: Thu Jan 22 12:27:25 2009 -0600
Committer: Abhijith Das <adas@redhat.com>
CommitterDate: Thu Jan 22 12:27:25 2009 -0600
Revert "gfs-kernel: Make gfs1 work with recent upstream kernels 2.6.28/2.6.29"
This reverts commit 5618eb654879c2929bba736639c51a5ca90c4720.
Misses out a more recent upstream change that affects gfs
---
gfs-kernel/src/gfs/acl.c | 3 +-
gfs-kernel/src/gfs/inode.c | 12 ++--
gfs-kernel/src/gfs/ioctl.c | 5 +-
gfs-kernel/src/gfs/ops_address.c | 119 +++++++++++++++-----------------------
gfs-kernel/src/gfs/ops_export.c | 20 +++++--
gfs-kernel/src/gfs/ops_inode.c | 9 +--
gfs-kernel/src/gfs/quota.c | 3 +-
7 files changed, 75 insertions(+), 96 deletions(-)
diff --git a/gfs-kernel/src/gfs/acl.c b/gfs-kernel/src/gfs/acl.c
index a9312ba..a3e30b0 100644
--- a/gfs-kernel/src/gfs/acl.c
+++ b/gfs-kernel/src/gfs/acl.c
@@ -7,7 +7,6 @@
#include <linux/buffer_head.h>
#include <linux/posix_acl.h>
#include <linux/posix_acl_xattr.h>
-#include <linux/cred.h>
#include "gfs.h"
#include "acl.h"
@@ -79,7 +78,7 @@ gfs_acl_validate_remove(struct gfs_inode *ip, int access)
{
if (!ip->i_sbd->sd_args.ar_posix_acls)
return -EOPNOTSUPP;
- if (current_fsuid() != ip->i_di.di_uid && !capable(CAP_FOWNER))
+ if (current->fsuid != ip->i_di.di_uid && !capable(CAP_FOWNER))
return -EPERM;
if (ip->i_di.di_type == GFS_FILE_LNK)
return -EOPNOTSUPP;
diff --git a/gfs-kernel/src/gfs/inode.c b/gfs-kernel/src/gfs/inode.c
index 1e3684a..9de4741 100644
--- a/gfs-kernel/src/gfs/inode.c
+++ b/gfs-kernel/src/gfs/inode.c
@@ -6,7 +6,6 @@
#include <linux/completion.h>
#include <linux/buffer_head.h>
#include <linux/posix_acl.h>
-#include <linux/cred.h>
#include "gfs.h"
#include "acl.h"
@@ -1234,17 +1233,18 @@ inode_init_and_link(struct gfs_inode *dip, struct qstr *name,
dip->i_di.di_uid) {
if (type == GFS_FILE_DIR)
mode |= S_ISUID;
- else if (dip->i_di.di_uid != current_fsuid())
+ else if (dip->i_di.di_uid != current->fsuid)
mode &= ~07111;
uid = dip->i_di.di_uid;
} else
- uid = current_fsuid();
+ uid = current->fsuid;
+
if (dip->i_di.di_mode & S_ISGID) {
if (type == GFS_FILE_DIR)
mode |= S_ISGID;
gid = dip->i_di.di_gid;
} else
- gid = current_fsgid();
+ gid = current->fsgid;
error = gfs_acl_new_prep(dip, type, &mode,
&acl_a_data, &acl_d_data,
@@ -1580,8 +1580,8 @@ gfs_unlink_ok(struct gfs_inode *dip, struct qstr *name, struct gfs_inode *ip)
return -EPERM;
if ((dip->i_di.di_mode & S_ISVTX) &&
- dip->i_di.di_uid != current_fsuid() &&
- ip->i_di.di_uid != current_fsuid() &&
+ dip->i_di.di_uid != current->fsuid &&
+ ip->i_di.di_uid != current->fsuid &&
!capable(CAP_FOWNER))
return -EPERM;
diff --git a/gfs-kernel/src/gfs/ioctl.c b/gfs-kernel/src/gfs/ioctl.c
index 56e844c..d5489b5 100644
--- a/gfs-kernel/src/gfs/ioctl.c
+++ b/gfs-kernel/src/gfs/ioctl.c
@@ -7,7 +7,6 @@
#include <linux/buffer_head.h>
#include <asm/uaccess.h>
#include <linux/compat.h>
-#include <linux/cred.h>
#include "gfs_ioctl.h"
#include "gfs.h"
@@ -922,7 +921,7 @@ gi_set_file_flag(struct gfs_inode *ip, struct gfs_ioctl *gi, int from_user)
return error;
error = -EACCES;
- if (ip->i_di.di_uid != current_fsuid() && !capable(CAP_FOWNER))
+ if (ip->i_di.di_uid != current->fsuid && !capable(CAP_FOWNER))
goto out;
error = -EINVAL;
@@ -1016,7 +1015,7 @@ gi_get_file_meta(struct gfs_inode *ip, struct gfs_ioctl *gi)
return error;
error = -EACCES;
- if (ip->i_di.di_uid != current_fsuid() && !capable(CAP_FOWNER))
+ if (ip->i_di.di_uid != current->fsuid && !capable(CAP_FOWNER))
goto out;
error = gfs_get_file_meta(ip, &ub);
diff --git a/gfs-kernel/src/gfs/ops_address.c b/gfs-kernel/src/gfs/ops_address.c
index 5e55477..0a9c7cd 100644
--- a/gfs-kernel/src/gfs/ops_address.c
+++ b/gfs-kernel/src/gfs/ops_address.c
@@ -19,11 +19,8 @@
#include "quota.h"
#include "trans.h"
-static int
-gfs_write_end(struct file *file, struct address_space *mapping,
- loff_t pos, unsigned len, unsigned copied,
- struct page *page, void *fsdata);
-
+static int gfs_commit_write(struct file *file, struct page *page,
+ unsigned from, unsigned to);
/**
* get_block - Fills in a buffer head with details about a block
* @inode: The inode
@@ -287,14 +284,11 @@ gfs_readpage(struct file *file, struct page *page)
}
/**
- * gfs_write_begin - Begin to write to a file
+ * gfs_prepare_write - Prepare to write a page to a file
* @file: The file to write to
- * @mapping: The mapping in which to write
- * @pos: The file offset at which to start writing
- * @len: Length of the write
- * @flags: Various flags
- * @pagep: Pointer to return the page
- * @fsdata: Pointer to return fs data (unused by GFS)
+ * @page: The page which is to be prepared for writing
+ * @from: From (byte range within page)
+ * @to: To (byte range within page)
*
* Returns: errno
*
@@ -306,38 +300,29 @@ gfs_readpage(struct file *file, struct page *page)
*/
static int
-gfs_write_begin(struct file *file, struct address_space *mapping,
- loff_t pos, unsigned len, unsigned flags,
- struct page **pagep, void **fsdata)
+gfs_prepare_write(struct file *file, struct page *page,
+ unsigned from, unsigned to)
{
- struct gfs_inode *ip = get_v2ip(mapping->host);
+ struct gfs_inode *ip = get_v2ip(page->mapping->host);
struct gfs_sbd *sdp = ip->i_sbd;
int error = 0;
- pgoff_t index = pos >> PAGE_CACHE_SHIFT;
- unsigned from = pos & (PAGE_CACHE_SIZE - 1);
- unsigned to = from + len;
- struct page *page;
atomic_inc(&sdp->sd_ops_address);
- /* We can't set write_end in the structure in the declare */
+ /* We can't set commit_write in the structure in the declare */
/* because if we do, loopback (loop.c) will interpret that to mean */
/* it's okay to do buffered writes without locking through sendfile. */
/* This is a kludge to get around the problem with loop.c because */
/* the upstream community rejected my changes to loop.c. */
- ip->gfs_file_aops.write_end = gfs_write_end;
+ ip->gfs_file_aops.commit_write = gfs_commit_write;
if (gfs_assert_warn(sdp, gfs_glock_is_locked_by_me(ip->i_gl)))
return -ENOSYS;
- error = -ENOMEM;
- page = grab_cache_page_write_begin(mapping, index, flags);
- *pagep = page;
- if (!page)
- goto out;
-
if (gfs_is_stuffed(ip)) {
- if (pos + len > sdp->sd_sb.sb_bsize - sizeof(struct gfs_dinode)) {
+ uint64_t file_size = ((uint64_t)page->index << PAGE_CACHE_SHIFT) + to;
+
+ if (file_size > sdp->sd_sb.sb_bsize - sizeof(struct gfs_dinode)) {
error = gfs_unstuff_dinode(ip, gfs_unstuffer_page, page);
if (!error)
error = block_prepare_write(page, from, to, get_block);
@@ -346,81 +331,71 @@ gfs_write_begin(struct file *file, struct address_space *mapping,
} else
error = block_prepare_write(page, from, to, get_block);
- if (error)
- page_cache_release(page);
-
-out:
return error;
}
/**
- * gfs_write_end
+ * gfs_commit_write - Commit write to a file
* @file: The file to write to
- * @mapping: The address space to write to
- * @pos: The file position
- * @len: The length of the data
- * @copied:
- * @page: The page that has been written
- * @fsdata: The fsdata (unused in GFS)
- *
- * The main write_end function for GFS. We have a separate one for
- * stuffed files as they are slightly different, otherwise we just
- * put our locking around the VFS provided functions
+ * @page: The page containing the data
+ * @from: From (byte range within page)
+ * @to: To (byte range within page)
*
* Returns: errno
*/
static int
-gfs_write_end(struct file *file, struct address_space *mapping,
- loff_t pos, unsigned len, unsigned copied,
- struct page *page, void *fsdata)
+gfs_commit_write(struct file *file, struct page *page,
+ unsigned from, unsigned to)
{
struct inode *inode = page->mapping->host;
struct gfs_inode *ip = get_v2ip(inode);
struct gfs_sbd *sdp = ip->i_sbd;
- int ret;
+ int error;
atomic_inc(&sdp->sd_ops_address);
- BUG_ON(gfs_glock_is_locked_by_me(ip->i_gl) == 0);
if (gfs_is_stuffed(ip)) {
struct buffer_head *dibh;
- u64 to = pos + copied;
+ uint64_t file_size = ((uint64_t)page->index << PAGE_CACHE_SHIFT) + to;
void *kaddr;
- unsigned char *buf;
- ret = gfs_get_inode_buffer(ip, &dibh);
- if (ret)
+ error = gfs_get_inode_buffer(ip, &dibh);
+ if (error)
goto fail;
- buf = dibh->b_data + sizeof(struct gfs_dinode);
- BUG_ON((pos + len) > (dibh->b_size - sizeof(struct gfs_dinode)));
+
+ gfs_trans_add_bh(ip->i_gl, dibh);
kaddr = kmap(page);
- memcpy(buf + pos, kaddr + pos, copied);
- memset(kaddr + pos + copied, 0, len - copied);
- flush_dcache_page(page);
+ memcpy(dibh->b_data + sizeof(struct gfs_dinode) + from,
+ (char *)kaddr + from,
+ to - from);
kunmap(page);
brelse(dibh);
- if (!PageUptodate(page))
- SetPageUptodate(page);
- unlock_page(page);
- page_cache_release(page);
- if (inode->i_size < to)
- i_size_write(inode, to);
+ SetPageUptodate(page);
+
+ if (inode->i_size < file_size)
+ i_size_write(inode, file_size);
} else {
- ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata);
+ loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
+ error = block_commit_write(page, from, to);
+ if (error)
+ goto fail;
+ if (pos > inode->i_size) {
+ i_size_write(inode, pos);
+ mark_inode_dirty(inode);
+ }
}
- ip->gfs_file_aops.write_end = NULL;
- return ret;
+ ip->gfs_file_aops.commit_write = NULL;
+ return 0;
-fail:
+ fail:
ClearPageUptodate(page);
- unlock_page(page);
- page_cache_release(page);
- return ret;
+
+ return error;
}
/**
@@ -498,7 +473,7 @@ struct address_space_operations gfs_file_aops = {
.writepage = gfs_writepage,
.readpage = gfs_readpage,
.sync_page = block_sync_page,
- .write_begin = gfs_write_begin,
+ .prepare_write = gfs_prepare_write,
.bmap = gfs_bmap,
.direct_IO = gfs_direct_IO,
};
diff --git a/gfs-kernel/src/gfs/ops_export.c b/gfs-kernel/src/gfs/ops_export.c
index ca5e648..bf3484c 100644
--- a/gfs-kernel/src/gfs/ops_export.c
+++ b/gfs-kernel/src/gfs/ops_export.c
@@ -208,9 +208,13 @@ gfs_get_parent(struct dentry *child)
if (!inode)
return ERR_PTR(-ENOMEM);
- dentry = d_obtain_alias(inode);
- if (!IS_ERR(dentry))
- dentry->d_op = &gfs_dops;
+ dentry = d_alloc_anon(inode);
+ if (!dentry) {
+ iput(inode);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ dentry->d_op = &gfs_dops;
return dentry;
fail:
@@ -322,9 +326,13 @@ gfs_get_dentry(struct super_block *sb, struct inode_cookie *cookie)
return ERR_PTR(-ESTALE);
}
- dentry = d_obtain_alias(inode);
- if (!IS_ERR(dentry))
- dentry->d_op = &gfs_dops;
+ dentry = d_alloc_anon(inode);
+ if (!dentry) {
+ iput(inode);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ dentry->d_op = &gfs_dops;
return dentry;
fail_relse:
diff --git a/gfs-kernel/src/gfs/ops_inode.c b/gfs-kernel/src/gfs/ops_inode.c
index 400ec13..433fce6 100644
--- a/gfs-kernel/src/gfs/ops_inode.c
+++ b/gfs-kernel/src/gfs/ops_inode.c
@@ -12,7 +12,6 @@
#include <linux/xattr.h>
#include <linux/posix_acl.h>
#include <linux/security.h>
-#include <linux/cred.h>
#include "gfs.h"
#include "acl.h"
@@ -192,11 +191,11 @@ lookup_cdpn_sub_at(struct gfs_sbd *sdp, struct dentry *dentry)
else if (gfs_filecmp(&dentry->d_name, "@uid", 4))
new = lookup_one_len(buf,
parent,
- sprintf(buf, "%u", current_fsuid()));
+ sprintf(buf, "%u", current->fsuid));
else if (gfs_filecmp(&dentry->d_name, "@gid", 4))
new = lookup_one_len(buf,
parent,
- sprintf(buf, "%u", current_fsgid()));
+ sprintf(buf, "%u", current->fsgid));
else if (gfs_filecmp(&dentry->d_name, "@sys", 4))
new = lookup_one_len(buf,
parent,
@@ -251,11 +250,11 @@ lookup_cdpn_sub_brace(struct gfs_sbd *sdp, struct dentry *dentry)
else if (gfs_filecmp(&dentry->d_name, "{uid}", 5))
new = lookup_one_len(buf,
parent,
- sprintf(buf, "%u", current_fsuid()));
+ sprintf(buf, "%u", current->fsuid));
else if (gfs_filecmp(&dentry->d_name, "{gid}", 5))
new = lookup_one_len(buf,
parent,
- sprintf(buf, "%u", current_fsgid()));
+ sprintf(buf, "%u", current->fsgid));
else if (gfs_filecmp(&dentry->d_name, "{sys}", 5))
new = lookup_one_len(buf,
parent,
diff --git a/gfs-kernel/src/gfs/quota.c b/gfs-kernel/src/gfs/quota.c
index df45487..4e2bee6 100644
--- a/gfs-kernel/src/gfs/quota.c
+++ b/gfs-kernel/src/gfs/quota.c
@@ -6,7 +6,6 @@
#include <linux/completion.h>
#include <linux/buffer_head.h>
#include <linux/tty.h>
-#include <linux/cred.h>
#include "gfs.h"
#include "bmap.h"
@@ -1110,7 +1109,7 @@ gfs_quota_read(struct gfs_sbd *sdp, int user, uint32_t id,
struct gfs_holder q_gh;
int error;
- if (((user) ? (id != current_fsuid()) : (!in_group_p(id))) &&
+ if (((user) ? (id != current->fsuid) : (!in_group_p(id))) &&
!capable(CAP_SYS_ADMIN))
return -EACCES;
More information about the Cluster-cvs
mailing list