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>,
	jlayton@kernel.org, linux-cifs@vger.kernel.org
Subject: Re: cifs conversion to netfslib
Date: Fri, 11 Mar 2022 08:25:35 +0000	[thread overview]
Message-ID: <2315193.1646987135@warthog.procyon.org.uk> (raw)
In-Reply-To: <2314914.1646986773@warthog.procyon.org.uk>


David Howells <dhowells@redhat.com> wrote:

> The other issue is that if I run splice to an empty file, it works; running
> another splice to the same file will result in the server giving
> STATUS_ACCESS_DENIED when cifs_write_begin() tries to read from the file:
> 
>     7 0.009485249  192.168.6.2 → 192.168.6.1  SMB2 183 Read Request Len:65536 Off:0 File: x
>     8 0.009674245  192.168.6.1 → 192.168.6.2  SMB2 143 Read Response, Error: STATUS_ACCESS_DENIED
> 
> Actually - that might be because the file is only 65536 bytes long because the
> first splice finished short.

Actually, it's because I opened the output file O_WRONLY.  If I open it
O_RDWR, it works.  The test program is attached below.

David
---
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>

int main(int argc, char *argv[])
{
	off64_t opos;
	size_t len;
	int in, out;

	if (argc != 4) {
		printf("Format: %s size in out\n", argv[0]);
		exit(2);
	}

	len = atol(argv[1]);

	if (strcmp(argv[2], "-") != 0) {
		in = open(argv[2], O_RDONLY);
		if (in < 0) {
			perror(argv[2]);
			return 1;
		}
	} else {
		in = 0;
	}

	if (strcmp(argv[3], "-") != 0) {
		out = open(argv[3], O_WRONLY);  // Change to O_RDWR
		if (out < 0) {
			perror(argv[3]);
			return 1;
		}
	} else {
		out = 1;
	}

	opos = 3;
	if (splice(in, NULL, out, &opos, len, 0) < 0) {
		perror("splice");
		return 1;
	}

	if (close(in) < 0) {
		perror("close/in");
		return 1;
	}

	if (close(out) < 0) {
		perror("close/out");
		return 1;
	}

	return 0;
}


  reply	other threads:[~2022-03-11  8:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11  8:19 cifs conversion to netfslib David Howells
2022-03-11  8:25 ` David Howells [this message]
2022-03-15  3:50   ` Rohith Surabattula
2022-03-15  9:54     ` Rohith Surabattula
2022-03-17  0:07       ` David Howells
2022-03-17 16:16         ` David Howells
2022-03-18  0:21         ` David Howells
2022-03-18  2:52           ` Steve French
2022-03-21 10:19             ` Rohith Surabattula
2022-03-21 17:18               ` 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=2315193.1646987135@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=jlayton@kernel.org \
    --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