1. 18 10月, 2008 17 次提交
    • E
      9p: add new protocol support code · ace51c4d
      Eric Van Hensbergen 提交于
      This adds a new protocol processing support code based on Anthony Liguori's
      9p library code.  This code performs protocol marshalling/unmarshalling using
      printf like strings to represent protocol elements.  It is my intent to use
      them to replace the current functions in conv.c as well as the 
      p9_create_* functions.
      
      This should make the client implementation much more clear, and also make it
      much easier to add new protocol extensions by limiting the number of places
      in which changes need to be made.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      
      
      ace51c4d
    • E
      9p: encapsulate version function · 6936bf60
      Eric Van Hensbergen 提交于
      Alsmot all 9P client wire functions have their own (set of) functions.
      Tversion is an exception as its encapsulated into the client_create code.
      
      This patch moves the protocol specifics of this to a function to match the
      rest of the code.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      
      
      
      6936bf60
    • E
      9p: move dirread to fs layer · 06b55b46
      Eric Van Hensbergen 提交于
      Currently reading a directory is implemented in the client code.
      This function is not actually a wire operation, but a meta operation 
      which calls read operations and processes the results.
      
      This patch moves this functionality to the fs layer and calls component
      wire operations instead of constructing their packets.  This provides a 
      cleaner separation and will help when we reorganize the client functions
      and protocol processing methods.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      
      
      
      06b55b46
    • E
      9p: move readn meta-function from client to fs layer · fbedadc1
      Eric Van Hensbergen 提交于
      There are a couple of methods in the client code which aren't actually
      wire operations.  To keep things organized cleaner, these operations are
      being moved to the fs layer.
      
      This patch moves the readn meta-function (which executes multiple wire
      reads until a buffer is full) to the fs layer.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      
      
      
      fbedadc1
    • E
      9p: consolidate read/write functions · 0fc9655e
      Eric Van Hensbergen 提交于
      Currently there are two separate versions of read and write.  One for
      dealing with user buffers and the other for dealing with kernel buffers.
      There is a tremendous amount of code duplication in the otherwise
      identical versions of these functions.  This patch adds an additional
      user buffer parameter to read and write and conditionalizes handling of
      the buffer on whether the kernel buffer or the user buffer is populated.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      
      
      
      0fc9655e
    • T
      9p: drop broken unused error path from p9_conn_create() · 95820a36
      Tejun Heo 提交于
      Post p9_fd_poll() error path which checks m->poll_waddr[i] for PTR_ERR
      value has the following problems.
      
      * It's completely unused.  Error value is set iff NULL @wait_address
        has been specified to p9_pollwait() which is guaranteed not to
        happen.
      
      * It dereferences @m after deallocating it (introduced by 571ffeaf and
        spotted by Raja R Harinath.
      
      * It returned the wrong value on error.  It should return
        poll_waddr[i] but it returnes poll_waddr (introduced by 571ffeaf).
      
      * p9_mux_poll_stop() doesn't handle PTR_ERR value.  It will try to
        operate on the PTR_ERR value as if it's a normal pointer and cause
        oops.
      
      As the error path is bogus in the first place, there's no reason to
      hold onto it.  Kill it.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      Cc: Raja R Harinath <harinath@hurrynot.org>
      95820a36
    • E
      9p: make rpc code common and rework flush code · 91b8534f
      Eric Van Hensbergen 提交于
      This code moves the rpc function to the common client base,
      reorganizes the flush code to be more simple and stable, and
      makes the necessary adjustments to the underlying transports
      to adapt to the new structure.
      
      This reduces the overall amount of code duplication between the
      transports and should make adding new transports more straightforward.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      91b8534f
    • E
      9p: use the rcall structure passed in the request in trans_fd read_work · 1b0a763b
      Eric Van Hensbergen 提交于
      This patch reworks the read_work function to enable it to directly use a passed
      in rcall structure.  This should help allow us to remove unnecessary copies
      in the future.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      1b0a763b
    • E
      9p: apply common request code to trans_fd · 673d62cd
      Eric Van Hensbergen 提交于
      Apply the now common p9_req_t structure to the fd transport.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      673d62cd
    • E
      9p: apply common tagpool handling to trans_fd · ff683452
      Eric Van Hensbergen 提交于
      Simplify trans_fd by using new common client tagpool structure.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      ff683452
    • E
      9p: move request management to client code · fea511a6
      Eric Van Hensbergen 提交于
      The virtio transport uses a simplified request management system
      that I want to use for all transports.  This patch adapts and moves the
      exisiting code for managing requests to the client common code.
      Later patches will apply these mechanisms to the other transports.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      fea511a6
    • E
      9p: eliminate callback complexity · 044c7768
      Eric Van Hensbergen 提交于
      The current trans_fd rpc mechanisms use a dynamic callback mechanism which
      introduces a lot of complexity which only accomodates a single special case.
      This patch removes much of that complexity in favor of a simple exception
      mechanism to deal with flushes.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      044c7768
    • E
      9p: consolidate mux_rpc and request structure · 21c00368
      Eric Van Hensbergen 提交于
      Currently, trans_fd has two structures (p9_req and p9_mux-rpc)
      which contain mostly duplicate data.
      
      This patch consolidates these two structures and removes p9_mux_rpc.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      21c00368
    • E
      9p: remove unnecessary prototypes · 5503ac56
      Eric Van Hensbergen 提交于
      Cleanup files by reordering functions in order to remove need for
      unnecessary function prototypes.
      
      There are no code changes here, just functions being moved around and
      prototypes being eliminated.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      5503ac56
    • E
      9p: remove duplicate client state · bead27f0
      Eric Van Hensbergen 提交于
      Now that we are passing client state into the transport modules, remove
      duplicate state which is present in transport private structures.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      bead27f0
    • E
      9p: consolidate transport structure · 8b81ef58
      Eric Van Hensbergen 提交于
      Right now there is a transport module structure which provides per-transport
      type functions and data and a transport structure which contains per-instance
      public data as well as function pointers to instance specific functions.
      
      This patch moves public transport visible instance data to the client
      structure (which in some cases had duplicate data) and consolidates the
      functions into the transport module structure.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      8b81ef58
    • T
      9p-trans_fd: use single poller · 992b3f1d
      Tejun Heo 提交于
      trans_fd used pool of upto 100 pollers to monitor the r/w fds.  The
      approach makes sense in userspace back when the only available
      interfaces were poll(2) and select(2).  As each event monitor -
      trigger - handling iteration took O(n) where `n' is the number of
      watched fds, it makes sense to spread them to many pollers such that
      the `n' can be divided by the number of pollers.  However, this
      doesn't make any sense in kernel because persistent edge triggered
      event monitoring is how the whole thing is implemented in the kernel
      in the first place.
      
      This patch converts trans_fd to use single poller which watches all
      the fds instead of the poll of pollers approach.  All the fds are
      registered for monitoring on creation and only the fds with pending
      events are scanned when something happens much like how epoll is
      implemented.
      
      This change makes trans_fd fd monitoring more efficient and simpler.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      992b3f1d
  2. 14 10月, 2008 1 次提交
  3. 25 9月, 2008 7 次提交
    • E
      9p: fix put_data error handling · 16ec4700
      Eric Van Hensbergen 提交于
      Abhishek Kulkarni pointed out an inconsistency in the way
      errors are returned from p9_put_data.  On deeper exploration it
      seems the error handling for this path was completely wrong.
      This patch adds checks for allocation problems and propagates
      errors correctly.
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      16ec4700
    • J
      9p: introduce missing kfree · 62067824
      Julia Lawall 提交于
      Error handling code following a kmalloc should free the allocated data.
      
      The semantic match that finds the problem is as follows:
      (http://www.emn.fr/x-info/coccinelle/)
      
      // <smpl>
      @r exists@
      local idexpression x;
      statement S;
      expression E;
      identifier f,l;
      position p1,p2;
      expression *ptr != NULL;
      @@
      
      (
      if ((x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...)) == NULL) S
      |
      x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
      ...
      if (x == NULL) S
      )
      <... when != x
           when != if (...) { <+...x...+> }
      x->f = E
      ...>
      (
       return \(0\|<+...x...+>\|ptr\);
      |
       return@p2 ...;
      )
      
      @script:python@
      p1 << r.p1;
      p2 << r.p2;
      @@
      
      print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line)
      // </smpl>
      Signed-off-by: NJulia Lawall <julia@diku.dk>
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      62067824
    • T
      9p-trans_fd: fix and clean up module init/exit paths · 206ca50d
      Tejun Heo 提交于
      trans_fd leaked p9_mux_wq on module unload.  Fix it.  While at it,
      collapse p9_mux_global_init() into p9_trans_fd_init().  It's easier to
      follow this way and the global poll_tasks array is about to removed
      anyway.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      206ca50d
    • T
      9p-trans_fd: don't do fs segment mangling in p9_fd_poll() · ec3c68f2
      Tejun Heo 提交于
      p9_fd_poll() is never called with user pointers and f_op->poll()
      doesn't expect its arguments to be from userland.  There's no need to
      set kernel ds before calling f_op->poll() from p9_fd_poll().  Remove
      it.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      ec3c68f2
    • T
      9p-trans_fd: clean up p9_conn_create() · 571ffeaf
      Tejun Heo 提交于
      * Use kzalloc() to allocate p9_conn and remove 0/NULL initializations.
      
      * Clean up error return paths.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      571ffeaf
    • T
      9p-trans_fd: fix trans_fd::p9_conn_destroy() · 7dc5d24b
      Tejun Heo 提交于
      p9_conn_destroy() first kills all current requests by calling
      p9_conn_cancel(), then waits for the request list to be cleared by
      waiting on p9_conn->equeue.  After that, polling is stopped and the
      trans is destroyed.  This sequence has a few problems.
      
      * Read and write works were never cancelled and the p9_conn can be
        destroyed while the works are running as r/w works remove requests
        from the list and dereference the p9_conn from them.
      
      * The list emptiness wait using p9_conn->equeue wouldn't trigger
        because p9_conn_cancel() always clears all the lists and the only
        way the wait can be triggered is to have another task to issue a
        request between the slim window between p9_conn_cancel() and the
        wait, which isn't safe under the current implementation with or
        without the wait.
      
      This patch fixes the problem by first stopping poll, which can
      schedule r/w works, first and cancle r/w works which guarantees that
      r/w works are not and will not run from that point and then calling
      p9_conn_cancel() and do the rest of destruction.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      7dc5d24b
    • T
      9p: implement proper trans module refcounting and unregistration · 72029fe8
      Tejun Heo 提交于
      9p trans modules aren't refcounted nor were they unregistered
      properly.  Fix it.
      
      * Add 9p_trans_module->owner and reference the module on each trans
        instance creation and put it on destruction.
      
      * Protect v9fs_trans_list with a spinlock.  This isn't strictly
        necessary as the list is manipulated only during module loading /
        unloading but it's a good idea to make the API safe.
      
      * Unregister trans modules when the corresponding module is being
        unloaded.
      
      * While at it, kill unnecessary EXPORT_SYMBOL on p9_trans_fd_init().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NEric Van Hensbergen <ericvh@gmail.com>
      72029fe8
  4. 25 7月, 2008 1 次提交
    • U
      flag parameters: socket and socketpair · a677a039
      Ulrich Drepper 提交于
      This patch adds support for flag values which are ORed to the type passwd
      to socket and socketpair.  The additional code is minimal.  The flag
      values in this implementation can and must match the O_* flags.  This
      avoids overhead in the conversion.
      
      The internal functions sock_alloc_fd and sock_map_fd get a new parameters
      and all callers are changed.
      
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      #include <fcntl.h>
      #include <stdio.h>
      #include <unistd.h>
      #include <netinet/in.h>
      #include <sys/socket.h>
      
      #define PORT 57392
      
      /* For Linux these must be the same.  */
      #define SOCK_CLOEXEC O_CLOEXEC
      
      int
      main (void)
      {
        int fd;
        fd = socket (PF_INET, SOCK_STREAM, 0);
        if (fd == -1)
          {
            puts ("socket(0) failed");
            return 1;
          }
        int coe = fcntl (fd, F_GETFD);
        if (coe == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if (coe & FD_CLOEXEC)
          {
            puts ("socket(0) set close-on-exec flag");
            return 1;
          }
        close (fd);
      
        fd = socket (PF_INET, SOCK_STREAM|SOCK_CLOEXEC, 0);
        if (fd == -1)
          {
            puts ("socket(SOCK_CLOEXEC) failed");
            return 1;
          }
        coe = fcntl (fd, F_GETFD);
        if (coe == -1)
          {
            puts ("fcntl failed");
            return 1;
          }
        if ((coe & FD_CLOEXEC) == 0)
          {
            puts ("socket(SOCK_CLOEXEC) does not set close-on-exec flag");
            return 1;
          }
        close (fd);
      
        int fds[2];
        if (socketpair (PF_UNIX, SOCK_STREAM, 0, fds) == -1)
          {
            puts ("socketpair(0) failed");
            return 1;
          }
        for (int i = 0; i < 2; ++i)
          {
            coe = fcntl (fds[i], F_GETFD);
            if (coe == -1)
              {
                puts ("fcntl failed");
                return 1;
              }
            if (coe & FD_CLOEXEC)
              {
                printf ("socketpair(0) set close-on-exec flag for fds[%d]\n", i);
                return 1;
              }
            close (fds[i]);
          }
      
        if (socketpair (PF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0, fds) == -1)
          {
            puts ("socketpair(SOCK_CLOEXEC) failed");
            return 1;
          }
        for (int i = 0; i < 2; ++i)
          {
            coe = fcntl (fds[i], F_GETFD);
            if (coe == -1)
              {
                puts ("fcntl failed");
                return 1;
              }
            if ((coe & FD_CLOEXEC) == 0)
              {
                printf ("socketpair(SOCK_CLOEXEC) does not set close-on-exec flag for fds[%d]\n", i);
                return 1;
              }
            close (fds[i]);
          }
      
        puts ("OK");
      
        return 0;
      }
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Signed-off-by: NUlrich Drepper <drepper@redhat.com>
      Acked-by: NDavide Libenzi <davidel@xmailserver.org>
      Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a677a039
  5. 15 5月, 2008 7 次提交
  6. 29 3月, 2008 1 次提交
    • A
      net/9p/trans_fd.c:p9_trans_fd_init(): module_init functions should return 0 on success · 3387b804
      Andrew Morton 提交于
      Mar 23 09:06:31 opensuse103 kernel: Installing 9P2000 support
      Mar 23 09:06:31 opensuse103 kernel: sys_init_module: '9pnet_fd'->init suspiciously returned 1, it should follow 0/-E convention
      Mar 23 09:06:31 opensuse103 kernel: sys_init_module: loading module anyway...
      Mar 23 09:06:31 opensuse103 kernel: Pid: 5323, comm: modprobe Not tainted 2.6.25-rc6-git7-default #1
      Mar 23 09:06:31 opensuse103 kernel:  [<c013c253>] sys_init_module+0x172b/0x17c9
      Mar 23 09:06:31 opensuse103 kernel:  [<c0108a6a>] sys_mmap2+0x62/0x77
      Mar 23 09:06:31 opensuse103 kernel:  [<c01059c4>] sysenter_past_esp+0x6d/0xa9
      Mar 23 09:06:31 opensuse103 kernel:  =======================
      
      Cc: Latchesar Ionkov <lucho@ionkov.net>
      Cc: Eric Van Hensbergen <ericvh@opteron.(none)>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
      Cc: <devzero@web.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3387b804
  7. 23 3月, 2008 1 次提交
  8. 06 3月, 2008 1 次提交
  9. 20 2月, 2008 1 次提交
  10. 18 2月, 2008 1 次提交
  11. 07 2月, 2008 2 次提交