From: Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
To: Pavel Shilovsky <piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Steve French <sfrench-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH v2 05/53] CIFS: wait_for_free_request needs to wait on credits returned by server (for SMB2)
Date: Sat, 29 Oct 2011 22:41:47 -0400 [thread overview]
Message-ID: <20111029224147.4cc321f7@corrin.poochiereds.net> (raw)
In-Reply-To: <CAKywueSGDSw33L4_a7W6D7gM_PH9uy3xTQ6=8zgAimGhz5=UfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Sun, 30 Oct 2011 00:00:15 +0400
Pavel Shilovsky <piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org> wrote:
> 2011/10/29 Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>:
> > On Fri, 28 Oct 2011 23:54:16 +0400
> > Pavel Shilovsky <piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org> wrote:
> >
> >> From: Steve French <sfrench-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> >>
> >> wait_for_free_request is called to ensure that we don't have more than the
> >> configured maximum of requests in flight on the wire (for cifs), but for SMB2,
> >> the number of requests that can be in flight varies dynamically (the client
> >> may request that the server grant more "credits" in a request, and each
> >> request uses at least one credit). Instead of migrating over the original
> >> smb2_wait_for_free_request function, simply add a check in cifs's original
> >> wait_for_free_request for the is_smb2 case to make sure that we don't go
> >> beyond the number of allocated "credits" (ie those that remain from those
> >> the server has allocated for this tcp session). Otherwise the logic is unchanged
> >> (other than to make it extern so that the next function to be added, smb2_sendrcv2
> >> in smbtransport.c can call it - smb2_sendrcv2 will be migrated over in the next patch).
> >>
> >> Note that smb2 servers will typically allow many more requests in flight at one time
> >> than cifs servers (which usually default to only 50) and can adjust this as needed.
> >> This should provide significant performance benefit in some workloads (ie smb2
> >> in many cases will get more parallelism than cifs and some other protocols
> >> since some artificially constrain the maximum number of requests).
> >>
> >> Signed-off-by: Steve French <sfrench-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> >> Signed-off-by: Pavel Shilovsky <piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
> >> ---
> >> fs/cifs/cifsglob.h | 1 +
> >> fs/cifs/cifsproto.h | 3 ++-
> >> fs/cifs/transport.c | 22 +++++++++++++++++++---
> >> 3 files changed, 22 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
> >> index 179b784..b440329 100644
> >> --- a/fs/cifs/cifsglob.h
> >> +++ b/fs/cifs/cifsglob.h
> >> @@ -311,6 +311,7 @@ struct TCP_Server_Info {
> >> wait_queue_head_t read_q; /* used by readpages */
> >> atomic_t active_readpage_req; /* used by readpages */
> >> atomic_t resp_rdy; /* used by readpages and demultiplex */
> >> + atomic_t credits; /* send no more simultaneous requests than this */
> >> __le16 smb2_dialect_revision; /* SMB2.0 implemented, 2.1 recognized */
> >> struct task_struct *observe;
> >> char smb2_crypt_key[CIFS_CRYPTO_KEY_SIZE]; /* BB can we use cifs key */
> >> diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
> >> index ef4f631..84d1e4c 100644
> >> --- a/fs/cifs/cifsproto.h
> >> +++ b/fs/cifs/cifsproto.h
> >> @@ -1,7 +1,7 @@
> >> /*
> >> * fs/cifs/cifsproto.h
> >> *
> >> - * Copyright (c) International Business Machines Corp., 2002,2008
> >> + * Copyright (c) International Business Machines Corp., 2002,2011
> >> * Author(s): Steve French (sfrench-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org)
> >> *
> >> * This library is free software; you can redistribute it and/or modify
> >> @@ -68,6 +68,7 @@ extern char *cifs_compose_mount_options(const char *sb_mountdata,
> >> extern struct mid_q_entry *AllocMidQEntry(const struct smb_hdr *smb_buffer,
> >> struct TCP_Server_Info *server);
> >> extern void DeleteMidQEntry(struct mid_q_entry *midEntry);
> >> +extern int wait_for_free_request(struct TCP_Server_Info *sv, const int long_op);
> >> extern int cifs_call_async(struct TCP_Server_Info *server, struct kvec *iov,
> >> unsigned int nvec, mid_receive_t *receive,
> >> mid_callback_t *callback, void *cbdata,
> >> diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
> >> index 0cc9584..25d04df 100644
> >> --- a/fs/cifs/transport.c
> >> +++ b/fs/cifs/transport.c
> >> @@ -254,7 +254,7 @@ smb_send(struct TCP_Server_Info *server, struct smb_hdr *smb_buffer,
> >> return smb_sendv(server, &iov, 1);
> >> }
> >>
> >> -static int wait_for_free_request(struct TCP_Server_Info *server,
> >> +int wait_for_free_request(struct TCP_Server_Info *server,
> >> const int long_op)
> >> {
> >> if (long_op == CIFS_ASYNC_OP) {
> >> @@ -265,7 +265,8 @@ static int wait_for_free_request(struct TCP_Server_Info *server,
> >>
> >> spin_lock(&GlobalMid_Lock);
> >> while (1) {
> >> - if (atomic_read(&server->inFlight) >= cifs_max_pending) {
> >> + if ((server->is_smb2 == false) &&
> >> + atomic_read(&server->inFlight) >= cifs_max_pending) {
> >> spin_unlock(&GlobalMid_Lock);
> >> cifs_num_waiters_inc(server);
> >> wait_event(server->request_q,
> >> @@ -273,6 +274,16 @@ static int wait_for_free_request(struct TCP_Server_Info *server,
> >> < cifs_max_pending);
> >> cifs_num_waiters_dec(server);
> >> spin_lock(&GlobalMid_Lock);
> >> +#ifdef CONFIG_CIFS_SMB2
> >> + } else if (server->is_smb2 &&
> >> + (atomic_read(&server->credits) < 1)) {
> >> + spin_unlock(&GlobalMid_Lock);
> >> + cifs_num_waiters_inc(server);
> >> + wait_event(server->request_q,
> >> + atomic_read(&server->credits) > 0);
> >> + cifs_num_waiters_dec(server);
> >> + spin_lock(&GlobalMid_Lock);
> >> +#endif /* CONFIG_CIFS_SMB2 */
> >> } else {
> >> if (server->tcpStatus == CifsExiting) {
> >> spin_unlock(&GlobalMid_Lock);
> >> @@ -283,8 +294,13 @@ static int wait_for_free_request(struct TCP_Server_Info *server,
> >> as they are allowed to block on server */
> >>
> >> /* update # of requests on the wire to server */
> >> - if (long_op != CIFS_BLOCKING_OP)
> >> + if (server->is_smb2 == false &&
> >> + long_op != CIFS_BLOCKING_OP)
> >> atomic_inc(&server->inFlight);
> >> +#ifdef CONFIG_CIFS_SMB2
> >> + else if (server->is_smb2)
> >> + atomic_dec(&server->credits);
> >> +#endif
> >> spin_unlock(&GlobalMid_Lock);
> >> break;
> >> }
> >
> > This patch doesn't make much sense...
> >
> > "credits" gets initialized to 0, then on the first request, you'll
> > decrement it which will make it go negative. I then don't see any place
> > where credits is ever incremented.
> >
> > Maybe that happens in a different patch, but splitting your patches out
> > this way makes no sense. No one can reasonably review this patch for
> > sanity since the lifecycle of "credits" is incomplete.
>
> In this case we should move this patch after we add smb2_sendrcv
> function (where credits are increased). Make sense?
>
I haven't gotten that far in the series yet, so I'm not sure if that
makes sense or not. That's the problem: we as reviewers can't review
this set as a whole. Most of us don't have brains that big. We have to
review these patches a set of individual changes that are working
toward a goal.
I think what you need to do is to figure out a way to break the
patchset up more logically. One would think that doing that would be a
set of steps that you could follow, but it's really more of an art. You
have to look at this from the viewpoint of potential reviewers.
A large patchset like this needs to have a clear "flow" that evolves
the code incrementally. Cleanups or other changes that make sense on
their own should usually be broken out and done first, and often in a
separate set. Further patches should make a set of logically complete
changes to the code.
A case in point: when I did the patchset to clean up the demultiplex
codepath, I added code to kmalloc a buffer on each pass through
readv_from_socket. In the next patch, I ripped that kmalloc back out
and added code to keep a reusable buffer for that purpose.
I could have done that in a different way that didn't "churn" the code
so much, but it made more sense to do it that way for a reviewer walking
the patches in order. Adding the new buffer management was logically
separate from the earlier change, so I broke the patches up along the
same lines.
Doing this also pays off later. It also allows for someone bisecting
the code to have a tree that reasonably works if they stop at that
point, and makes it easier to find bugs since the change is more
logical.
Sometimes it is necessary to have a patch that doesn't make a lot of
sense on its own in order to prepare for later patches. If you do that
though, you really need to have a commit message that explains what
you're doing and why.
--
Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>
next prev parent reply other threads:[~2011-10-30 2:41 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-28 19:54 [PATCH v2 00/53] SMB2 protocol support for CIFS kernel module Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 02/53] CIFS: Allow SMB2 statistics to be tracked Pavel Shilovsky
2011-10-29 4:48 ` Jeff Layton
2011-10-29 5:12 ` Steve French
[not found] ` <CAH2r5mtpckA75LEAynsPLVsPfr7U0wnYAyZ1uKeK2VU9F1CGeQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-10-29 5:32 ` Jeff Layton
[not found] ` <20111029004814.41340503-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2011-10-29 19:44 ` Pavel Shilovsky
[not found] ` <CAKywueQwBwR-HZtv6gQv32kt4+2qycS7vq5KDLiE3xw3_9=wPA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-10-30 2:12 ` Jeff Layton
[not found] ` <20111029221251.5fba1444-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2011-10-30 2:52 ` Steve French
2011-10-28 19:54 ` [PATCH v2 03/53] CIFS: Check for smb2 vs. cifs in find_tcp_session Pavel Shilovsky
[not found] ` <1319831704-3572-4-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2011-10-29 4:40 ` Jeff Layton
[not found] ` <20111029004046.2bf8e111-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2011-10-29 19:55 ` Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 05/53] CIFS: wait_for_free_request needs to wait on credits returned by server (for SMB2) Pavel Shilovsky
[not found] ` <1319831704-3572-6-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2011-10-29 15:35 ` Jeff Layton
2011-10-29 20:00 ` Pavel Shilovsky
[not found] ` <CAKywueSGDSw33L4_a7W6D7gM_PH9uy3xTQ6=8zgAimGhz5=UfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-10-30 2:41 ` Jeff Layton [this message]
2011-10-28 19:54 ` [PATCH v2 07/53] CIFS: Add structure definitions for SMB2 PDUs Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 09/53] CIFS: Allocating SMB2 mids (multiplex identifier structures) Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 15/53] CIFS: Make demultiplex_thread work with SMB2 code Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 16/53] CIFS: Get mount/umount work with SMB2 protocol Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 18/53] CIFS: Add SMB2 inode/dentry ops structures Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 19/53] CIFS: Add SMB2 support for mkdir operation Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 22/53] CIFS: Add SMB2 support for open/close file operations Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 23/53] CIFS: Add SMB2 support for reopen file operation Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 25/53] CIFS: Add SMB2 support for cifs_iovec_read Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 26/53] CIFS: Add address space ops structures for SMB2 Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 28/53] CIFS: Add write related address space operations " Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 30/53] CIFS: Temporarily disable set inode info " Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 31/53] CIFS: Add writepages support " Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 32/53] CIFS: Add readpages " Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 33/53] CIFS: Add echo request " Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 39/53] CIFS: Add SMB2 support for flush operation Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 42/53] CIFS: Process oplocks for SMB2 Pavel Shilovsky
[not found] ` <1319831704-3572-1-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2011-10-28 19:54 ` [PATCH v2 01/53] CIFS: Update cifs global structures to handle smb2 sessions Pavel Shilovsky
[not found] ` <1319831704-3572-2-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2011-10-29 4:54 ` Jeff Layton
2011-10-28 19:54 ` [PATCH v2 04/53] CIFS: Do not try to dump cifs mids from " Pavel Shilovsky
[not found] ` <1319831704-3572-5-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2011-10-29 5:05 ` Jeff Layton
2011-10-28 19:54 ` [PATCH v2 06/53] CIFS: Add missing unicode handling routines needed by smb2 Pavel Shilovsky
[not found] ` <1319831704-3572-7-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2011-11-01 10:12 ` Jeff Layton
2011-11-01 13:52 ` Shirish Pargaonkar
2011-12-29 15:01 ` Pavel Shilovsky
2011-12-30 12:42 ` Jeff Layton
2012-01-12 10:47 ` Pavel Shilovsky
2012-01-12 17:22 ` Shirish Pargaonkar
[not found] ` <CADT32eJ7FMkQZiy4LjeEG3axvt99N7jFEod7-u2js1MnhVkc7Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-01-12 18:42 ` Jeff Layton
2012-01-12 19:58 ` Shirish Pargaonkar
[not found] ` <CADT32eKc=Xq5G1cE+pye6h1dN6sjry+b7V0ze7CTMJXC8JCtwA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-01-12 20:48 ` Jeff Layton
2012-01-12 20:41 ` Shirish Pargaonkar
2011-10-28 19:54 ` [PATCH v2 10/53] CIFS: Add routines to free SMB2 mids Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 11/53] CIFS: Add sync_smb2_mid_result Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 13/53] CIFS: Add SMB2 transport routines Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 14/53] CIFS: Expand cifs mid structure to keep SMB2 related fields Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 17/53] CIFS: Simplify SMB2 query info Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 20/53] CIFS: Add SMB2 support for rmdir operation Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 21/53] CIFS: Add SMB2 support for unlink operation Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 24/53] CIFS: Add SMB2 support for cifs_iovec_write Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 27/53] CIFS: Add read related address space operations for SMB2 Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 29/53] CIFS: Respect max buf size for SMB2 read and write Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 34/53] [CIFS] Add SMB2 support for cifs_get_file_info Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 35/53] CIFS: Add SMB2 support for create operation Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 36/53] CIFS: Add readdir support for SMB2 Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 37/53] CIFS: Add SMB2 support for rename operation Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 38/53] CIFS: Add SMB2 support for hardlink operation Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 40/53] CIFS: Add NTLMSSP sec type to defaults Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 41/53] CIFS: Disable SMB2.1 protocol negotiating Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 43/53] CIFS: Process STATUS_PENDING responses for SMB2 Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 44/53] CIFS: Request SMB2.1 leases Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 45/53] CIFS: Process oplock/lease break for SMB2/2.1 Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 47/53] CIFS: Enable signing in SMB2 Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 48/53] CIFS: Process signing for SMB2_logoff Pavel Shilovsky
2011-10-28 19:55 ` [PATCH v2 49/53] CIFS: Introduce SMB2 Kconfig option Pavel Shilovsky
2011-10-28 19:55 ` [PATCH v2 50/53] CIFS: Introduce smb2 mounts as vers=2 Pavel Shilovsky
2011-10-28 19:55 ` [PATCH v2 53/53] CIFS: Disable lock call for SMB2 since we don't support it Pavel Shilovsky
2011-10-28 19:54 ` [PATCH v2 46/53] CIFS: Add strictcache i/o for SMB2 Pavel Shilovsky
2011-10-28 19:55 ` [PATCH v2 51/53] CIFS: Change Makefile to support CONFIG_CIFS_SMB2 Pavel Shilovsky
2011-10-28 19:55 ` [PATCH v2 52/53] CIFS: Add statfs support for SMB2 Pavel Shilovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111029224147.4cc321f7@corrin.poochiereds.net \
--to=jlayton-eunubhrolfbytjvyw6ydsg@public.gmane.org \
--cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org \
--cc=sfrench-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox