On Wed, 30 Aug 2017, Meyers Mark wrote: > Hi: > > I want to ask a question about "lease issued to client". > > In ceph source, src/mds/Locker.cc: Locker::issue_client_lease: > > > if(... && > > (!diri->filelock.can_lease(client) && > > (diri->get_client_cap_pending(client) & > (CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_EXCL)) == 0) && > > dn->lock.can_lease(client)) { > > ... > > // issue a dentry lease > > ClientLease *l = dn->add_client_lease(client, session); > > ... > > LeaseStat e; > > ... > > e.duration_ms = (int)(1000 * > mdcache->client_lease_durations[pool]); > > ... > > } else { > > // null lease > > LeaseStat e; > > ... > > e.duration_ms = 0; > ... > > } > > So my understanding is: > > If parent directory has no lease, but has CEPH_CAP_FILE_SHARED > mask, then the dentry can get a lease of 30s(caculated from > duration_ms). Actually if it *doesn't* have the FILE_SHARED cap, then we issue a per-dentry lease. Per-dentry leases are fine, but not as efficient as a single bit on an entire directory indicating that the entire directory won't change. Since most directories are static, this is an efficient way for clients to cache (and trust their cache). If there are some modifications in the directory or for some other reason the MDS can't issue a the directory-wide lease (FILE_SHARED cap bit), then we issue per-dentry leases. > Else if in other conditions, then the dentry get a lease of 0s. > > I am confused here, in what situation does the parent > directory and the child dentry share a lease? > > And in what situation does the child dentry have no > lease(lease of zero seconds?)? If there are locks on the dentry due to a modification in flight, we don't issue a lease. This ensures that things like rename, unlink, etc. can make progress. sage -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html