fusefs: VOP_FSYNC should be synchronous

returning asynchronously pretty much defeats the point of fsync

PR:		236474
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Alan Somers 2019-03-21 21:53:55 +00:00
parent 44dc9245e7
commit cc34f2f66a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/fuse2/; revision=345390
3 changed files with 7 additions and 37 deletions

View File

@ -287,6 +287,7 @@ fuse_internal_fsync(struct vnode *vp,
int op = FUSE_FSYNC;
struct fuse_fsync_in *ffsi;
struct fuse_dispatcher fdi;
int err;
if (vnode_isdir(vp)) {
op = FUSE_FSYNCDIR;
@ -298,13 +299,10 @@ fuse_internal_fsync(struct vnode *vp,
ffsi->fsync_flags = 1; /* datasync */
fuse_insert_callback(fdi.tick, fuse_internal_fsync_callback);
fuse_insert_message(fdi.tick);
err = fdisp_wait_answ(&fdi);
fdisp_destroy(&fdi);
return 0;
return err;
}
/* readdir */

View File

@ -454,12 +454,12 @@ fuse_vnop_fsync(struct vop_fsync_args *ap)
for (type = 0; type < FUFH_MAXTYPE; type++) {
fufh = &(fvdat->fufh[type]);
if (FUFH_IS_VALID(fufh)) {
fuse_internal_fsync(vp, td, NULL, fufh);
err = fuse_internal_fsync(vp, td, NULL, fufh);
}
}
out:
return 0;
return err;
}
/*

View File

@ -77,7 +77,6 @@ void expect_write(uint64_t ino, uint64_t size, const void *contents)
/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236379 */
/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236473 */
/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */
TEST_F(Fsync, DISABLED_aio_fsync)
{
const char FULLPATH[] = "mountpoint/some_file.txt";
@ -149,8 +148,7 @@ TEST_F(Fsync, close)
close(fd);
}
/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */
TEST_F(Fsync, DISABLED_eio)
TEST_F(Fsync, eio)
{
const char FULLPATH[] = "mountpoint/some_file.txt";
const char RELPATH[] = "some_file.txt";
@ -179,7 +177,6 @@ TEST_F(Fsync, DISABLED_eio)
* subsequent calls to VOP_FSYNC will succeed automatically without being sent
* to the filesystem daemon
*/
/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */
/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236557 */
TEST_F(Fsync, DISABLED_enosys)
{
@ -207,8 +204,7 @@ TEST_F(Fsync, DISABLED_enosys)
}
/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */
TEST_F(Fsync, DISABLED_fdatasync)
TEST_F(Fsync, fdatasync)
{
const char FULLPATH[] = "mountpoint/some_file.txt";
const char RELPATH[] = "some_file.txt";
@ -232,7 +228,6 @@ TEST_F(Fsync, DISABLED_fdatasync)
}
/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236473 */
/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */
TEST_F(Fsync, DISABLED_fsync)
{
const char FULLPATH[] = "mountpoint/some_file.txt";
@ -258,7 +253,6 @@ TEST_F(Fsync, DISABLED_fsync)
/* Fsync should sync a file with dirty metadata but clean data */
/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236473 */
/* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236474 */
TEST_F(Fsync, DISABLED_fsync_metadata_only)
{
const char FULLPATH[] = "mountpoint/some_file.txt";
@ -289,25 +283,3 @@ TEST_F(Fsync, DISABLED_fsync_metadata_only)
ASSERT_EQ(0, fsync(fd)) << strerror(errno);
/* Deliberately leak fd. close(2) will be tested in release.cc */
}
// fsync()ing a file that isn't dirty should be a no-op
TEST_F(Fsync, nop)
{
const char FULLPATH[] = "mountpoint/some_file.txt";
const char RELPATH[] = "some_file.txt";
uint64_t ino = 42;
int fd;
expect_lookup(RELPATH, ino);
expect_open(ino, 0, 1);
expect_getattr(ino, 0);
fd = open(FULLPATH, O_WRONLY);
ASSERT_LE(0, fd) << strerror(errno);
ASSERT_EQ(0, fsync(fd)) << strerror(errno);
/* Deliberately leak fd. close(2) will be tested in release.cc */
}
// TODO: ENOSYS test