Skip to contentSkip to conversation

When do writes to fuse fd block?

fuse Nikolaus Rath 2 participants 4 messages Sep 19, 2018 – Sep 20, 2018 VFS

lore
Share & tools
lore
#0 lore raw

Hi,

Are there any conditions under which a write to the fuse file descriptor may block?

It seems to me that this should never be the case - except possibly when sending a FUSE_NOTIFY_INVAL_ENTRY or FUSE_NOTIFY_DELETE request that is related for to an ongoing file system operation. Here would would much appreciate if someone could clarify what operations exactly would cause the write to block. Is it possible that the write blocks indefinitely because new related operations keep coming? Or will the kernel suspend sending any new related requests and just wait for the existing ones to terminate?

Thanks!
-Nikolaus

Signature · 3 lines
GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«
#1 lore raw
Quoted 10 lines · Nikolaus Rath

Hi,

Are there any conditions under which a write to the fuse file descriptor may block?

It seems to me that this should never be the case - except possibly when sending a FUSE_NOTIFY_INVAL_ENTRY or FUSE_NOTIFY_DELETE request that is related for to an ongoing file system operation. Here would would much appreciate if someone could clarify what operations exactly would cause the write to block.

NOTIFY_INVAL_ENTRY and NOTIFY_DELETE lock the parent directory i_mutex. Operations which run under i_mutex of parent are: lookup, symlink, mknod, mkdir, unlink, rmdir, rename, link, create, rename2. Operations which run under i_mutex of object: setattr, unlink, rmdir, rename, setxattr, removexattr, readdir, readdirplus, rename2.

Quoted 4 lines

Is it possible that the write blocks indefinitely
because new related operations keep coming? Or will the kernel suspend sending any new related requests and just wait for the existing ones to terminate?

Shouldn't block indefinitely (lock does not allow starving), unless there's a deadlock caused by calling the invalidate from an op that is itself already holding i_mutex on the parent.

Thanks,
Miklos

#2 lore raw
Quoted 12 lines · Miklos Szeredi
Quoted 10 lines · Nikolaus Rath

Hi,

Are there any conditions under which a write to the fuse file descriptor may block?

It seems to me that this should never be the case - except possibly when sending a FUSE_NOTIFY_INVAL_ENTRY or FUSE_NOTIFY_DELETE request that is related for to an ongoing file system operation. Here would would much appreciate if someone could clarify what operations exactly would cause the write to block.

Quoted 5 lines

NOTIFY_INVAL_ENTRY and NOTIFY_DELETE lock the parent directory i_mutex. Operations which run under i_mutex of parent are: lookup, symlink, mknod, mkdir, unlink, rmdir, rename, link, create, rename2. Operations which run under i_mutex of object: setattr, unlink, rmdir, rename, setxattr, removexattr, readdir, readdirplus, rename2.

Thanks! Could you also confirm if that's the only situation where a write might block? In other words, in all other cases I can safely skip a select/poll/epoll for writability of fuse fd and be guaranteed that the write will proceed immediately?

Best,
-Nikolaus

Signature · 3 lines
GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

             »Time flies like an arrow, fruit flies like a Banana.«
#3 lore raw
Quoted 19 lines · Nikolaus Rath
Quoted 12 lines · Miklos Szeredi
Quoted 10 lines · Nikolaus Rath

Hi,

Are there any conditions under which a write to the fuse file descriptor may block?

It seems to me that this should never be the case - except possibly when sending a FUSE_NOTIFY_INVAL_ENTRY or FUSE_NOTIFY_DELETE request that is related for to an ongoing file system operation. Here would would much appreciate if someone could clarify what operations exactly would cause the write to block.

Quoted 5 lines

NOTIFY_INVAL_ENTRY and NOTIFY_DELETE lock the parent directory i_mutex. Operations which run under i_mutex of parent are: lookup, symlink, mknod, mkdir, unlink, rmdir, rename, link, create, rename2. Operations which run under i_mutex of object: setattr, unlink, rmdir, rename, setxattr, removexattr, readdir, readdirplus, rename2.

Quoted 4 lines

Thanks! Could you also confirm if that's the only situation where a write might block? In other words, in all other cases I can safely skip a select/poll/epoll for writability of fuse fd and be guaranteed that the write will proceed immediately?

Yes.

In fact doing poll() on fuse device fd would always return POLLOUT, so it makes no sense to poll for this event.

Thanks,
Miklos