-
Notifications
You must be signed in to change notification settings - Fork 136
Non-resident COW files #273
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
Open
dakotarwilliams
wants to merge
3
commits into
datto:main
Choose a base branch
from
dakotarwilliams:ntfs-remount
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -159,7 +159,7 @@ static int snap_trace_bio(struct snap_device *dev, struct bio *bio) | |
| unsigned int bytes, pages; | ||
|
|
||
| // if we don't need to cow this bio just call the real mrf normally | ||
| if (!bio_needs_cow(bio, dev->sd_cow_inode)) | ||
| if (!bio_needs_cow(bio, dev)) | ||
| return dattobd_call_mrf(dev->sd_orig_mrf, | ||
| dattobd_bio_get_queue(bio), bio); | ||
|
|
||
|
|
@@ -255,6 +255,14 @@ static int inc_trace_bio(struct snap_device *dev, struct bio *bio) | |
| bio_iter_t iter; | ||
| bio_iter_bvec_t bvec; | ||
|
|
||
| if (!test_bit(SD_FLAG_COW_RESIDENT, &dev->sd_flags)) { | ||
| // if the cow is non-resident, then we don't need to check if | ||
| // the bio is for the cow file. | ||
| ret = inc_make_sset(dev, bio_sector(bio), | ||
| bio_size(bio) / SECTOR_SIZE); | ||
| goto out; | ||
| } | ||
|
|
||
| #ifdef HAVE_ENUM_REQ_OPF | ||
| //#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0) | ||
| if (bio_op(bio) == REQ_OP_WRITE_ZEROES) { | ||
|
|
@@ -406,10 +414,7 @@ static int __tracer_destroy_cow(struct snap_device *dev, int close_method) | |
| if (dev->sd_cow) { | ||
| LOG_DEBUG("destroying cow manager"); | ||
|
|
||
| if (close_method == 0) { | ||
| cow_free(dev->sd_cow); | ||
| dev->sd_cow = NULL; | ||
| } else if (close_method == 1) { | ||
| if (close_method == 0 || close_method == 1) { | ||
| ret = cow_sync_and_free(dev->sd_cow); | ||
| dev->sd_cow = NULL; | ||
| } else if (close_method == 2) { | ||
|
|
@@ -483,11 +488,8 @@ static int __tracer_setup_cow(struct snap_device *dev, | |
| } | ||
| } | ||
|
|
||
| // verify that file is on block device | ||
| if (!file_is_on_bdev(dev->sd_cow->filp, bdev)) { | ||
| ret = -EINVAL; | ||
| LOG_ERROR(ret, "'%s' is not on '%s'", cow_path, bdev_name); | ||
| goto error; | ||
| if (file_is_on_bdev(dev->sd_cow->filp, bdev)) { | ||
| set_bit(SD_FLAG_COW_RESIDENT, &dev->sd_flags); | ||
| } | ||
|
|
||
| // find the cow file's inode number | ||
|
|
@@ -627,6 +629,12 @@ static void __tracer_destroy_cow_path(struct snap_device *dev) | |
| kfree(dev->sd_cow_path); | ||
| dev->sd_cow_path = NULL; | ||
| } | ||
|
|
||
| if (dev->sd_cow_full_path) { | ||
| LOG_DEBUG("freeing full cow path"); | ||
| kfree(dev->sd_cow_full_path); | ||
| dev->sd_cow_full_path = NULL; | ||
| } | ||
| } | ||
|
|
||
| static int __tracer_setup_cow_path(struct snap_device *dev, | ||
|
|
@@ -635,6 +643,11 @@ static int __tracer_setup_cow_path(struct snap_device *dev, | |
| int ret; | ||
|
|
||
| // get the pathname of the cow file (relative to the mountpoint) | ||
| LOG_DEBUG("getting absolute pathname of cow file"); | ||
| ret = file_get_absolute_pathname(cow_file, &dev->sd_cow_full_path, NULL); | ||
| if (ret) | ||
| goto error; | ||
|
|
||
| LOG_DEBUG("getting relative pathname of cow file"); | ||
| ret = dentry_get_relative_pathname(dattobd_get_dentry(cow_file), | ||
| &dev->sd_cow_path, NULL); | ||
|
|
@@ -1579,14 +1592,17 @@ void __tracer_dormant_to_active(struct snap_device *dev, | |
| const char __user *user_mount_path) | ||
| { | ||
| int ret; | ||
| char *resident_cow_path; | ||
| char *cow_path; | ||
|
|
||
| // generate the full pathname | ||
| ret = user_mount_pathname_concat(user_mount_path, dev->sd_cow_path, | ||
| &cow_path); | ||
| &resident_cow_path); | ||
| if (ret) | ||
| goto error; | ||
|
|
||
| cow_path = test_bit(SD_FLAG_COW_RESIDENT, &dev->sd_flags) ? resident_cow_path : dev->sd_cow_full_path; | ||
|
|
||
| // setup the cow manager | ||
| ret = __tracer_setup_cow_reopen(dev, dev->sd_base_dev, cow_path); | ||
| if (ret) | ||
|
|
@@ -1608,13 +1624,13 @@ void __tracer_dormant_to_active(struct snap_device *dev, | |
| set_bit(ACTIVE, &dev->sd_state); | ||
| clear_bit(UNVERIFIED, &dev->sd_state); | ||
|
|
||
| kfree(cow_path); | ||
| kfree(resident_cow_path); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be freed immediately after __tracer_setup_cow_reopen() and then the extra test/free in the error: case could be removed? |
||
|
|
||
| return; | ||
|
|
||
| error: | ||
| LOG_ERROR(ret, "error transitioning tracer to active state"); | ||
| if (cow_path) | ||
| kfree(cow_path); | ||
| if (resident_cow_path) | ||
| kfree(resident_cow_path); | ||
| tracer_set_fail_state(dev, ret); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be marked as deprecated in a comment?