linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: dzafman@kahuna.cag.cpqcorp.net
To: trond.myklebust@fys.uio.no
Cc: linux-kernel@vger.kernel.org
Subject: NFS client llseek
Date: Thu, 13 Dec 2001 16:51 PST	[thread overview]
Message-ID: <200112140057.fBE0vDm05648@kahuna.cag.cpqcorp.net> (raw)


I noticed that generic_file_llseek looks at i_size without performing a
revalidate, so I propose the following patch for NFS client.  It applies to
both 2.4.16 and 2.5.0 kernels.


diff -Naur linux-2.4.16.orig/fs/nfs/file.c linux-2.4.16/fs/nfs/file.c
--- linux-2.4.16.orig/fs/nfs/file.c	Sun Sep 23 09:48:01 2001
+++ linux-2.4.16/fs/nfs/file.c	Thu Dec 13 15:35:05 2001
@@ -39,9 +39,10 @@
 static ssize_t nfs_file_write(struct file *, const char *, size_t, loff_t *);
 static int  nfs_file_flush(struct file *);
 static int  nfs_fsync(struct file *, struct dentry *dentry, int datasync);
+static loff_t nfs_file_llseek(struct file *, loff_t, int origin);
 
 struct file_operations nfs_file_operations = {
-	llseek:		generic_file_llseek,
+	llseek:		nfs_file_llseek,
 	read:		nfs_file_read,
 	write:		nfs_file_write,
 	mmap:		nfs_file_mmap,
@@ -142,6 +143,24 @@
 	}
 	unlock_kernel();
 	return status;
+}
+
+static loff_t
+nfs_file_llseek(struct file *file, loff_t offset, int origin)
+{
+	struct dentry * dentry = file->f_dentry;
+	struct inode * inode = dentry->d_inode;
+	loff_t result;
+
+	/*
+	 * Make sure inode fields are up-to-date, since generic_file_llseek()
+	 * might look at anything in the inode.  Currently, i_size may be
+	 * used.
+	 */
+	result = nfs_revalidate_inode(NFS_SERVER(inode), inode);
+	if (!result)
+		result = generic_file_llseek(file, offset, origin);
+	return result;
 }
 
 /*

             reply	other threads:[~2001-12-14  1:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-14  0:51 dzafman [this message]
2001-12-14 12:42 ` Trond Myklebust
2001-12-14 12:51 ` Trond Myklebust
2001-12-17 18:18   ` Jan Harkes
2001-12-17 18:42     ` Alexander Viro
2001-12-17 20:34     ` Trond Myklebust
2001-12-14 20:45 dzafman
2001-12-14 23:13 ` Pedro M. Rodrigues

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=200112140057.fBE0vDm05648@kahuna.cag.cpqcorp.net \
    --to=dzafman@kahuna.cag.cpqcorp.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=trond.myklebust@fys.uio.no \
    --subject='Re: NFS client llseek' \
    /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

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox