Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: avoid second lock on client_lock #21554

Merged
merged 1 commit into from Apr 29, 2018
Merged

client: avoid second lock on client_lock #21554

merged 1 commit into from Apr 29, 2018

Conversation

supriti
Copy link
Contributor

@supriti supriti commented Apr 20, 2018

Avoid a second nested lock on client lock. As a result, drop unused function ll_get_inodeno().

Fixes: http://tracker.ceph.com/issues/23815
Signed-off-by: Supriti Singh supriti.singh@suse.com

Copy link
Member

@joscollin joscollin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is ll_get_inodeno

@joscollin joscollin added the cephfs Ceph File System label Apr 20, 2018
@ukernel
Copy link
Contributor

ukernel commented Apr 20, 2018

this is wrong. ll_get_inodeno() unlock client_lock when it returns

@supriti
Copy link
Contributor Author

supriti commented Apr 20, 2018

@ukernel I guess you meant that ll_get_inodeno DOES not unlock when it returns? You are right. It would be better to take lock in ll_get_stripe_osd and not in ll_get_inodeno as it will never release the lock.

@@ -12422,8 +12422,6 @@ int Client::ll_file_layout(Fh *fh, file_layout_t *layout)
int Client::ll_get_stripe_osd(Inode *in, uint64_t blockno,
file_layout_t* layout)
{
Mutex::Locker lock(client_lock);

inodeno_t ino = ll_get_inodeno(in);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can get directly from in. in->ino.

Copy link
Contributor Author

@supriti supriti Apr 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case, no one is calling this function ll_get_inodeno ( and consecutively) _get_inodeno except ll_get_stripe_osd. May be we can remove these functions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client::_ll_forget() is calling _get_inodeno()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joscollin in _ll_forget as well we can have inodeno_t ino = in->ino. But I am not aware of design behind using _get_inodeno().

Besides that, I see in some the functions in Client.cc, we have taken client_lock but don't unlock it before leaving the function. For example, ll_get_stripe_osd, ll_readlink, ll_get_snapid. This seems like error. If that's case I can submit a another patch.

Copy link
Member

@joscollin joscollin Apr 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See how Mutex::Locker is defined and where in memory those objects are created.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RAII

@supriti supriti changed the title Don't take client lock in ll_get_stripe_osd Remove function ll_get_inodeno Apr 20, 2018
@supriti
Copy link
Contributor Author

supriti commented Apr 20, 2018

@joscollin thanks for review and your answers. I have updated PR addressing your comments.

@batrick batrick changed the title Remove function ll_get_inodeno client: remove function ll_get_inodeno Apr 20, 2018
Copy link
Member

@batrick batrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good change but the real issue is that ll_get_inodeno is doing a second nested lock on client lock. This fix will need backported so please create a tracker issue for it and annotate the commit message with Fixes: https://tracker.ceph.com/....

@joscollin joscollin changed the title client: remove function ll_get_inodeno client: avoid second lock on client_lock Apr 21, 2018
@tchaikov
Copy link
Contributor

retest this please

@supriti
Copy link
Contributor Author

supriti commented Apr 21, 2018

Updated the commit message with tracker issue.

Copy link
Member

@joscollin joscollin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@batrick
Copy link
Member

batrick commented Apr 23, 2018

Please fix the commit message to be:

Fixes: https://tracker.ceph.com/issues/23815

The https:// is important for our merge scripts.

Avoid a second nested lock on client lock. As a result, drop unused function ll_get_inodeno().
Fixes: https://tracker.ceph.com/issues/23815

Signed-off-by: Supriti Singh <supriti.singh@suse.com>
@supriti
Copy link
Contributor Author

supriti commented Apr 23, 2018

@batrick sorry I was not aware about it. Updated the comment now.

@joscollin
Copy link
Member

retest this please

@supriti
Copy link
Contributor Author

supriti commented Apr 24, 2018

retest this please

// low-level interface v2
inodeno_t ll_get_inodeno(Inode *in) {
Mutex::Locker lock(client_lock);
return _get_inodeno(in);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might not hurt to get rid of the _get_inodeno wrapper too, while you're in there. Seems rather silly to have a private method for fetching a single value out of the class.

@batrick batrick merged commit 7be8d55 into ceph:master Apr 29, 2018
batrick added a commit that referenced this pull request Apr 29, 2018
* refs/pull/21554/head:
	client: avoid second lock on client_lock

Reviewed-by: Jos Collin <jcollin@redhat.com>
Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
joscollin added a commit to joscollin/ceph that referenced this pull request Apr 30, 2018
Drop _get_inodeno() as per the comment in ceph#21554.

Signed-off-by: Jos Collin <jcollin@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants