From: Christoph Hellwig <hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
To: Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/5] CIFS: Move buffer allocation to a separate function
Date: Fri, 24 Jun 2011 03:11:59 -0400 [thread overview]
Message-ID: <20110624071159.GA11901@infradead.org> (raw)
In-Reply-To: <1308898317-7667-2-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On Fri, Jun 24, 2011 at 10:51:53AM +0400, Pavel Shilovsky wrote:
> +static bool
> +allocate_buffers(char **pbigbuf, char **psmallbuf, unsigned int size,
> + bool isLargeBuf)
No p-prefixes for pointers, and no camelCase, please.
> +{
> + char *bigbuf = *pbigbuf, *smallbuf = *psmallbuf;
> +
> + if (bigbuf == NULL) {
> + bigbuf = (char *)cifs_buf_get();
> + if (!bigbuf) {
> + cERROR(1, "No memory for large SMB response");
> + msleep(3000);
> + /* retry will check if exiting */
> + return false;
> + }
> + } else if (isLargeBuf) {
> + /* we are reusing a dirty large buf, clear its start */
> + memset(bigbuf, 0, size);
> + }
> +
> + if (smallbuf == NULL) {
> + smallbuf = (char *)cifs_small_buf_get();
> + if (!smallbuf) {
> + cERROR(1, "No memory for SMB response");
> + msleep(1000);
> + /* retry will check if exiting */
> + return false;
> + }
> + /* beginning of smb buffer is cleared in our buf_get */
> + } else /* if existing small buf clear beginning */
> + memset(smallbuf, 0, size);
> +
> + *pbigbuf = bigbuf;
> + *psmallbuf = smallbuf;
> +
> + return true;
But in the end this whole code doesn't make any sense at all. Just
sleeping when failing to memory is a bad idea, as is all this partial
reuse stuff.
Someone needs to rearchitect this code to actually make sense.
next prev parent reply other threads:[~2011-06-24 7:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-24 6:51 [PATCH 0/5] Simplify demultiplex thread Pavel Shilovsky
[not found] ` <1308898317-7667-1-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-06-24 6:51 ` [PATCH 1/5] CIFS: Move buffer allocation to a separate function Pavel Shilovsky
[not found] ` <1308898317-7667-2-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-06-24 7:11 ` Christoph Hellwig [this message]
[not found] ` <20110624071159.GA11901-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2011-06-24 7:36 ` Pavel Shilovsky
2011-06-24 6:51 ` [PATCH 2/5] CIFS: Simplify socket reading in demultiplex thread Pavel Shilovsky
2011-06-24 6:51 ` [PATCH 3/5] CIFS: Move RFC1002 check to a separate function Pavel Shilovsky
2011-06-24 6:51 ` [PATCH 4/5] CIFS: Move mid search " Pavel Shilovsky
[not found] ` <1308898317-7667-5-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-06-24 7:14 ` Christoph Hellwig
2011-06-24 6:51 ` [PATCH 5/5] CIFS: Cleanup demupltiplex thread exiting code 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=20110624071159.GA11901@infradead.org \
--to=hch-wegcikhe2lqwvfeawa7xhq@public.gmane.org \
--cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=piastryyy-Re5JQEeQqe8AvxtiuMwx3w@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.