linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Kleikamp <shaggy@austin.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Christoph Hellwig <hch@lst.de>,
	linux-fsdevel@vger.kernel.org, Steven French <sfrench@us.ibm.com>
Subject: [PATCH] CIFS: Do not overwrite aops elements
Date: Fri, 12 May 2006 13:35:53 -0500	[thread overview]
Message-ID: <1147458953.10150.14.camel@kleikamp.austin.ibm.com> (raw)
In-Reply-To: <20060512042023.2dd484f4.akpm@osdl.org>

On Fri, 2006-05-12 at 04:20 -0700, Andrew Morton wrote:
> Christoph Hellwig <hch@lst.de> wrote:
> >
> > Same as with already do with the file operations:
> >  keep them in .rodata and prevents people from doing runtime patching.
> 
> It would occasionally be nice to be the second person to compile something.
> 
> fs/cifs/inode.c: In function `cifs_get_inode_info_unix':
> fs/cifs/inode.c:187: warning: assignment of read-only member `readpages'
> fs/cifs/inode.c: In function `cifs_get_inode_info':
> fs/cifs/inode.c:525: warning: assignment of read-only member `readpages'
> 
> Steve, you should have separate sets of a_ops and select the appropriate
> one for inode->i_data.a_ops, rather than scribbling on cifs_addr_ops.

This patch has been compile-tested only.

cifs should not be overwriting an element of the aops structure, since
the structure is shared by all cifs inodes.  Instead define a separate
aops structure to suit each purpose.

I also took the liberty of replacing a hard-coded 4096 with PAGE_CACHE_SIZE

Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>

diff -urp linux-2.6.17-rc4/fs/cifs/cifsfs.h linux/fs/cifs/cifsfs.h
--- linux-2.6.17-rc4/fs/cifs/cifsfs.h	2006-05-12 12:46:27.000000000 -0500
+++ linux/fs/cifs/cifsfs.h	2006-05-12 12:49:45.000000000 -0500
@@ -33,6 +33,7 @@
 #endif
 
 extern const struct address_space_operations cifs_addr_ops;
+extern const struct address_space_operations cifs_addr_ops_smallbuf;
 
 /* Functions related to super block operations */
 extern struct super_operations cifs_super_ops;
diff -urp linux-2.6.17-rc4/fs/cifs/file.c linux/fs/cifs/file.c
--- linux-2.6.17-rc4/fs/cifs/file.c	2006-05-12 12:46:27.000000000 -0500
+++ linux/fs/cifs/file.c	2006-05-12 12:50:34.000000000 -0500
@@ -1955,3 +1955,19 @@ const struct address_space_operations ci
 	/* .sync_page = cifs_sync_page, */
 	/* .direct_IO = */
 };
+
+/*
+ * cifs_readpages requires the server to support a buffer large enough to
+ * contain the header plus one complete page of data.  Otherwise, we need
+ * to leave cifs_readpages out of the address space operations.
+ */
+const struct address_space_operations cifs_addr_ops_smallbuf = {
+	.readpage = cifs_readpage,
+	.writepage = cifs_writepage,
+	.writepages = cifs_writepages,
+	.prepare_write = cifs_prepare_write,
+	.commit_write = cifs_commit_write,
+	.set_page_dirty = __set_page_dirty_nobuffers,
+	/* .sync_page = cifs_sync_page, */
+	/* .direct_IO = */
+};
diff -urp linux-2.6.17-rc4/fs/cifs/inode.c linux/fs/cifs/inode.c
--- linux-2.6.17-rc4/fs/cifs/inode.c	2006-05-12 10:31:20.000000000 -0500
+++ linux/fs/cifs/inode.c	2006-05-12 12:52:08.000000000 -0500
@@ -180,11 +180,12 @@ int cifs_get_inode_info_unix(struct inod
 			else /* not direct, send byte range locks */ 
 				inode->i_fop = &cifs_file_ops;
 
-			inode->i_data.a_ops = &cifs_addr_ops;
 			/* check if server can support readpages */
 			if(pTcon->ses->server->maxBuf < 
-			    4096 + MAX_CIFS_HDR_SIZE)
-				inode->i_data.a_ops->readpages = NULL;
+			    PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
+				inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
+			else
+				inode->i_data.a_ops = &cifs_addr_ops;
 		} else if (S_ISDIR(inode->i_mode)) {
 			cFYI(1, ("Directory inode"));
 			inode->i_op = &cifs_dir_inode_ops;
@@ -519,10 +520,11 @@ int cifs_get_inode_info(struct inode **p
 			else /* not direct, send byte range locks */
 				inode->i_fop = &cifs_file_ops;
 
-			inode->i_data.a_ops = &cifs_addr_ops;
 			if(pTcon->ses->server->maxBuf < 
-			     4096 + MAX_CIFS_HDR_SIZE)
-				inode->i_data.a_ops->readpages = NULL;
+			     PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
+				inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
+			else
+				inode->i_data.a_ops = &cifs_addr_ops;
 		} else if (S_ISDIR(inode->i_mode)) {
 			cFYI(1, ("Directory inode"));
 			inode->i_op = &cifs_dir_inode_ops;
diff -urp linux-2.6.17-rc4/fs/cifs/readdir.c linux/fs/cifs/readdir.c
--- linux-2.6.17-rc4/fs/cifs/readdir.c	2006-05-12 10:31:20.000000000 -0500
+++ linux/fs/cifs/readdir.c	2006-05-12 13:11:47.000000000 -0500
@@ -21,6 +21,7 @@
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 #include <linux/fs.h>
+#include <linux/pagemap.h>
 #include <linux/stat.h>
 #include <linux/smp_lock.h>
 #include "cifspdu.h"
@@ -215,11 +216,13 @@ static void fill_in_inode(struct inode *
 		else
 			tmp_inode->i_fop = &cifs_file_ops;
 
-		tmp_inode->i_data.a_ops = &cifs_addr_ops;
 		if((cifs_sb->tcon) && (cifs_sb->tcon->ses) &&
 		   (cifs_sb->tcon->ses->server->maxBuf <
-			4096 + MAX_CIFS_HDR_SIZE))
-			tmp_inode->i_data.a_ops->readpages = NULL;
+			PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE))
+			tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
+		else
+			tmp_inode->i_data.a_ops = &cifs_addr_ops;
+
 		if(isNewInode)
 			return; /* No sense invalidating pages for new inode
 				   since have not started caching readahead file
@@ -338,11 +341,12 @@ static void unix_fill_in_inode(struct in
 		else
 			tmp_inode->i_fop = &cifs_file_ops;
 
-		tmp_inode->i_data.a_ops = &cifs_addr_ops;
 		if((cifs_sb->tcon) && (cifs_sb->tcon->ses) &&
 		   (cifs_sb->tcon->ses->server->maxBuf < 
-			4096 + MAX_CIFS_HDR_SIZE))
-			tmp_inode->i_data.a_ops->readpages = NULL;
+			PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE))
+			tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
+		else
+			tmp_inode->i_data.a_ops = &cifs_addr_ops;
 
 		if(isNewInode)
 			return; /* No sense invalidating pages for new inode since we

-- 
David Kleikamp
IBM Linux Technology Center


      reply	other threads:[~2006-05-12 18:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-03 13:18 [PATCH] mark address_space_operations const Christoph Hellwig
2006-05-09  5:30 ` Prasanna S Panchamukhi
2006-05-09  5:56   ` Greg KH
2006-05-09  7:24     ` Prasanna S Panchamukhi
2006-05-09  9:13   ` Christoph Hellwig
2006-05-12 11:20 ` Andrew Morton
2006-05-12 18:35   ` Dave Kleikamp [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1147458953.10150.14.camel@kleikamp.austin.ibm.com \
    --to=shaggy@austin.ibm.com \
    --cc=akpm@osdl.org \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=sfrench@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).