Skip to content

Commit

Permalink
Merge pull request ceph#46210 from vshankar/wip-54701
Browse files Browse the repository at this point in the history
mds: do not assert early on when issuing client leases

Reviewed-by: Patrick Donnelly <[email protected]>
Reviewed-by: Xiubo Li <[email protected]>
Reviewed-by: Greg Farnum <[email protected]>
  • Loading branch information
vshankar authored Jun 7, 2022
2 parents 375c8a6 + 907b1f4 commit 971567e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
17 changes: 14 additions & 3 deletions src/mds/Locker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4252,8 +4252,8 @@ void Locker::handle_client_lease(const cref_t<MClientLease> &m)
}


void Locker::issue_client_lease(CDentry *dn, MDRequestRef &mdr, int mask,
utime_t now, bufferlist &bl)
void Locker::issue_client_lease(CDentry *dn, CInode *in, MDRequestRef &mdr, utime_t now,
bufferlist &bl)
{
client_t client = mdr->get_client();
Session *session = mdr->session;
Expand All @@ -4264,6 +4264,17 @@ void Locker::issue_client_lease(CDentry *dn, MDRequestRef &mdr, int mask,
!diri->is_stray() && // do not issue dn leases in stray dir!
!diri->filelock.can_lease(client) &&
!(diri->get_client_cap_pending(client) & (CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_EXCL))) {
int mask = 0;
CDentry::linkage_t *dnl = dn->get_linkage(client, mdr);
if (dnl->is_primary()) {
ceph_assert(dnl->get_inode() == in);
mask = CEPH_LEASE_PRIMARY_LINK;
} else {
if (dnl->is_remote())
ceph_assert(dnl->get_remote_ino() == in->ino());
else
ceph_assert(!in);
}
// issue a dentry lease
ClientLease *l = dn->add_client_lease(client, session);
session->touch_lease(l);
Expand All @@ -4283,7 +4294,7 @@ void Locker::issue_client_lease(CDentry *dn, MDRequestRef &mdr, int mask,
} else {
// null lease
LeaseStat lstat;
lstat.mask = mask;
lstat.mask = 0;
lstat.alternate_name = std::string(dn->alternate_name);
encode_lease(bl, session->info, lstat);
dout(20) << "issue_client_lease no/null lease on " << *dn << dendl;
Expand Down
2 changes: 1 addition & 1 deletion src/mds/Locker.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class Locker {
// -- client leases --
void handle_client_lease(const cref_t<MClientLease> &m);

void issue_client_lease(CDentry *dn, MDRequestRef &mdr, int mask, utime_t now, bufferlist &bl);
void issue_client_lease(CDentry *dn, CInode *in, MDRequestRef &mdr, utime_t now, bufferlist &bl);
void revoke_client_leases(SimpleLock *lock);
static void encode_lease(bufferlist& bl, const session_info_t& info, const LeaseStat& ls);

Expand Down
18 changes: 2 additions & 16 deletions src/mds/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2332,20 +2332,7 @@ void Server::set_trace_dist(const ref_t<MClientReply> &reply,
dout(20) << "set_trace_dist added dir " << *dir << dendl;

encode(dn->get_name(), bl);

int lease_mask = 0;
CDentry::linkage_t *dnl = dn->get_linkage(mdr->get_client(), mdr);
if (dnl->is_primary()) {
ceph_assert(dnl->get_inode() == in);
lease_mask = CEPH_LEASE_PRIMARY_LINK;
} else {
if (dnl->is_remote())
ceph_assert(dnl->get_remote_ino() == in->ino());
else
ceph_assert(!in);
}
mds->locker->issue_client_lease(dn, mdr, lease_mask, now, bl);
dout(20) << "set_trace_dist added dn " << snapid << " " << *dn << dendl;
mds->locker->issue_client_lease(dn, in, mdr, now, bl);
} else
reply->head.is_dentry = 0;

Expand Down Expand Up @@ -4781,8 +4768,7 @@ void Server::handle_client_readdir(MDRequestRef& mdr)
// dentry
dout(12) << "including dn " << *dn << dendl;
encode(dn->get_name(), dnbl);
int lease_mask = dnl->is_primary() ? CEPH_LEASE_PRIMARY_LINK : 0;
mds->locker->issue_client_lease(dn, mdr, lease_mask, now, dnbl);
mds->locker->issue_client_lease(dn, in, mdr, now, dnbl);

// inode
dout(12) << "including inode " << *in << dendl;
Expand Down

0 comments on commit 971567e

Please sign in to comment.