31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation this program is
    distributed in the hope that it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details you should have received a copy of the gnu general
    public license along with this program if not write to free software
    foundation 51 franklin street fifth floor boston ma 02111 1301 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 27 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Richard Fontana
    Reviewed-by: Alexios Zavras
    Reviewed-by: Steve Winslow
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190528170026.981318839@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

08 Sep, 2018

2 commits

  • strcpy to dirent->d_name could overflow the buffer, use strscpy to check
    the provided string length and error out if the size was too big.

    While we are here, make the function return an error when the pdu
    parsing failed, instead of returning the pdu offset as if it had been a
    success...

    Link: http://lkml.kernel.org/r/1536339057-21974-4-git-send-email-asmadeus@codewreck.org
    Addresses-Coverity-ID: 139133 ("Copy into fixed size buffer")
    Signed-off-by: Dominique Martinet

    Dominique Martinet
     
  • v9fs_dir_readdir() could deadloop if a struct was sent with a size set
    to -2

    Link: http://lkml.kernel.org/r/1536134432-11997-1-git-send-email-asmadeus@codewreck.org
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=88021
    Signed-off-by: Gertjan Halkes
    Signed-off-by: Dominique Martinet

    Gertjan Halkes
     

29 Aug, 2018

1 commit

  • p9stat_free is more of a cleanup function than a 'free' function as it
    only frees the content of the struct; there are chances of use-after-free
    if it is improperly used (e.g. p9stat_free called twice as it used to be
    possible to)

    Clearing dangling pointers makes the function idempotent and safer to use.

    Link: http://lkml.kernel.org/r/1535410108-20650-2-git-send-email-asmadeus@codewreck.org
    Signed-off-by: Dominique Martinet
    Reported-by: syzbot+d4252148d198410b864f@syzkaller.appspotmail.com

    Dominique Martinet
     

13 Aug, 2018

1 commit

  • We should return -ENOMEM to upper user when kmalloc failed to indicate
    accurate errno.

    Link: http://lkml.kernel.org/r/5B4552C5.60000@huawei.com
    Signed-off-by: Jun Piao
    Reviewed-by: Yiwen Jiang
    Reviewed-by: Andrew Morton
    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: Andrew Morton
    Signed-off-by: Dominique Martinet

    piaojun
     

13 Jun, 2018

1 commit

  • The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
    patch replaces cases of:

    kmalloc(a * b, gfp)

    with:
    kmalloc_array(a * b, gfp)

    as well as handling cases of:

    kmalloc(a * b * c, gfp)

    with:

    kmalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kmalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kmalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The tools/ directory was manually excluded, since it has its own
    implementation of kmalloc().

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kmalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kmalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kmalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kmalloc
    + kmalloc_array
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kmalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kmalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kmalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kmalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kmalloc(C1 * C2 * C3, ...)
    |
    kmalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kmalloc(sizeof(THING) * C2, ...)
    |
    kmalloc(sizeof(TYPE) * C2, ...)
    |
    kmalloc(C1 * C2 * C3, ...)
    |
    kmalloc(C1 * C2, ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

22 Apr, 2017

1 commit


19 Apr, 2015

1 commit

  • Pull 9pfs updates from Eric Van Hensbergen:
    "Some accumulated cleanup patches for kerneldoc and unused variables as
    well as some lock bug fixes and adding privateport option for RDMA"

    * tag 'for-linus-4.1-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs:
    net/9p: add a privport option for RDMA transport.
    fs/9p: Initialize status in v9fs_file_do_lock.
    net/9p: Initialize opts->privport as it should be.
    net/9p: use memcpy() instead of snprintf() in p9_mount_tag_show()
    9p: use unsigned integers for nwqid/count
    9p: do not crash on unknown lock status code
    9p: fix error handling in v9fs_file_do_lock
    9p: remove unused variable in p9_fd_create()
    9p: kerneldoc warning fixes

    Linus Torvalds
     

12 Apr, 2015

1 commit


20 Mar, 2015

1 commit

  • As specification says, all integers in messages are unsigned. Let's fix
    behaviour of p9pdu_vreadf()/p9pdu_vwritef() accordingly.

    Fix for p9pdu_vreadf() is critical. If server replies with Rwalk, where
    nwqid > SHRT_MAX, the value will be interpreted as negative. kmalloc, in
    its order, will cast the value to (very big) size_t.

    It should never happen in normal situation: we never submit Twalk with
    nwname > 16, but malicious or broken server can still produce
    problematic Rwalk.

    Signed-off-by: Kirill A. Shutemov
    Signed-off-by: Dominique Martinet
    Signed-off-by: Eric Van Hensbergen

    Kirill A. Shutemov
     

12 Feb, 2013

2 commits

  • 9p has thre strucrtures that can encode inode stat information. Modify
    all of those structures to contain kuid_t and kgid_t values. Modify
    he wire encoders and decoders of those structures to use 'u' and 'g' instead of
    'd' in the format string where uids and gids are present.

    This results in all kuid and kgid conversion to and from on the wire values
    being performed by the same code in protocol.c where the client is known
    at the time of the conversion.

    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: Eric W. Biederman

    Eric W. Biederman
     
  • This allows concentrating all of the conversion to and from kuids and
    kgids into the format needed by the 9p protocol into one location.

    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: "Eric W. Biederman"

    Eric W. Biederman
     

28 Jun, 2012

1 commit


06 Jan, 2012

1 commit

  • Reduce object size by deduplicating formats.

    Use vsprintf extension %pV.
    Rename P9_DPRINTK uses to p9_debug, align arguments.
    Add function for _p9_debug and macro to add __func__.
    Add missing "\n"s to p9_debug uses.
    Remove embedded function names as p9_debug adds it.
    Remove P9_EPRINTK macro and convert use to pr_.
    Add and use pr_fmt and pr_.

    $ size fs/9p/built-in.o*
    text data bss dec hex filename
    62133 984 16000 79117 1350d fs/9p/built-in.o.new
    67342 984 16928 85254 14d06 fs/9p/built-in.o.old
    $ size net/9p/built-in.o*
    text data bss dec hex filename
    88792 4148 22024 114964 1c114 net/9p/built-in.o.new
    94072 4148 23232 121452 1da6c net/9p/built-in.o.old

    Signed-off-by: Joe Perches
    Signed-off-by: Eric Van Hensbergen

    Joe Perches
     

25 Oct, 2011

2 commits

  • This helps in more control over debugging.
    root@qemu-img-64:~# ls /pass/123
    ls: cannot access /pass/123: No such file or directory
    root@qemu-img-64:~# cat /sys/kernel/debug/tracing/trace
    # tracer: nop
    #
    # TASK-PID CPU# TIMESTAMP FUNCTION
    # | | | | |
    ls-1536 [001] 70.928584: 9p_protocol_dump: clnt 18446612132784021504 P9_TWALK(tag = 1)
    000: 16 00 00 00 6e 01 00 01 00 00 00 02 00 00 00 01
    010: 00 03 00 31 32 33 00 00 00 ff ff ff ff 00 00 00

    ls-1536 [001] 70.928587:
    => trace_9p_protocol_dump
    => p9pdu_finalize
    => p9_client_rpc
    => p9_client_walk
    => v9fs_vfs_lookup
    => d_alloc_and_lookup
    => walk_component
    => path_lookupat
    ls-1536 [000] 70.929696: 9p_protocol_dump: clnt 18446612132784021504 P9_RLERROR(tag = 1)
    000: 0b 00 00 00 07 01 00 02 00 00 00 4e 03 00 02 00
    010: 00 00 00 00 03 00 02 00 00 00 00 00 ff 43 00 00

    ls-1536 [000] 70.929697:
    => trace_9p_protocol_dump
    => p9_client_rpc
    => p9_client_walk
    => v9fs_vfs_lookup
    => d_alloc_and_lookup
    => walk_component
    => path_lookupat
    => do_path_lookup

    Signed-off-by: Aneesh Kumar K.V
    Signed-off-by: Eric Van Hensbergen

    Aneesh Kumar K.V
     
  • * remove lot of update to different data structure
    * add a seperate callback for zero copy request.
    * above makes non zero copy code path simpler
    * remove conditionalizing TREAD/TREADDIR/TWRITE in the zero copy path
    * Fix the dotu p9_check_errors with zero copy. Add sufficient doc around
    * Add support for both in and output buffers in zero copy callback
    * pin and unpin pages in the same context
    * use helpers instead of defining page offset and rest of page ourself
    * Fix mem leak in p9_check_errors
    * Remove 'E' and 'F' in p9pdu_vwritef

    Signed-off-by: Aneesh Kumar K.V
    Signed-off-by: Eric Van Hensbergen

    Aneesh Kumar K.V
     

23 Jul, 2011

1 commit


13 May, 2011

1 commit

  • When p9pdu_readf() is called with "s" attribute, it allocates a pointer that
    will store a string. In p9dirent_read(), this pointer is not being released,
    leading to out of memory errors.
    This patch releases this pointer after string is copyed to dirent->d_name.

    Signed-off-by: Pedro Scarapicchia Junior
    Signed-off-by: Eric Van Hensbergen

    Pedro Scarapicchia Junior
     

16 Apr, 2011

2 commits


23 Mar, 2011

1 commit

  • Without this we can cause reclaim allocation in writepage.

    [ 3433.448430] =================================
    [ 3433.449117] [ INFO: inconsistent lock state ]
    [ 3433.449117] 2.6.38-rc5+ #84
    [ 3433.449117] ---------------------------------
    [ 3433.449117] inconsistent {RECLAIM_FS-ON-W} -> {IN-RECLAIM_FS-R} usage.
    [ 3433.449117] kswapd0/505 [HC0[0]:SC0[0]:HE1:SE1] takes:
    [ 3433.449117] (iprune_sem){+++++-}, at: [] shrink_icache_memory+0x45/0x2b1
    [ 3433.449117] {RECLAIM_FS-ON-W} state was registered at:
    [ 3433.449117] [] mark_held_locks+0x52/0x70
    [ 3433.449117] [] lockdep_trace_alloc+0x85/0x9f
    [ 3433.449117] [] slab_pre_alloc_hook+0x18/0x3c
    [ 3433.449117] [] kmem_cache_alloc+0x23/0xa2
    [ 3433.449117] [] idr_pre_get+0x2d/0x6f
    [ 3433.449117] [] p9_idpool_get+0x30/0xae
    [ 3433.449117] [] p9_client_rpc+0xd7/0x9b0
    [ 3433.449117] [] p9_client_clunk+0x88/0xdb
    [ 3433.449117] [] v9fs_evict_inode+0x3c/0x48
    [ 3433.449117] [] evict+0x1f/0x87
    [ 3433.449117] [] dispose_list+0x47/0xe3
    [ 3433.449117] [] evict_inodes+0x138/0x14f
    [ 3433.449117] [] generic_shutdown_super+0x57/0xe8
    [ 3433.449117] [] kill_anon_super+0x11/0x50
    [ 3433.449117] [] v9fs_kill_super+0x49/0xab
    [ 3433.449117] [] deactivate_locked_super+0x21/0x46
    [ 3433.449117] [] deactivate_super+0x40/0x44
    [ 3433.449117] [] mntput_no_expire+0x100/0x109
    [ 3433.449117] [] sys_umount+0x2f1/0x31c
    [ 3433.449117] [] system_call_fastpath+0x16/0x1b
    [ 3433.449117] irq event stamp: 192941
    [ 3433.449117] hardirqs last enabled at (192941): [] _raw_spin_unlock_irq+0x2b/0x30
    [ 3433.449117] hardirqs last disabled at (192940): [] shrink_inactive_list+0x290/0x2f5
    [ 3433.449117] softirqs last enabled at (188470): [] __do_softirq+0x133/0x152
    [ 3433.449117] softirqs last disabled at (188455): [] call_softirq+0x1c/0x28
    [ 3433.449117]
    [ 3433.449117] other info that might help us debug this:
    [ 3433.449117] 1 lock held by kswapd0/505:
    [ 3433.449117] #0: (shrinker_rwsem){++++..}, at: [] shrink_slab+0x38/0x15f
    [ 3433.449117]
    [ 3433.449117] stack backtrace:
    [ 3433.449117] Pid: 505, comm: kswapd0 Not tainted 2.6.38-rc5+ #84
    [ 3433.449117] Call Trace:
    [ 3433.449117] [] ? valid_state+0x17e/0x191
    [ 3433.449117] [] ? save_stack_trace+0x28/0x45
    [ 3433.449117] [] ? check_usage_forwards+0x0/0x87
    [ 3433.449117] [] ? mark_lock+0x113/0x22c
    [ 3433.449117] [] ? __lock_acquire+0x37a/0xcf7
    [ 3433.449117] [] ? mark_lock+0x2d/0x22c
    [ 3433.449117] [] ? __lock_acquire+0x392/0xcf7
    [ 3433.449117] [] ? determine_dirtyable_memory+0x15/0x28
    [ 3433.449117] [] ? lock_acquire+0x57/0x6d
    [ 3433.449117] [] ? shrink_icache_memory+0x45/0x2b1
    [ 3433.449117] [] ? down_read+0x47/0x5c
    [ 3433.449117] [] ? shrink_icache_memory+0x45/0x2b1
    [ 3433.449117] [] ? shrink_icache_memory+0x45/0x2b1
    [ 3433.449117] [] ? shrink_slab+0xdb/0x15f
    [ 3433.449117] [] ? kswapd+0x574/0x96a
    [ 3433.449117] [] ? kswapd+0x0/0x96a
    [ 3433.449117] [] ? kthread+0x7d/0x85
    [ 3433.449117] [] ? kernel_thread_helper+0x4/0x10
    [ 3433.449117] [] ? restore_args+0x0/0x30
    [ 3433.449117] [] ? kthread+0x0/0x85
    [ 3433.449117] [] ? kernel_thread_helper+0x0/0x10

    Signed-off-by: Aneesh Kumar K.V
    Signed-off-by: Venkateswararao Jujjuri
    Signed-off-by: Eric Van Hensbergen

    Aneesh Kumar K.V
     

15 Mar, 2011

4 commits


11 Jan, 2011

1 commit

  • Use proper data types for storing the count of the binary blob and
    length of a string. Without this patch length calculation of string will
    always result in -1 because of comparision between signed and unsigned
    integer.

    Signed-off-by: M. Mohan Kumar
    Signed-off-by: Venkateswararao Jujjuri
    Signed-off-by: Eric Van Hensbergen

    M. Mohan Kumar
     

09 Dec, 2010

1 commit


28 Oct, 2010

1 commit


03 Aug, 2010

3 commits

  • SYNOPSIS

    size[4] Tsetattr tag[2] attr[n]

    size[4] Rsetattr tag[2]

    DESCRIPTION

    The setattr command changes some of the file status information.
    attr resembles the iattr structure used in Linux kernel. It
    specifies which status parameter is to be changed and to what
    value. It is laid out as follows:

    valid[4]
    specifies which status information is to be changed. Possible
    values are:
    ATTR_MODE (1 << 0)
    ATTR_UID (1 << 1)
    ATTR_GID (1 << 2)
    ATTR_SIZE (1 << 3)
    ATTR_ATIME (1 << 4)
    ATTR_MTIME (1 << 5)
    ATTR_ATIME_SET (1 << 7)
    ATTR_MTIME_SET (1 << 8)

    The last two bits represent whether the time information
    is being sent by the client's user space. In the absense
    of these bits the server always uses server's time.

    mode[4]
    File permission bits

    uid[4]
    Owner id of file

    gid[4]
    Group id of the file

    size[8]
    File size

    atime_sec[8]
    Time of last file access, seconds

    atime_nsec[8]
    Time of last file access, nanoseconds

    mtime_sec[8]
    Time of last file modification, seconds

    mtime_nsec[8]
    Time of last file modification, nanoseconds

    Explanation of the patches:
    --------------------------

    *) The kernel just copies relevent contents of iattr structure to
    p9_iattr_dotl structure and passes it down to the client. The
    only check it has is calling inode_change_ok()
    *) The p9_iattr_dotl structure does not have ctime and ia_file
    parameters because I don't think these are needed in our case.
    The client user space can request updating just ctime by calling
    chown(fd, -1, -1). This is handled on server side without a need
    for putting ctime on the wire.
    *) The server currently supports changing mode, time, ownership and
    size of the file.
    *) 9P RFC says "Either all the changes in wstat request happen, or
    none of them does: if the request succeeds, all changes were made;
    if it fails, none were."
    I have not done anything to implement this specifically because I
    don't see a reason.

    Signed-off-by: Sripathi Kodi
    Signed-off-by: Venkateswararao Jujjuri
    Signed-off-by: Eric Van Hensbergen

    Sripathi Kodi
     
  • SYNOPSIS

    size[4] Tgetattr tag[2] fid[4] request_mask[8]

    size[4] Rgetattr tag[2] lstat[n]

    DESCRIPTION

    The getattr transaction inquires about the file identified by fid.
    request_mask is a bit mask that specifies which fields of the
    stat structure is the client interested in.

    The reply will contain a machine-independent directory entry,
    laid out as follows:

    st_result_mask[8]
    Bit mask that indicates which fields in the stat structure
    have been populated by the server

    qid.type[1]
    the type of the file (directory, etc.), represented as a bit
    vector corresponding to the high 8 bits of the file's mode
    word.

    qid.vers[4]
    version number for given path

    qid.path[8]
    the file server's unique identification for the file

    st_mode[4]
    Permission and flags

    st_uid[4]
    User id of owner

    st_gid[4]
    Group ID of owner

    st_nlink[8]
    Number of hard links

    st_rdev[8]
    Device ID (if special file)

    st_size[8]
    Size, in bytes

    st_blksize[8]
    Block size for file system IO

    st_blocks[8]
    Number of file system blocks allocated

    st_atime_sec[8]
    Time of last access, seconds

    st_atime_nsec[8]
    Time of last access, nanoseconds

    st_mtime_sec[8]
    Time of last modification, seconds

    st_mtime_nsec[8]
    Time of last modification, nanoseconds

    st_ctime_sec[8]
    Time of last status change, seconds

    st_ctime_nsec[8]
    Time of last status change, nanoseconds

    st_btime_sec[8]
    Time of creation (birth) of file, seconds

    st_btime_nsec[8]
    Time of creation (birth) of file, nanoseconds

    st_gen[8]
    Inode generation

    st_data_version[8]
    Data version number

    request_mask and result_mask bit masks contain the following bits
    #define P9_STATS_MODE 0x00000001ULL
    #define P9_STATS_NLINK 0x00000002ULL
    #define P9_STATS_UID 0x00000004ULL
    #define P9_STATS_GID 0x00000008ULL
    #define P9_STATS_RDEV 0x00000010ULL
    #define P9_STATS_ATIME 0x00000020ULL
    #define P9_STATS_MTIME 0x00000040ULL
    #define P9_STATS_CTIME 0x00000080ULL
    #define P9_STATS_INO 0x00000100ULL
    #define P9_STATS_SIZE 0x00000200ULL
    #define P9_STATS_BLOCKS 0x00000400ULL

    #define P9_STATS_BTIME 0x00000800ULL
    #define P9_STATS_GEN 0x00001000ULL
    #define P9_STATS_DATA_VERSION 0x00002000ULL

    #define P9_STATS_BASIC 0x000007ffULL
    #define P9_STATS_ALL 0x00003fffULL

    This patch implements the client side of getattr implementation for
    9P2000.L. It introduces a new structure p9_stat_dotl for getting
    Linux stat information along with QID. The data layout is similar to
    stat structure in Linux user space with the following major
    differences:

    inode (st_ino) is not part of data. Instead qid is.

    device (st_dev) is not part of data because this doesn't make sense
    on the client.

    All time variables are 64 bit wide on the wire. The kernel seems to use
    32 bit variables for these variables. However, some of the architectures
    have used 64 bit variables and glibc exposes 64 bit variables to user
    space on some architectures. Hence to be on the safer side we have made
    these 64 bit in the protocol. Refer to the comments in
    include/asm-generic/stat.h

    There are some additional fields: st_btime_sec, st_btime_nsec, st_gen,
    st_data_version apart from the bitmask, st_result_mask. The bit mask
    is filled by the server to indicate which stat fields have been
    populated by the server. Currently there is no clean way for the
    server to obtain these additional fields, so it sends back just the
    basic fields.

    Signed-off-by: Sripathi Kodi
    Signed-off-by: Eric Van Hensbegren

    Sripathi Kodi
     
  • This patch implements the kernel part of readdir() implementation for 9p2000.L

    Change from V3: Instead of inode, server now sends qids for each dirent

    SYNOPSIS

    size[4] Treaddir tag[2] fid[4] offset[8] count[4]
    size[4] Rreaddir tag[2] count[4] data[count]

    DESCRIPTION

    The readdir request asks the server to read the directory specified by 'fid'
    at an offset specified by 'offset' and return as many dirent structures as
    possible that fit into count bytes. Each dirent structure is laid out as
    follows.

    qid.type[1]
    the type of the file (directory, etc.), represented as a bit
    vector corresponding to the high 8 bits of the file's mode
    word.

    qid.vers[4]
    version number for given path

    qid.path[8]
    the file server's unique identification for the file

    offset[8]
    offset into the next dirent.

    type[1]
    type of this directory entry.

    name[256]
    name of this directory entry.

    This patch adds v9fs_dir_readdir_dotl() as the readdir() call for 9p2000.L.
    This function sends P9_TREADDIR command to the server. In response the server
    sends a buffer filled with dirent structures. This is different from the
    existing v9fs_dir_readdir() call which receives stat structures from the server.
    This results in significant speedup of readdir() on large directories.
    For example, doing 'ls >/dev/null' on a directory with 10000 files on my
    laptop takes 1.088 seconds with the existing code, but only takes 0.339 seconds
    with the new readdir.

    Signed-off-by: Sripathi Kodi
    Reviewed-by: Aneesh Kumar K.V
    Signed-off-by: Eric Van Hensbergen

    Sripathi Kodi
     

25 May, 2010

1 commit


22 May, 2010

1 commit


30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

06 Mar, 2010

1 commit


07 Feb, 2009

1 commit

  • When the changes were done to the protocol last release, some endian
    bugs crept in. This patch fixes those endian problems and has been
    verified to run on 32/64 bit and x86/ppc architectures.

    This version of the patch incorporates the correct annotations
    for endian variables.

    Signed-off-by: Eric Van Hensbergen
    Signed-off-by: David S. Miller

    Eric Van Hensbergen
     

23 Oct, 2008

2 commits


18 Oct, 2008

2 commits