On Thu, 17 Jul 2014 07:55:34 -0700 Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote: > On Wed, Jul 16, 2014 at 03:04:01PM -0400, Jeff Layton wrote: > > Hmm...maybe. It's a very unlikely race though, and I think the same > > sort of race exists today. In fact, it's worse today since we don't do > > any checking of the validity of the lease after acquiring it now. > > > > The flag sounds like a good idea, but the code is structured completely > > wrong for it currently. The delegation is only hashed after we get a > > lease, so the lease break wouldn't find anything to set a flag on. > > > > Quite frankly, I _really_ do not want to have to rework the locking in > > the delegation code yet again. I think this scheme is an improvement > > over what we have now, even if it's not 100% perfect. > > > > Once we get the scalability set done, I'd like to go back and overhaul > > the delegation code. There are a lot of ugly warts here, but fixing > > them is really a separate project in its own right. > > But in the old code we had the client lock over all of this, right? > Yes, but it's still possible for the lease to get broken after setting it but before the delegation is hashed in the existing code. You're correct though that another nfsd wouldn't be able to set a lease on the same file though. One possibility to ensure that can't happen is to check whether fp->fi_had_conflict became true after vfs_setlease returns. That would also obviate the need for file_has_lease. I'm still trying to figure out whether there are potential races there with that approach though. > Anyway, if Bruce and you are fine with this I'm not going to block it, > although it seems a little incomplete to me. Thanks, and I agree. I think we're going to need to revisit this area, but I suspect we need to do some surgery to the generic lease handling code too. For one thing, it's a little disturbing to me that vfs_setlease returns a pointer to the file_lock that's sitting on the i_flock list. I'm not sure that it's a problem today, but it seems like a caller could end up trying to use that pointer after time_out_leases has been called, or after the lease has been otherwise deleted. -- Jeff Layton <jlayton@xxxxxxxxxxxxxxx> -- 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