Re: SETATTR without stateid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 19, 2017 at 9:58 AM, Mkrtchyan, Tigran
<tigran.mkrtchyan@xxxxxxx> wrote:
> Dear friends,
>
> By running xfstest (generic/013) I have discovered client side misbehavior.
> Consider the following test code:
>
> -----
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <fcntl.h>
>
>
> int main(int argc, char **argv)
> {
>
>   if (argc != 2) {
>     fprintf(stderr, "Usage: %s <path>\n", argv[0]);
>     exit(1);
>   }
>
>   int rc = truncate(argv[1], 8192);
>   if (rc < 0) {
>     perror("Failed to truncate the file");
>     exit(4);
>   }
>   exit(0);
> }
>
>
> ----
>
> The expectation is that client will send a valid open stateid with SETATTR (rfc7530#16.32.4).
> However, this is not the case - client just send's a SETATTR with size, but without any open.

SETATTR is allowed to send an all-zero stateid:

RFC7530 9.1.4.3

Anonymous Stateid:  When "other" and seqid are both zero, the stateid
      is treated as a special anonymous stateid, which can be used in
      READ, WRITE, and SETATTR requests to indicate the absence of any
      open state associated with the request.

> BTW, older clients (RHEL6) will fail with EIO, latest kernel, 4.13.0-rc1 goes into an
> infinite loop of SETATTR requests.

What does the server replies with in such case? I believe the client
assumes that SETATTR with all zeros will always be allowed and it will
not be checking anything if it gets BAD_STATEID and will automatically
re-try on BAD_STATEID with zero stateid (therefore it would explain
the loop you are seeing).

Older clients (RHEL6) did not have an option of retrying the SETATTR
that got the BAD_STATEID (on a delegation stateid) and retrying with
zero stateid which is allowed by the spec.

> On the other hand, ftruncate works as expected, e.q. following example:
>
> ---
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <fcntl.h>
>
>
> int main(int argc, char **argv)
> {
>
>   if (argc != 2) {
>     fprintf(stderr, "Usage: %s <path>\n", argv[0]);
>     exit(1);
>   }
>
>   int fd = open(argv[1], O_RDWR, 0644);
>   if (fd < 0) {
>     perror("Failed to open file");
>     exit(2);
>   }
>
>   int rc = ftruncate(fd, 8192);
>   if (rc < 0) {
>     perror("Failed to truncate the file");
>     exit(4);
>   }
>
>   close(fd);
>   exit(0);
> }
> ----
> Will provide an open stateid with SETATTR requests as mandated by rfc.

Yes that version of the user land "setattr" is on the file descriptor
so there was an opens stateid to be used by the nfs setattr.
"truncate" is on the file name and nfs does not underneath open a file
to satisfy this command.

>
> Tigran.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux