On Tue, May 22, 2018 at 10:37:14AM -0700, Omar Sandoval wrote: > On Tue, May 22, 2018 at 07:17:48PM +0200, David Sterba wrote: > > On Tue, May 22, 2018 at 09:47:58AM -0700, Omar Sandoval wrote: > > > From: Omar Sandoval <osan...@fb.com> > > > > > > Jun Wu at Facebook reported that an internal service was seeing a return > > > value of 1 from ftruncate() on Btrfs in some cases. > > > > Do you have a reproducer? To estimate how likely is to hit the problem > > in practice.
Here's an even easier one: truncating a compressed, inline file twice: #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main() { char buf[256] = { 0 }; int ret; int fd; fd = open("test", O_CREAT | O_WRONLY | O_TRUNC, 0666); if (fd == -1) { perror("open"); return EXIT_FAILURE; } if (write(fd, buf, sizeof(buf)) != sizeof(buf)) { perror("write"); close(fd); return EXIT_FAILURE; } close(fd); fd = open("test", O_WRONLY, 0666); if (fd == -1) { perror("open"); return EXIT_FAILURE; } ret = ftruncate(fd, 128); if (ret) { printf("first ftruncate() returned %d\n", ret); close(fd); return EXIT_FAILURE; } close(fd); fd = open("test", O_WRONLY, 0666); if (fd == -1) { perror("open"); return EXIT_FAILURE; } ret = ftruncate(fd, 64); if (ret) { printf("second ftruncate() returned %d\n", ret); close(fd); return EXIT_FAILURE; } close(fd); return EXIT_SUCCESS; } The output is second ftruncate() returned 1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html