20 Oct, 2011

2 commits

  • CIFS currently uses wait_event_killable to put tasks to sleep while
    they await replies from the server. That function though does not
    allow the freezer to run. In many cases, the network interface may
    be going down anyway, in which case the reply will never come. The
    client then ends up blocking the computer from suspending.

    Fix this by adding a new wait_event_freezable variant --
    wait_event_freezekillable. The idea is to combine the behavior of
    wait_event_killable and wait_event_freezable -- put the task to
    sleep and only allow it to be awoken by fatal signals, but also
    allow the freezer to do its job.

    Signed-off-by: Jeff Layton

    Jeff Layton
     
  • In order to handle larger SMBs for readpages and other calls, we want
    to be able to read into a preallocated set of buffers. Rather than
    changing all of the existing code to preallocate buffers however, we
    instead add a receive callback function to the MID.

    cifsd will call this function once the mid_q_entry has been identified
    in order to receive the rest of the SMB. If the mid can't be identified
    or the receive pointer is unset, then the standard 3rd phase receive
    function will be called.

    Reviewed-and-Tested-by: Pavel Shilovsky
    Signed-off-by: Jeff Layton

    Jeff Layton
     

13 Oct, 2011

1 commit

  • We have two versions of signature generating code. A vectorized and
    non-vectorized version. Eliminate a large chunk of cut-and-paste
    code by turning the non-vectorized version into a wrapper around the
    vectorized one.

    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     

12 Aug, 2011

1 commit

  • Christoph had requested that the stats related code (in
    CONFIG_CIFS_STATS2) be moved into helpers to make code flow more
    readable. This patch should help. For example the following
    section from transport.c

    spin_unlock(&GlobalMid_Lock);
    atomic_inc(&ses->server->num_waiters);
    wait_event(ses->server->request_q,
    atomic_read(&ses->server->inFlight)
    < cifs_max_pending);
    atomic_dec(&ses->server->num_waiters);
    spin_lock(&GlobalMid_Lock);

    becomes simpler (with the patch below):
    spin_unlock(&GlobalMid_Lock);
    cifs_num_waiters_inc(server);
    wait_event(server->request_q,
    atomic_read(&server->inFlight)
    < cifs_max_pending);
    cifs_num_waiters_dec(server);
    spin_lock(&GlobalMid_Lock);

    Reviewed-by: Jeff Layton
    CC: Christoph Hellwig
    Signed-off-by: Steve French
    Reviewed-by: Pavel Shilovsky

    Steve French
     

04 Aug, 2011

1 commit


27 May, 2011

1 commit


24 May, 2011

1 commit

  • Minor revision to the last version of this patch -- the only difference
    is the fix to the cFYI statement in cifs_reconnect.

    Holding the spinlock while we call this function means that it can't
    sleep, which really limits what it can do. Taking it out from under
    the spinlock also means less contention for this global lock.

    Change the semantics such that the Global_MidLock is not held when
    the callback is called. To do this requires that we take extra care
    not to have sync_mid_result remove the mid from the list when the
    mid is in a state where that has already happened. This prevents
    list corruption when the mid is sitting on a private list for
    reconnect or when cifsd is coming down.

    Reviewed-by: Shirish Pargaonkar
    Reviewed-by: Pavel Shilovsky
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     

23 May, 2011

3 commits

  • The current code always ignores the max_pending limit. Have it instead
    only optionally ignore the pending limit. For CIFSSMBEcho, we need to
    ignore it to make sure they always can go out. For async reads, writes
    and potentially other calls, we need to respect it.

    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     
  • We'll need this for async writes, so convert the call to take a kvec
    array. CIFSSMBEcho is changed to put a kvec on the stack and pass
    in the SMB buffer using that.

    Reviewed-by: Pavel Shilovsky
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     
  • Further consolidate the SendReceive code by moving the checks run over
    the packet into a separate function that all the SendReceive variants
    can call.

    We can also eliminate the check for a receive_len that's too big or too
    small. cifs_demultiplex_thread already checks that and disconnects the
    socket if that occurs, while setting the midStatus to MALFORMED. It'll
    never call this code if that's the case.

    Finally do a little cleanup. Use "goto out" on errors so that the flow
    of code in the normal case is more evident. Also switch the logErr
    variable in map_smb_to_linux_error to a bool.

    Reviewed-by: Pavel Shilovsky
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     

19 May, 2011

2 commits

  • This is the same patch as originally posted, just with some merge
    conflicts fixed up...

    Currently, the ByteCount is usually converted to host-endian on receive.
    This is confusing however, as we need to keep two sets of routines for
    accessing it, and keep track of when to use each routine. Munging
    received packets like this also limits when the signature can be
    calulated.

    Simplify the code by keeping the received ByteCount in little-endian
    format. This allows us to eliminate a set of routines for accessing it
    and we can now drop the *_le suffixes from the accessor functions since
    that's now implied.

    While we're at it, switch all of the places that read the ByteCount
    directly to use the get_bcc inline which should also clean up some
    unaligned accesses.

    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     
  • There is one big endian field in the cifs protocol, the RFC1001
    length, which cifs code (unlike in the smb2 code) had been handling as
    u32 until the last possible moment, when it was converted to be32 (its
    native form) before sending on the wire. To remove the last sparse
    endian warning, and to make this consistent with the smb2
    implementation (which always treats the fields in their
    native size and endianness), convert all uses of smb_buf_length to
    be32.

    This version incorporates Christoph's comment about
    using be32_add_cpu, and fixes a typo in the second
    version of the patch.

    Signed-off-by: Steve French
    Signed-off-by: Pavel Shilovsky
    Signed-off-by: Steve French

    Steve French
     

11 Feb, 2011

1 commit

  • Slight revision to this patch...use min_t() instead of conditional
    assignment. Also, remove the FIXME comment and replace it with the
    explanation that Steve gave earlier.

    After receiving a packet, we currently check the header. If it's no
    good, then we toss it out and continue the loop, leaving the caller
    waiting on that response.

    In cases where the packet has length inconsistencies, but the MID is
    valid, this leads to unneeded delays. That's especially problematic now
    that the client waits indefinitely for responses.

    Instead, don't immediately discard the packet if checkSMB fails. Try to
    find a matching mid_q_entry, mark it as having a malformed response and
    issue the callback.

    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     

05 Feb, 2011

1 commit


31 Jan, 2011

3 commits

  • If we kill the process while it's sending on a socket then the
    kernel_sendmsg will return -EINTR. This is normal. No need to spam the
    ring buffer with this info.

    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     
  • Use the new send_nt_cancel function to send an NT_CANCEL when the
    process is delivered a fatal signal. This is a "best effort" enterprise
    however, so don't bother to check the return code. There's nothing we
    can reasonably do if it fails anyway.

    Reviewed-by: Pavel Shilovsky
    Reviewed-by: Suresh Jayaraman
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     
  • Currently, when a request is cancelled via signal, we delete the mid
    immediately. If the request was already transmitted however, the client
    is still likely to receive a response. When it does, it won't recognize
    it however and will pop a printk.

    It's also a little dangerous to just delete the mid entry like this. We
    may end up reusing that mid. If we do then we could potentially get the
    response from the first request confused with the later one.

    Prevent the reuse of mids by marking them as cancelled and keeping them
    on the pending_mid_q list. If the reply comes in, we'll delete it from
    the list then. If it never comes, then we'll delete it at reconnect
    or when cifsd comes down.

    Reviewed-by: Pavel Shilovsky
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     

21 Jan, 2011

9 commits

  • It's possible that when we access the ByteCount that the alignment
    will be off. Most CPUs deal with that transparently, but there's
    usually some performance impact. Some CPUs raise an exception on
    unaligned accesses.

    Fix this by accessing the byte count using the get_unaligned and
    put_unaligned inlined functions. While we're at it, fix the types
    of some of the variables that end up getting returns from these
    functions.

    Acked-by: Pavel Shilovsky
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     
  • The NT_CANCEL command looks just like the original command, except for a
    few small differences. The send_nt_cancel function however currently takes
    a tcon, which we don't have in SendReceive and SendReceive2.

    Instead of "respinning" the entire header for an NT_CANCEL, just mangle
    the existing header by replacing just the fields we need. This means we
    don't need a tcon and allows us to call it from other places.

    Reviewed-by: Pavel Shilovsky
    Reviewed-by: Suresh Jayaraman
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     
  • Since we don't time out individual requests anymore, remove the code
    that we used to use for setting timeouts on different requests.

    Reviewed-by: Pavel Shilovsky
    Reviewed-by: Suresh Jayaraman
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     
  • Reviewed-by: Suresh Jayaraman
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     
  • Add a function that will send a request, and set up the mid for an
    async reply.

    Reviewed-by: Suresh Jayaraman
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     
  • In order to incorporate async requests, we need to allow for a more
    general way to do things on receive, rather than just waking up a
    process.

    Turn the task pointer in the mid_q_entry into a callback function and a
    generic data pointer. When a response comes in, or the socket is
    reconnected, cifsd can call the callback function in order to wake up
    the process.

    The default is to just wake up the current process which should mean no
    change in behavior for existing code.

    Also, clean up the locking in cifs_reconnect. There doesn't seem to be
    any need to hold both the srv_mutex and GlobalMid_Lock when walking the
    list of mids.

    Reviewed-by: Suresh Jayaraman
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     
  • Make it use a switch statement based on the value of the midStatus. If
    the resp_buf is set, then MID_RESPONSE_RECEIVED is too.

    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     
  • We only want to force a reconnect to the server under very limited and
    specific circumstances. Now that we have processes waiting indefinitely
    for responses, we shouldn't reach this point unless a reconnect is
    already in process. Thus, there's no reason to re-mark the server for
    reconnect here.

    Reviewed-by: Suresh Jayaraman
    Reviewed-by: Pavel Shilovsky
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     
  • The client should not be timing out on individual SMB requests. Too much
    of the state between client and server is tied to the state of the
    socket. If we time out requests and issue spurious disconnects then that
    comprimises data integrity.

    Instead of doing this complicated dance where we try to decide how long
    to wait for a response for particular requests, have the client instead
    wait indefinitely for a response. Also, use a TASK_KILLABLE sleep here
    so that fatal signals will break out of this waiting.

    Later patches will add support for detecting dead peers and forcing
    reconnects based on that.

    Reviewed-by: Suresh Jayaraman
    Reviewed-by: Pavel Shilovsky
    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     

20 Jan, 2011

4 commits


07 Jan, 2011

1 commit


27 Oct, 2010

1 commit

  • Start calculating auth response within a session. Move/Add pertinet
    data structures like session key, server challenge and ntlmv2_hash in
    a session structure. We should do the calculations within a session
    before copying session key and response over to server data
    structures because a session setup can fail.

    Only after a very first smb session succeeds, it copy/make its
    session key, session key of smb connection. This key stays with
    the smb connection throughout its life.
    sequence_number within server is set to 0x2.

    The authentication Message Authentication Key (mak) which consists
    of session key followed by client response within structure session_key
    is now dynamic. Every authentication type allocates the key + response
    sized memory within its session structure and later either assigns or
    frees it once the client response is sent and if session's session key
    becomes connetion's session key.

    ntlm/ntlmi authentication functions are rearranged. A function
    named setup_ntlm_resp(), similar to setup_ntlmv2_resp(), replaces
    function cifs_calculate_session_key().

    size of CIFS_SESS_KEY_SIZE is changed to 16, to reflect the byte size
    of the key it holds.

    Reviewed-by: Jeff Layton
    Signed-off-by: Shirish Pargaonkar
    Signed-off-by: Steve French

    Shirish Pargaonkar
     

30 Sep, 2010

1 commit


09 Sep, 2010

1 commit

  • This reverts commit 9fbc590860e75785bdaf8b83e48fabfe4d4f7d58.

    The change to kernel crypto and fixes to ntlvm2 and ntlmssp
    series, introduced a regression. Deferring this patch series
    to 2.6.37 after Shirish fixes it.

    Signed-off-by: Steve French
    Acked-by: Jeff Layton
    CC: Shirish Pargaonkar

    Steve French
     

21 Aug, 2010

1 commit

  • Make ntlmv2 as an authentication mechanism within ntlmssp
    instead of ntlmv1.
    Parse type 2 response in ntlmssp negotiation to pluck
    AV pairs and use them to calculate ntlmv2 response token.
    Also, assign domain name from the sever response in type 2
    packet of ntlmssp and use that (netbios) domain name in
    calculation of response.

    Enable cifs/smb signing using rc4 and md5.

    Changed name of the structure mac_key to session_key to reflect
    the type of key it holds.

    Use kernel crypto_shash_* APIs instead of the equivalent cifs functions.

    Signed-off-by: Shirish Pargaonkar
    Acked-by: Herbert Xu
    Signed-off-by: Steve French

    Steve French
     

06 May, 2010

1 commit


21 Apr, 2010

1 commit

  • Neaten cERROR and cFYI macros, reduce text space
    ~2.5K

    Convert '__FILE__ ": " fmt' to '"%s: " fmt', __FILE__' to save text space
    Surround macros with do {} while
    Add parentheses to macros
    Make statement expression macro from macro with assign
    Remove now unnecessary parentheses from cFYI and cERROR uses

    defconfig with CIFS support old
    $ size fs/cifs/built-in.o
    text data bss dec hex filename
    156012 1760 148 157920 268e0 fs/cifs/built-in.o

    defconfig with CIFS support old
    $ size fs/cifs/built-in.o
    text data bss dec hex filename
    153508 1760 148 155416 25f18 fs/cifs/built-in.o

    allyesconfig old:
    $ size fs/cifs/built-in.o
    text data bss dec hex filename
    309138 3864 74824 387826 5eaf2 fs/cifs/built-in.o

    allyesconfig new
    $ size fs/cifs/built-in.o
    text data bss dec hex filename
    305655 3864 74824 384343 5dd57 fs/cifs/built-in.o

    Signed-off-by: Joe Perches
    Signed-off-by: Steve French

    Joe Perches
     

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
     

25 Sep, 2009

1 commit

  • This is the fourth respin of the patch to convert oplock breaks to
    use the slow_work facility.

    A customer of ours was testing a backport of one of the earlier
    patchsets, and hit a "Busy inodes after umount..." problem. An oplock
    break job had raced with a umount, and the superblock got torn down and
    its memory reused. When the oplock break job tried to dereference the
    inode->i_sb, the kernel oopsed.

    This patchset has the oplock break job hold an inode and vfsmount
    reference until the oplock break completes. With this, there should be
    no need to take a tcon reference (the vfsmount implicitly holds one
    already).

    Currently, when an oplock break comes in there's a chance that the
    oplock break job won't occur if the allocation of the oplock_q_entry
    fails. There are also some rather nasty races in the allocation and
    handling these structs.

    Rather than allocating oplock queue entries when an oplock break comes
    in, add a few extra fields to the cifsFileInfo struct. Get rid of the
    dedicated cifs_oplock_thread as well and queue the oplock break job to
    the slow_work thread pool.

    This approach also has the advantage that the oplock break jobs can
    potentially run in parallel rather than be serialized like they are
    today.

    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton
     

02 Sep, 2009

1 commit

  • Right now, the GlobalOplock_Q is protected by the GlobalMid_Lock. That
    lock is also used for completely unrelated purposes (mostly for managing
    the global mid queue). Give the list its own dedicated spinlock
    (cifs_oplock_lock) and rename the list to cifs_oplock_list to
    eliminate the camel-case.

    Signed-off-by: Jeff Layton
    Signed-off-by: Steve French

    Jeff Layton