linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* should sillyrename be an asynchronous operation?
@ 2010-08-17 13:30 Jeff Layton
  2010-08-17 22:02 ` Trond Myklebust
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Layton @ 2010-08-17 13:30 UTC (permalink / raw)
  To: linux-nfs

We had a bug report recently where someone was complaining about
silly-renamed files being left around:

https://bugzilla.redhat.com/show_bug.cgi?id=511901

...they attached a reproducer to the bug which involves a
pthreads-based program killing a child thread that's unlinking and
closing a file.

The unlink triggers a sillyrename (since the file is still open). The
parent kills the child thread and if timed just right, the child thread
will be killed after the RENAME call is issued but before the reply is
processed. The file will end up renamed on the server, but the client
won't be aware of it and won't unlink it during dentry_iput.

It's a bit of work, but the best way I can envision to fix this would
be to make sillyrename do an asynchronous RENAME call, and have it wait
for the reply. If the task is killed, then the RENAME can proceed and
the file would be unlinked when the dput is done by the rpc_release
call.

At this point, I just want to know whether this approach is acceptable
before I spend time on it. Is there a better way to handle this?

Thanks,
-- 
Jeff Layton <jlayton@redhat.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: should sillyrename be an asynchronous operation?
  2010-08-17 13:30 should sillyrename be an asynchronous operation? Jeff Layton
@ 2010-08-17 22:02 ` Trond Myklebust
  0 siblings, 0 replies; 2+ messages in thread
From: Trond Myklebust @ 2010-08-17 22:02 UTC (permalink / raw)
  To: Jeff Layton; +Cc: linux-nfs

On Tue, 2010-08-17 at 09:30 -0400, Jeff Layton wrote:
> We had a bug report recently where someone was complaining about
> silly-renamed files being left around:
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=511901
> 
> ...they attached a reproducer to the bug which involves a
> pthreads-based program killing a child thread that's unlinking and
> closing a file.
> 
> The unlink triggers a sillyrename (since the file is still open). The
> parent kills the child thread and if timed just right, the child thread
> will be killed after the RENAME call is issued but before the reply is
> processed. The file will end up renamed on the server, but the client
> won't be aware of it and won't unlink it during dentry_iput.
> 
> It's a bit of work, but the best way I can envision to fix this would
> be to make sillyrename do an asynchronous RENAME call, and have it wait
> for the reply. If the task is killed, then the RENAME can proceed and
> the file would be unlinked when the dput is done by the rpc_release
> call.
> 
> At this point, I just want to know whether this approach is acceptable
> before I spend time on it. Is there a better way to handle this?

Well... The rpc_release cannot allocate memory, so you're going to have
to preallocate the struct nfs_unlinkdata afaics.

I suppose one way to do that would be to call nfs_async_unlink() first,
then do the rename, then cancel the async_unlink if the rename attempt
fails.
We already do something like that in nfs_do_call_unlink if we race with
a lookup...

Cheers
  Trond

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-17 22:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-17 13:30 should sillyrename be an asynchronous operation? Jeff Layton
2010-08-17 22:02 ` Trond Myklebust

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).