1. 17 Oct, 2006 1 commit
    • J. Bruce Fields's avatar
      [PATCH] knfsd: nfsd4: fix owner-override on open · dc730e17
      J. Bruce Fields authored
      
      
      If a client creates a file using an open which sets the mode to 000, or if a
      chmod changes permissions after a file is opened, then situations may arise
      where an NFS client knows that some IO is permitted (because a process holds
      the file open), but the NFS server does not (because it doesn't know about the
      open, and only sees that the IO conflicts with the current mode of the file).
      
      As a hack to solve this problem, NFS servers normally allow the owner to
      override permissions on IO.  The client can still enforce correct
      permissions-checking on open by performing an explicit access check.
      
      In NFSv4 the client can rely on the explicit on-the-wire open instead of an
      access check.
      
      Therefore we should not be allowing the owner to override permissions on an
      over-the-wire open!
      
      However, we should still allow the owner to override permissions in the case
      where the client is claiming an open that it already made either before a
      reboot, or while it was holding a delegation.
      
      Thanks to Jim Rees for reporting the bug.
      Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
      Signed-off-by: default avatarNeil Brown <neilb@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      dc730e17
  2. 06 Oct, 2006 1 commit
    • NeilBrown's avatar
      [PATCH] knfsd: tidy up up meaning of 'buffer size' in nfsd/sunrpc · c6b0a9f8
      NeilBrown authored
      
      
      There is some confusion about the meaning of 'bufsz' for a sunrpc server.
      In some cases it is the largest message that can be sent or received.  In
      other cases it is the largest 'payload' that can be included in a NFS
      message.
      
      In either case, it is not possible for both the request and the reply to be
      this large.  One of the request or reply may only be one page long, which
      fits nicely with NFS.
      
      So we remove 'bufsz' and replace it with two numbers: 'max_payload' and
      'max_mesg'.  Max_payload is the size that the server requests.  It is used
      by the server to check the max size allowed on a particular connection:
      depending on the protocol a lower limit might be used.
      
      max_mesg is the largest single message that can be sent or received.  It is
      calculated as the max_payload, rounded up to a multiple of PAGE_SIZE, and
      with PAGE_SIZE added to overhead.  Only one of the request and reply may be
      this size.  The other must be at most one page.
      
      Cc: Greg Banks <gnb@sgi.com>
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Signed-off-by: default avatarNeil Brown <neilb@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      c6b0a9f8
  3. 04 Oct, 2006 21 commits
  4. 03 Oct, 2006 3 commits
    • Eric Sesterhenn's avatar
      BUG_ON() conversion in fs/nfsd/ · 73dff8be
      Eric Sesterhenn authored
      
      
      This patch converts an if () BUG(); construct to BUG_ON();
      which occupies less space, uses unlikely and is safer when
      BUG() is disabled.
      Signed-off-by: default avatarEric Sesterhenn <snakebyte@gmx.de>
      Signed-off-by: default avatarAdrian Bunk <bunk@stusta.de>
      73dff8be
    • Uwe Zeisberger's avatar
      fix file specification in comments · f30c2269
      Uwe Zeisberger authored
      
      
      Many files include the filename at the beginning, serveral used a wrong one.
      Signed-off-by: default avatarUwe Zeisberger <Uwe_Zeisberger@digi.com>
      Signed-off-by: default avatarAdrian Bunk <bunk@stusta.de>
      f30c2269
    • David Howells's avatar
      [PATCH] VFS: Make filldir_t and struct kstat deal in 64-bit inode numbers · afefdbb2
      David Howells authored
      
      
      These patches make the kernel pass 64-bit inode numbers internally when
      communicating to userspace, even on a 32-bit system.  They are required
      because some filesystems have intrinsic 64-bit inode numbers: NFS3+ and XFS
      for example.  The 64-bit inode numbers are then propagated to userspace
      automatically where the arch supports it.
      
      Problems have been seen with userspace (eg: ld.so) using the 64-bit inode
      number returned by stat64() or getdents64() to differentiate files, and
      failing because the 64-bit inode number space was compressed to 32-bits, and
      so overlaps occur.
      
      This patch:
      
      Make filldir_t take a 64-bit inode number and struct kstat carry a 64-bit
      inode number so that 64-bit inode numbers can be passed back to userspace.
      
      The stat functions then returns the full 64-bit inode number where
      available and where possible.  If it is not possible to represent the inode
      number supplied by the filesystem in the field provided by userspace, then
      error EOVERFLOW will be issued.
      
      Similarly, the getdents/readdir functions now pass the full 64-bit inode
      number to userspace where possible, returning EOVERFLOW instead when a
      directory entry is encountered that can't be properly represented.
      
      Note that this means that some inodes will not be stat'able on a 32-bit
      system with old libraries where they were before - but it does mean that
      there will be no ambiguity over what a 32-bit inode number refers to.
      
      Note similarly that directory scans may be cut short with an error on a
      32-bit system with old libraries where the scan would work before for the
      same reasons.
      
      It is judged unlikely that this situation will occur because modern glibc
      uses 64-bit capable versions of stat and getdents class functions
      exclusively, and that older systems are unlikely to encounter
      unrepresentable inode numbers anyway.
      
      [akpm: alpha build fix]
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Cc: Trond Myklebust <trond.myklebust@fys.uio.no>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      afefdbb2
  5. 02 Oct, 2006 14 commits
    • Peter Zijlstra's avatar
      [PATCH] nfsd: lockdep annotation · 12fd3520
      Peter Zijlstra authored
      
      
      while doing a kernel make modules_install install over an NFS mount.
      
        =============================================
        [ INFO: possible recursive locking detected ]
        ---------------------------------------------
        nfsd/9550 is trying to acquire lock:
         (&inode->i_mutex){--..}, at: [<c034c845>] mutex_lock+0x1c/0x1f
      
        but task is already holding lock:
         (&inode->i_mutex){--..}, at: [<c034c845>] mutex_lock+0x1c/0x1f
      
        other info that might help us debug this:
        2 locks held by nfsd/9550:
         #0:  (hash_sem){..--}, at: [<cc895223>] exp_readlock+0xd/0xf [nfsd]
         #1:  (&inode->i_mutex){--..}, at: [<c034c845>] mutex_lock+0x1c/0x1f
      
        stack backtrace:
         [<c0103508>] show_trace_log_lvl+0x58/0x152
         [<c0103b8b>] show_trace+0xd/0x10
         [<c0103c2f>] dump_stack+0x19/0x1b
         [<c012aa57>] __lock_acquire+0x77a/0x9a3
         [<c012af4a>] lock_acquire+0x60/0x80
         [<c034c6c2>] __mutex_lock_slowpath+0xa7/0x20e
         [<c034c845>] mutex_lock+0x1c/0x1f
         [<c0162edc>] vfs_unlink+0x34/0x8a
         [<cc891d98>] nfsd_unlink+0x18f/0x1e2 [nfsd]
         [<cc89884f>] nfsd3_proc_remove+0x95/0xa2 [nfsd]
         [<cc88f0d4>] nfsd_dispatch+0xc0/0x178 [nfsd]
         [<c033e84d>] svc_process+0x3a5/0x5ed
         [<cc88f5ba>] nfsd+0x1a7/0x305 [nfsd]
         [<c0101005>] kernel_thread_helper+0x5/0xb
        DWARF2 unwinder stuck at kernel_thread_helper+0x5/0xb
        Leftover inexact backtrace:
         [<c0103b8b>] show_trace+0xd/0x10
         [<c0103c2f>] dump_stack+0x19/0x1b
         [<c012aa57>] __lock_acquire+0x77a/0x9a3
         [<c012af4a>] lock_acquire+0x60/0x80
         [<c034c6c2>] __mutex_lock_slowpath+0xa7/0x20e
         [<c034c845>] mutex_lock+0x1c/0x1f
         [<c0162edc>] vfs_unlink+0x34/0x8a
         [<cc891d98>] nfsd_unlink+0x18f/0x1e2 [nfsd]
         [<cc89884f>] nfsd3_proc_remove+0x95/0xa2 [nfsd]
         [<cc88f0d4>] nfsd_dispatch+0xc0/0x178 [nfsd]
         [<c033e84d>] svc_process+0x3a5/0x5ed
         [<cc88f5ba>] nfsd+0x1a7/0x305 [nfsd]
         [<c0101005>] kernel_thread_helper+0x5/0xb
      
        =============================================
        [ INFO: possible recursive locking detected ]
        ---------------------------------------------
        nfsd/9580 is trying to acquire lock:
         (&inode->i_mutex){--..}, at: [<c034cc1d>] mutex_lock+0x1c/0x1f
      
        but task is already holding lock:
         (&inode->i_mutex){--..}, at: [<c034cc1d>] mutex_lock+0x1c/0x1f
      
        other info that might help us debug this:
        2 locks held by nfsd/9580:
         #0:  (hash_sem){..--}, at: [<cc89522b>] exp_readlock+0xd/0xf [nfsd]
         #1:  (&inode->i_mutex){--..}, at: [<c034cc1d>] mutex_lock+0x1c/0x1f
      
        stack backtrace:
         [<c0103508>] show_trace_log_lvl+0x58/0x152
         [<c0103b8b>] show_trace+0xd/0x10
         [<c0103c2f>] dump_stack+0x19/0x1b
         [<c012aa63>] __lock_acquire+0x77a/0x9a3
         [<c012af56>] lock_acquire+0x60/0x80
         [<c034ca9a>] __mutex_lock_slowpath+0xa7/0x20e
         [<c034cc1d>] mutex_lock+0x1c/0x1f
         [<cc892ad1>] nfsd_setattr+0x2c8/0x499 [nfsd]
         [<cc893ede>] nfsd_create_v3+0x31b/0x4ac [nfsd]
         [<cc8984a1>] nfsd3_proc_create+0x128/0x138 [nfsd]
         [<cc88f0d4>] nfsd_dispatch+0xc0/0x178 [nfsd]
         [<c033ec1d>] svc_process+0x3a5/0x5ed
         [<cc88f5ba>] nfsd+0x1a7/0x305 [nfsd]
         [<c0101005>] kernel_thread_helper+0x5/0xb
        DWARF2 unwinder stuck at kernel_thread_helper+0x5/0xb
        Leftover inexact backtrace:
         [<c0103b8b>] show_trace+0xd/0x10
         [<c0103c2f>] dump_stack+0x19/0x1b
         [<c012aa63>] __lock_acquire+0x77a/0x9a3
         [<c012af56>] lock_acquire+0x60/0x80
         [<c034ca9a>] __mutex_lock_slowpath+0xa7/0x20e
         [<c034cc1d>] mutex_lock+0x1c/0x1f
         [<cc892ad1>] nfsd_setattr+0x2c8/0x499 [nfsd]
         [<cc893ede>] nfsd_create_v3+0x31b/0x4ac [nfsd]
         [<cc8984a1>] nfsd3_proc_create+0x128/0x138 [nfsd]
         [<cc88f0d4>] nfsd_dispatch+0xc0/0x178 [nfsd]
         [<c033ec1d>] svc_process+0x3a5/0x5ed
         [<cc88f5ba>] nfsd+0x1a7/0x305 [nfsd]
         [<c0101005>] kernel_thread_helper+0x5/0xb
      Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Neil Brown <neilb@suse.de>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Arjan van de Ven <arjan@infradead.org>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      12fd3520
    • Greg Banks's avatar
      [PATCH] knfsd: allow admin to set nthreads per node · eed2965a
      Greg Banks authored
      
      
      Add /proc/fs/nfsd/pool_threads which allows the sysadmin (or a userspace
      daemon) to read and change the number of nfsd threads in each pool.  The
      format is a list of space-separated integers, one per pool.
      Signed-off-by: default avatarGreg Banks <gnb@melbourne.sgi.com>
      Signed-off-by: default avatarNeil Brown <neilb@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      eed2965a
    • Greg Banks's avatar
      [PATCH] knfsd: use svc_set_num_threads to manage threads in knfsd · eec09661
      Greg Banks authored
      
      
      Replace the existing list of all nfsd threads with new code using
      svc_create_pooled().
      Signed-off-by: default avatarGreg Banks <gnb@melbourne.sgi.com>
      Signed-off-by: default avatarNeil Brown <neilb@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      eec09661
    • Greg Banks's avatar
      [PATCH] knfsd: add svc_get · 9a24ab57
      Greg Banks authored
      
      
      add svc_get() for those occasions when we need to temporarily bump up
      svc_serv->sv_nrthreads as a pseudo refcount.
      Signed-off-by: default avatarGreg Banks <gnb@melbourne.sgi.com>
      Signed-off-by: default avatarNeil Brown <neilb@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      9a24ab57
    • NeilBrown's avatar
      [PATCH] knfsd: Correctly handle error condition from lockd_up · 4a3ae42d
      NeilBrown authored
      
      
      If lockd_up fails - what should we expect?  Do we have to later call
      lockd_down?
      
      Well the nfs client thinks "no", the nfs server thinks "yes".  lockd thinks
      "yes".
      
      The only answer that really makes sense is "no" !!
      
      So:
        Make lockd_up only increment  nlmsvc_users on success.
        Make nfsd handle errors from lockd_up properly.
        Make sure lockd_up(0) never fails when lockd is running
          so that the 'reclaimer' call to lockd_up doesn't need to
          be error checked.
      
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Signed-off-by: default avatarNeil Brown <neilb@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      4a3ae42d
    • NeilBrown's avatar
      [PATCH] knfsd: Check return value of lockd_up in write_ports · 3dfb4210
      NeilBrown authored
      
      
      We should be checking the return value of lockd_up when adding a new socket to
      nfsd.  So move the lockd_up before the svc_addsock and check the return value.
      
      The move is because lockd_down is easy, but there is no easy way to remove a
      recently added socket.
      
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Signed-off-by: default avatarNeil Brown <neilb@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      3dfb4210
    • NeilBrown's avatar
      [PATCH] knfsd: Drop 'serv' option to svc_recv and svc_process · 6fb2b47f
      NeilBrown authored
      
      
      It isn't needed as it is available in rqstp->rq_server, and dropping it allows
      some local vars to be dropped.
      
      [akpm@osdl.org: build fix]
      Cc: "J. Bruce Fields" <bfields@fieldses.org>
      Signed-off-by: default avatarNeil Brown <neilb@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      6fb2b47f
    • Josh Triplett's avatar
      [PATCH] nfsd: add lock annotations to e_start and e_stop · 896440d5
      Josh Triplett authored
      
      
      e_start acquires svc_export_cache.hash_lock, and e_stop releases it.  Add
      lock annotations to these two functions so that sparse can check callers
      for lock pairing, and so that sparse will not complain about these
      functions since they intentionally use locks in this manner.
      Signed-off-by: default avatarJosh Triplett <josh@freedesktop.org>
      Cc: Neil Brown <neilb@cse.unsw.edu.au>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      896440d5
    • Greg Banks's avatar
    • NeilBrown's avatar
      [PATCH] knfsd: allow sockets to be passed to nfsd via 'portlist' · b41b66d6
      NeilBrown authored
      
      
      Userspace should create and bind a socket (but not connectted) and write the
      'fd' to portlist.  This will cause the nfs server to listen on that socket.
      
      To close a socket, the name of the socket - as read from 'portlist' can be
      written to 'portlist' with a preceding '-'.
      Signed-off-by: default avatarNeil Brown <neilb@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      b41b66d6
    • NeilBrown's avatar
      [PATCH] knfsd: define new nfsdfs file: portlist - contains list of ports · 80212d59
      NeilBrown authored
      
      
      This file will list all ports that nfsd has open.
      Default when TCP enabled will be
         ipv4 udp 0.0.0.0 2049
         ipv4 tcp 0.0.0.0 2049
      
      Later, the list of ports will be settable.
      
      'portlist' chosen rather than 'ports', to avoid unnecessary confusion with
      non-mainline patches which created 'ports' with different semantics.
      
      [akpm@osdl.org: cleanups, build fix]
      Signed-off-by: default avatarNeil Brown <neilb@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      80212d59
    • NeilBrown's avatar
      [PATCH] knfsd: separate out some parts of nfsd_svc, which start nfs servers · 02a375f0
      NeilBrown authored
      
      
      Separate out the code for creating a new service, and for creating initial
      sockets.
      
      Some of these new functions will have multiple callers soon.
      
      [akpm@osdl.org: cleanups]
      Signed-off-by: default avatarNeil Brown <neilb@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      02a375f0
    • NeilBrown's avatar
      [PATCH] knfsd: remove nfsd_versbits as intermediate storage for desired versions · 6658d3a7
      NeilBrown authored
      
      
      We have an array 'nfsd_version' which lists the available versions of nfsd,
      and 'nfsd_versions' (poor choice there :-() which lists the currently active
      versions.
      
      Then we have a bitmap - nfsd_versbits which says which versions are wanted.
      The bits in this bitset cause content to be copied from nfsd_version to
      nfsd_versions when nfsd starts.
      
      This patch removes nfsd_versbits and moves information directly from
      nfsd_version to nfsd_versions when requests for version changes arrive.
      
      Note that this doesn't make it possible to change versions while the server is
      running.  This is because serv->sv_xdrsize is calculated when a service is
      created, and used when threads are created, and xdrsize depends on the active
      versions.
      Signed-off-by: default avatarNeil Brown <neilb@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      6658d3a7
    • NeilBrown's avatar
      [PATCH] knfsd: be more selective in which sockets lockd listens on · 24e36663
      NeilBrown authored
      
      
      Currently lockd listens on UDP always, and TCP if CONFIG_NFSD_TCP is set.
      
      However as lockd performs services of the client as well, this is a problem.
      If CONFIG_NfSD_TCP is not set, and a tcp mount is used, the server will not be
      able to call back to lockd.
      
      So:
       - add an option to lockd_up saying which protocol is needed
       - Always open sockets for which an explicit port was given, otherwise
         only open a socket of the type required
       - Change nfsd to do one lockd_up per socket rather than one per thread.
      
      This
       - removes the dependancy on CONFIG_NFSD_TCP
       - means that lockd may open sockets other than at startup
       - means that lockd will *not* listen on UDP if the only
         mounts are TCP mount (and nfsd hasn't started).
      
      The latter is the only one that concerns me at all - I don't know if this
      might be a problem with some servers.
      Signed-off-by: default avatarNeil Brown <neilb@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      24e36663