mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Trond Myklebust <trond.myklebust@fys.uio.no>
To: Olof Johansson <olof@lixom.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nfs: init req_lock in nfs_alloc_inode
Date: Tue, 20 Feb 2007 19:37:18 -0500	[thread overview]
Message-ID: <1172018238.6421.26.camel@heimdal.trondhjem.org> (raw)
In-Reply-To: <20070220172345.GA19249@lixom.net>

[-- Attachment #1: Type: text/plain, Size: 2189 bytes --]

On Tue, 2007-02-20 at 11:23 -0600, Olof Johansson wrote:

> In my original reproduction, I had to boot with nfs root, and try to mount
> my sata drive (/dev/sda3). This is with a static /dev, no udev. Seems like it
> happens when trying to mount any block device that's located on NFS.
> 
> Since this is what nfs_sync_mapping_wait does:
> 
> long nfs_sync_mapping_wait(struct address_space *mapping, struct
> 		 	   writeback_control *wbc, int how) {
>         struct inode *inode = mapping->host;
>         struct nfs_inode *nfsi = NFS_I(inode);
> [...]
>         spin_lock(&nfsi->req_lock);
> [...]
> 
> I added this and it pops when mounting:
> 
> @@ -421,6 +421,10 @@ int nfs_getattr(struct vfsmount *mnt, st
>         int need_atime = NFS_I(inode)->cache_validity & NFS_INO_INVALID_ATIME;
>         int err;
>  
> +       if (inode->i_mapping->host != inode) {
> +               printk("inode %p host %p\n", inode, inode->i_mapping->host);
> +               printk("inode_nfs %p host_nfs %p\n", NFS_I(inode), NFS_I(inode->i_mapping->host));
> +       }
>         /* Flush out writes to the server in order to update c/mtime */
>         nfs_sync_mapping_range(inode->i_mapping, 0, 0, FLUSH_NOCOMMIT);
>  
> 
> I don't claim to know VFS internals, but doesn't it make sense that the
> device node is backed against the actual device, not an NFS inode? And
> if so, NFS can't expect to do nfs_sync_mapping_range() on it, or at
> least not dereference ->host and use it as an NFS inode, right?

NFS still has to manage the inode attributes and handle permissions. It
is only when you open the device that the VFS takes over (see the call
to init_special_inode() in nfs_fhget()).

> What I'm not sure I understand is why it disappears in the first place
> when I add the spin lock init -- I never even see the i_mapping->host
> pointer being allocated as an nfs inode. Maybe I just messed that one
> up somehow.

Looks like we need a check in nfs_getattr() for a regular file. It makes
no sense to call nfs_sync_mapping_range() on anything else. I think that
should fix your problem: it will stop the NFS client from interfering
with dirty pages on that inode's mapping.

Cheers
  Trond

[-- Attachment #2: linux-2.6.20-000-fix_block_device_getattr.dif --]
[-- Type: message/rfc822, Size: 967 bytes --]

From: Trond Myklebust <Trond.Myklebust@netapp.com>
Subject: No Subject
Date: Tue, 20 Feb 2007 19:28:07 -0500
Message-ID: <1172017790.6421.19.camel@heimdal.trondhjem.org>

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---

 fs/nfs/inode.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index af53c02..93d046c 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -429,7 +429,8 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
 	int err;
 
 	/* Flush out writes to the server in order to update c/mtime */
-	nfs_sync_mapping_range(inode->i_mapping, 0, 0, FLUSH_NOCOMMIT);
+	if (S_ISREG(inode->i_mode))
+		nfs_sync_mapping_range(inode->i_mapping, 0, 0, FLUSH_NOCOMMIT);
 
 	/*
 	 * We may force a getattr if the user cares about atime.

  reply	other threads:[~2007-02-21  0:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-16 17:05 Olof Johansson
2007-02-17  0:15 ` Andrew Morton
2007-02-17  1:24 ` Andrew Morton
2007-02-18 20:32   ` Olof Johansson
2007-02-20 15:10 ` Trond Myklebust
2007-02-20 17:23   ` Olof Johansson
2007-02-21  0:37     ` Trond Myklebust [this message]
2007-02-22 20:13       ` Olof Johansson

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=1172018238.6421.26.camel@heimdal.trondhjem.org \
    --to=trond.myklebust@fys.uio.no \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olof@lixom.net \
    /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

all inboxes | Powered by JetHome®