Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Rohith Surabattula <rohiths.msft@gmail.com>
Cc: dhowells@redhat.com, Steve French <smfrench@gmail.com>,
	Shyam Prasad N <nspmangalore@gmail.com>,
	ronnie sahlberg <ronniesahlberg@gmail.com>,
	Paulo Alcantara <pc@cjr.nz>,
	linux-cifs <linux-cifs@vger.kernel.org>
Subject: Re: [PATCH] [CIFS]: Add clamp_length support
Date: Mon, 28 Feb 2022 14:39:10 +0000	[thread overview]
Message-ID: <2500957.1646059150@warthog.procyon.org.uk> (raw)
In-Reply-To: <CACdtm0ZteTve1EbSgDX_jochhHT7Ufm3gJg7j28BOjmRSg8dTQ@mail.gmail.com>

Rohith Surabattula <rohiths.msft@gmail.com> wrote:

> > Rohith Surabattula <rohiths.msft@gmail.com> wrote:
> >
> > > +     credits = kmalloc(sizeof(struct cifs_credits), GFP_KERNEL);
> > > ...
> > > +     subreq->subreq_priv = credits;
> >
> > Would it be better if I made it so that the netfs could specify the size of
> > the netfs_read_subrequest struct to be allocated, thereby allowing it to tag
> > extra data on the end?
>
> Do you mean the clamp handler in netfs should return the size of data
> to be allocated instead of allocating itself ?

No, I was thinking of putting a size_t in struct netfs_request_ops that
indicates how big the subrequest struct should be:

	struct netfs_request_ops {
		...
		size_t subrequest_size;
	};

and then:

	struct netfs_read_subrequest *netfs_alloc_subrequest(
		struct netfs_read_request *rreq)
	{
		struct netfs_read_subrequest *subreq;

		subreq = kzalloc(rreq->ops->subrequest_size, GFP_KERNEL);
		if (subreq) {
			INIT_LIST_HEAD(&subreq->rreq_link);
			refcount_set(&subreq->usage, 2);
			subreq->rreq = rreq;
			netfs_get_read_request(rreq);
			netfs_stat(&netfs_n_rh_sreq);
		}

		return subreq;
	}

This would allow you to do, for instance:

	struct cifs_subrequest {
		struct netfs_read_subrequest subreq;
		struct cifs_credits credits;
	};

then:

	const struct netfs_request_ops cifs_req_ops = {
		.subrequest_size	= sizeof(struct cifs_subrequest),
		.init_rreq		= cifs_init_rreq,
		.expand_readahead	= cifs_expand_readahead,
		.clamp_length		= cifs_clamp_length,
		.issue_op		= cifs_req_issue_op,
		.done			= cifs_rreq_done,
		.cleanup		= cifs_req_cleanup,
	};

and then:

	static bool cifs_clamp_length(struct netfs_read_subrequest *subreq)
	{
		struct cifs_subrequest *cifs_subreq =
			container_of(subreq, struct cifs_subrequest, subreq);
		struct cifs_sb_info *cifs_sb = CIFS_SB(subreq->rreq->inode->i_sb);
		struct TCP_Server_Info *server;
		struct cifsFileInfo *open_file = subreq->rreq->netfs_priv;
		struct cifs_credits *credits = &cifs_subreq->credits;
		unsigned int rsize;
		int rc;

		server = cifs_pick_channel(tlink_tcon(open_file->tlink)->ses);

		rc = server->ops->wait_mtu_credits(server, cifs_sb->ctx->rsize,
	                                                   &rsize, credits);
		if (rc)
			return false;

		subreq->len = rsize;
		return true;
	}

David


  reply	other threads:[~2022-02-28 14:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08  5:53 [PATCH] [CIFS]: Add clamp_length support Rohith Surabattula
2022-02-16 21:25 ` David Howells
2022-02-28 14:23   ` Rohith Surabattula
2022-02-28 14:39     ` David Howells [this message]
2022-03-02 11:05       ` Rohith Surabattula
2022-03-02 15:16         ` David Howells
2022-03-02 15:26           ` Rohith Surabattula
2022-03-02 15:47             ` David Howells
2022-03-09 12:58         ` David Howells

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=2500957.1646059150@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=nspmangalore@gmail.com \
    --cc=pc@cjr.nz \
    --cc=rohiths.msft@gmail.com \
    --cc=ronniesahlberg@gmail.com \
    --cc=smfrench@gmail.com \
    /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