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

mds: force client flush snap data before truncating objects #11994

Merged
merged 1 commit into from Nov 23, 2016

Conversation

ukernel
Copy link
Contributor

@ukernel ukernel commented Nov 15, 2016

Snapshot data get lost if following sequence of events happen

  • client writes data to a file
  • make a snapshot
  • truncate the file
  • mds truncate file objects using the newest snap context
  • client flushes snap data using the old snap context

OSD first handles MDS's truncate request, it updates object's snap
context. When handling client's write request, OSD finds that
object's snap context is newer than request's snap context. So
it uses the newer one and treats the data as if they were
written after the snapshot.

The fix is avoid touching file objects while clients may have
unflushed snap data. Before truncating file objects, MDS checks
if clients may have unflushed snap data. If client have, MDS
set filelock to a special unstable state, the state revokes Fb
capability. MDS starts truncating file objects after the Fb
capability get revoked.

Fixes: http://tracker.ceph.com/issues/17193
Signed-off-by: Yan, Zheng zyan@redhat.com

Snapshot data get lost if following sequence of events happen

- client writes data to a file
- make a snapshot
- truncate the file
- mds truncate file objects using the newest snap context
- client flushes snap data using the old snap context

OSD first handles MDS's truncate request, it updates object's snap
context. When handling client's write request, OSD finds that
object's snap context is newer than request's snap context. So
it uses the newer one and treats the data as if they were
written after the snapshot.

The fix is avoid touching file objects while clients may have
unflushed snap data. Before truncating file objects, MDS checks
if clients may have unflushed snap data. If client have, MDS
set filelock to a special unstable state, the state revokes Fb
capability. MDS starts truncating file objects after the Fb
capability get revoked.

Fixes: http://tracker.ceph.com/issues/17193
Signed-off-by: Yan, Zheng <zyan@redhat.com>
@ukernel ukernel added bug-fix cephfs Ceph File System labels Nov 15, 2016
@gregsfortytwo
Copy link
Member

/subscribe

@ghost
Copy link

ghost commented Nov 16, 2016

jenkins test this please (eio, now ignored in master)

@ghost
Copy link

ghost commented Nov 16, 2016

jenkins test this please (tox bug, now fixed in master)

@gregsfortytwo gregsfortytwo self-assigned this Nov 17, 2016
@jcsp
Copy link
Contributor

jcsp commented Nov 21, 2016

My test branch had a failure in a snapshot test:
http://pulpito.ceph.com/jspray-2016-11-18_13:57:54-fs-wip-jcsp-testing-20161118-distro-basic-smithi/559675

Failure: "2016-11-18 14:23:07.939915 mds.0 172.21.15.77:6812/4225298329 2 : cluster [ERR] dir 100000045a1 object missing on disk; some files may be lost (/client.0/tmp/k/coreutils-8.5/tests/pr)" in cluster log

@ukernel
Copy link
Contributor Author

ukernel commented Nov 22, 2016

unrelated bug http://tracker.ceph.com/issues/17990

Copy link
Member

@gregsfortytwo gregsfortytwo left a comment

Choose a reason for hiding this comment

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

Mostly looks good.

if (in->filelock.is_stable()) {
in->auth_pin(&in->filelock);
} else {
assert(in->filelock.get_state() == LOCK_XLOCKSNAP);
Copy link
Member

Choose a reason for hiding this comment

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

Don't we still need to auth_pin() the file here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LOCK_XLOCKSNAP is unstable state, it was already auth pinned

Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

@gregsfortytwo gregsfortytwo left a comment

Choose a reason for hiding this comment

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

Reviewed-by: Greg Farnum gfarnum@redhat.com

if (in->filelock.is_stable()) {
in->auth_pin(&in->filelock);
} else {
assert(in->filelock.get_state() == LOCK_XLOCKSNAP);
Copy link
Member

Choose a reason for hiding this comment

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

👍

@gregsfortytwo
Copy link
Member

Should build a test for this too @ukernel — we don't have much white box testing around recovery or snapshots.

@jcsp jcsp merged commit 59666c9 into ceph:master Nov 23, 2016
@ukernel ukernel deleted the wip-17193 branch January 12, 2017 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants