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

cmd/mount: honour --no-lock flag #2821

Merged
merged 1 commit into from
Aug 3, 2020
Merged

Conversation

renard
Copy link

@renard renard commented Jul 7, 2020

Do not lock the repository if --no-lock flag is set. This allows to
mount repositories which are archived on a read only system.

Signed-off-by: Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>

What is the purpose of this change? What does it change?

If remote repository is on a read-only partition no lock can be acquired making the repo un-mountable.

This small patch fixes this by honouring the --no-lock global flag.

Was the change discussed in an issue or in the forum before?

https://forum.restic.net/t/mount-without-locking/2887

Fixes #1597

Checklist

  • I have read the Contribution Guidelines
  • I have enabled maintainer edits for this PR
  • I have added tests for all changes in this PR
  • I have added documentation for the changes (in the manual)
  • There's a new file in changelog/unreleased/ that describes the changes for our users (template here)
  • I have run gofmt on the code in all commits
  • All commit messages are formatted in the same style as the other commits in the repo
  • I'm done, this Pull Request is ready for review

if err != nil {
return err
if !gopts.NoLock {
Verbosef("create lock for repository\n")
Copy link
Contributor

@aawsome aawsome Jul 7, 2020

Choose a reason for hiding this comment

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

Instead of printing out an info when the repo is locked, I would print out a warning when the repo is not locked.

Copy link
Author

Choose a reason for hiding this comment

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

Commit updated. Thanks.

Copy link
Contributor

@aawsome aawsome left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@greatroar
Copy link
Contributor

I'm not sure why mount should print a warning when no other command does that, but LGTM too.

@aawsome
Copy link
Contributor

aawsome commented Jul 9, 2020

I'm not sure why mount should print a warning when no other command does that, but LGTM too.

I think that that other commands should warn as well. 😉
IMO for mount this is even more important as the mount command only quits when the user cancels it - that might be quite a long time. However, not too much to worry as mount is a read-only command.

@greatroar
Copy link
Contributor

Fine with me, let's see what the maintainers think.

Copy link
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

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

This PR would also fix #1597, for some reason Github doesn't let me link this issue to the PR.

if err != nil {
return err
if gopts.NoLock {
Warnf("not locking the repository\n")
Copy link
Member

Choose a reason for hiding this comment

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

I don't think there's a need to print this warning. A user hopefully still remembers that they passed the --no-lock flag. So let's keep this consistent with the other commands which respect --no-lock and remove the warning.

Copy link
Author

Choose a reason for hiding this comment

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

@MichaelEischer done in commit a6c94ac.

Let me know if this is good for you.

Copy link
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

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

Please also add a short changelog entry file to this PR. After this and the warning message are fixed, this PR is ready for merging.

@renard renard force-pushed the mount-nolock branch 2 times, most recently from c0b4bc2 to a6c94ac Compare August 2, 2020 17:48
Copy link
Contributor

@rawtaz rawtaz left a comment

Choose a reason for hiding this comment

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

@renard I guess GitHub is acting up and you haven't seen the two remaining comments I made on the changelog file. Please check the "Files changed" tab to see them :)

@@ -0,0 +1,7 @@
cmd/mount: honour --no-lock flag
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't formatted like the changelog entry template. I suggest changing this line to (yeah, the shorter "honor" instead of "honour"): Change: Honor the --no-lock flag in the mount command

changelog/unreleased/pull-2821 Outdated Show resolved Hide resolved
@rawtaz
Copy link
Contributor

rawtaz commented Aug 3, 2020

The subject line in the changelog is still not changed.

Do not lock the repository if --no-lock global flag is set. This allows
to mount repositories which are archived on a read only system.

Signed-off-by: Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>
Copy link
Contributor

@rawtaz rawtaz left a comment

Choose a reason for hiding this comment

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

Thank you very much!

@rawtaz rawtaz merged commit 5af2815 into restic:master Aug 3, 2020
@ATLief
Copy link

ATLief commented Sep 19, 2020

This is a really interesting addition. Would it be possible to modify the repository via another process while it’s mounted with the —no-lock option? If so what would happen?

I’m thinking that this could be useful to continue backing up my system while I restore or read a backup of a file, but I also see the potential for this to have unintended side-effects; for example, if the snapshot where a file was being accessed was forgotten or pruned.

@aawsome
Copy link
Contributor

aawsome commented Sep 20, 2020

@ATLief as long as you just want to backup while having your repo mounted, there is not need to use the --no-lock option: It already works as expected without this option. Mount will even update the directory structure after a short delay and includes the newly added snapshots.
However, I would not recommend using mount --no-lock with commands that delete things from the repository. This won't break your repo as mount does only read, but may give errors or even may crash.

This option is IMO only interesting for the use case that you can no longer write to your repopository but still want to access it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mount repository on read-only filesystems with --no-lock fails
6 participants