This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gfs1-utils: master - gfs-kernel: Changes to gfs to work with 2.6.28


Gitweb:        http://git.fedorahosted.org/git/gfs1-utils.git?p=gfs1-utils.git;a=commitdiff;h=4de805c40d59e4555cf1973d2a8ee7e300ec4d76
Commit:        4de805c40d59e4555cf1973d2a8ee7e300ec4d76
Parent:        7e75e4cb903938161c261870a71127f5a1cc7424
Author:        Abhijith Das <adas@redhat.com>
AuthorDate:    Thu Jan 22 13:58:44 2009 -0600
Committer:     Abhijith Das <adas@redhat.com>
CommitterDate: Thu Jan 22 14:05:17 2009 -0600

gfs-kernel: Changes to gfs to work with 2.6.28

This patch brings gfs from 2.6.27 to 2.6.28

Signed-off-by: Abhijith Das <adas@redhat.com>
---
 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, 96 insertions(+), 75 deletions(-)

diff --git a/gfs-kernel/src/gfs/acl.c b/gfs-kernel/src/gfs/acl.c
index a3e30b0..a9312ba 100644
--- a/gfs-kernel/src/gfs/acl.c
+++ b/gfs-kernel/src/gfs/acl.c
@@ -7,6 +7,7 @@
 #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"
@@ -78,7 +79,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 9de4741..1e3684a 100644
--- a/gfs-kernel/src/gfs/inode.c
+++ b/gfs-kernel/src/gfs/inode.c
@@ -6,6 +6,7 @@
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
 #include <linux/posix_acl.h>
+#include <linux/cred.h>
 
 #include "gfs.h"
 #include "acl.h"
@@ -1233,18 +1234,17 @@ 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 d5489b5..56e844c 100644
--- a/gfs-kernel/src/gfs/ioctl.c
+++ b/gfs-kernel/src/gfs/ioctl.c
@@ -7,6 +7,7 @@
 #include <linux/buffer_head.h>
 #include <asm/uaccess.h>
 #include <linux/compat.h>
+#include <linux/cred.h>
 
 #include "gfs_ioctl.h"
 #include "gfs.h"
@@ -921,7 +922,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;
@@ -1015,7 +1016,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 0a9c7cd..55071a2 100644
--- a/gfs-kernel/src/gfs/ops_address.c
+++ b/gfs-kernel/src/gfs/ops_address.c
@@ -19,8 +19,11 @@
 #include "quota.h"
 #include "trans.h"
 
-static int gfs_commit_write(struct file *file, struct page *page,
-							unsigned from, unsigned to);
+static int
+gfs_write_end(struct file *file, struct address_space *mapping,
+	      loff_t pos, unsigned len, unsigned copied,
+	      struct page *page, void *fsdata);
+
 /**
  * get_block - Fills in a buffer head with details about a block
  * @inode: The inode
@@ -284,11 +287,14 @@ gfs_readpage(struct file *file, struct page *page)
 }
 
 /**
- * gfs_prepare_write - Prepare to write a page to a file
+ * gfs_write_begin - Begin to write to a file
  * @file: The file to write to
- * @page: The page which is to be prepared for writing
- * @from: From (byte range within page)
- * @to: To (byte range within page)
+ * @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)
  *
  * Returns: errno
  *
@@ -300,29 +306,38 @@ gfs_readpage(struct file *file, struct page *page)
  */
 
 static int
-gfs_prepare_write(struct file *file, struct page *page,
-		  unsigned from, unsigned to)
+gfs_write_begin(struct file *file, struct address_space *mapping,
+		loff_t pos, unsigned len, unsigned flags,
+		struct page **pagep, void **fsdata)
 {
-	struct gfs_inode *ip = get_v2ip(page->mapping->host);
+	struct gfs_inode *ip = get_v2ip(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 commit_write in the structure in the declare         */
+	/* We can't set write_end 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.commit_write = gfs_commit_write;
+	ip->gfs_file_aops.write_end = gfs_write_end;
 
 	if (gfs_assert_warn(sdp, gfs_glock_is_locked_by_me(ip->i_gl)))
 		return -ENOSYS;
 
-	if (gfs_is_stuffed(ip)) {
-		uint64_t file_size = ((uint64_t)page->index << PAGE_CACHE_SHIFT) + to;
+	error = -ENOMEM;
+	page = __grab_cache_page(mapping, index);
+	*pagep = page;
+	if (!page)
+		goto out;
 
-		if (file_size > sdp->sd_sb.sb_bsize - sizeof(struct gfs_dinode)) {
+	if (gfs_is_stuffed(ip)) {
+		if (pos + len > 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);
@@ -331,71 +346,81 @@ gfs_prepare_write(struct file *file, struct page *page,
 	} else
 		error = block_prepare_write(page, from, to, get_block);
 
+	if (error)
+		page_cache_release(page);
+
+out:
 	return error;
 }
 
 /**
- * gfs_commit_write - Commit write to a file
+ * gfs_write_end
  * @file: The file to write to
- * @page: The page containing the data
- * @from: From (byte range within page)
- * @to: To (byte range within page)
+ * @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
  *
  * Returns: errno
  */
 
 static int
-gfs_commit_write(struct file *file, struct page *page,
-		 unsigned from, unsigned to)
+gfs_write_end(struct file *file, struct address_space *mapping,
+	      loff_t pos, unsigned len, unsigned copied,
+	      struct page *page, void *fsdata)
 {
 	struct inode *inode = page->mapping->host;
 	struct gfs_inode *ip = get_v2ip(inode);
 	struct gfs_sbd *sdp = ip->i_sbd;
-	int error;
+	int ret;
 
 	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;
-		uint64_t file_size = ((uint64_t)page->index << PAGE_CACHE_SHIFT) + to;
+		u64 to = pos + copied;
 		void *kaddr;
+		unsigned char *buf;
 
-		error = gfs_get_inode_buffer(ip, &dibh);
-		if (error)
+		ret = gfs_get_inode_buffer(ip, &dibh);
+		if (ret)
 			goto fail;
-
-		gfs_trans_add_bh(ip->i_gl, dibh);
+		buf = dibh->b_data + sizeof(struct gfs_dinode);
+		BUG_ON((pos + len) > (dibh->b_size - sizeof(struct gfs_dinode)));
 
 		kaddr = kmap(page);
-		memcpy(dibh->b_data + sizeof(struct gfs_dinode) + from,
-		       (char *)kaddr + from,
-		       to - from);
+		memcpy(buf + pos, kaddr + pos, copied);
+		memset(kaddr + pos + copied, 0, len - copied);
+		flush_dcache_page(page);
 		kunmap(page);
 
 		brelse(dibh);
+		if (!PageUptodate(page))
+			SetPageUptodate(page);
+		unlock_page(page);
+		page_cache_release(page);
 
-		SetPageUptodate(page);
-
-		if (inode->i_size < file_size)
-			i_size_write(inode, file_size);
+		if (inode->i_size < to)
+			i_size_write(inode, to);
 	} else {
-		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);
-		}
+		ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata);
 	}
 
-	ip->gfs_file_aops.commit_write = NULL;
-	return 0;
+	ip->gfs_file_aops.write_end = NULL;
+	return ret;
 
- fail:
+fail:
 	ClearPageUptodate(page);
-
-	return error;
+	unlock_page(page);
+	page_cache_release(page);
+	return ret;
 }
 
 /**
@@ -473,7 +498,7 @@ struct address_space_operations gfs_file_aops = {
 	.writepage = gfs_writepage,
 	.readpage = gfs_readpage,
 	.sync_page = block_sync_page,
-	.prepare_write = gfs_prepare_write,
+	.write_begin = gfs_write_begin,
 	.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 bf3484c..ca5e648 100644
--- a/gfs-kernel/src/gfs/ops_export.c
+++ b/gfs-kernel/src/gfs/ops_export.c
@@ -208,13 +208,9 @@ gfs_get_parent(struct dentry *child)
 	if (!inode)
 		return ERR_PTR(-ENOMEM);
 
-	dentry = d_alloc_anon(inode);
-	if (!dentry) {
-		iput(inode);
-		return ERR_PTR(-ENOMEM);
-	}
-
-	dentry->d_op = &gfs_dops;
+	dentry = d_obtain_alias(inode);
+	if (!IS_ERR(dentry))
+		dentry->d_op = &gfs_dops;
 	return dentry;
 
  fail:
@@ -326,13 +322,9 @@ gfs_get_dentry(struct super_block *sb, struct inode_cookie *cookie)
 		return ERR_PTR(-ESTALE);
 	}
 
-	dentry = d_alloc_anon(inode);
-	if (!dentry) {
-		iput(inode);
-		return ERR_PTR(-ENOMEM);
-	}
-
-	dentry->d_op = &gfs_dops;
+	dentry = d_obtain_alias(inode);
+	if (!IS_ERR(dentry))
+		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 433fce6..400ec13 100644
--- a/gfs-kernel/src/gfs/ops_inode.c
+++ b/gfs-kernel/src/gfs/ops_inode.c
@@ -12,6 +12,7 @@
 #include <linux/xattr.h>
 #include <linux/posix_acl.h>
 #include <linux/security.h>
+#include <linux/cred.h>
 
 #include "gfs.h"
 #include "acl.h"
@@ -191,11 +192,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,
@@ -250,11 +251,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 4e2bee6..df45487 100644
--- a/gfs-kernel/src/gfs/quota.c
+++ b/gfs-kernel/src/gfs/quota.c
@@ -6,6 +6,7 @@
 #include <linux/completion.h>
 #include <linux/buffer_head.h>
 #include <linux/tty.h>
+#include <linux/cred.h>
 
 #include "gfs.h"
 #include "bmap.h"
@@ -1109,7 +1110,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;
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]