Hi!
> > In this case O_EXCL is going to be more accurate just because the
> > mounted check doesn't cover every disk in the FS. For now btrfsck
> > doesn't really give consistent results even readonly on a mounted
> > filesystem. We should prevent it with a message just to prevent
> > confusion.
> Thanks for the reply. I'll do this as soon as I understand the code
> that is affected by those changes (I'm still in the learning phase
> and stepping through the code).
OK, I've stepped through the code so far and I think I now have an idea of what
should be changed. However, concerning the solution, I was confusing two things.
Christoph Hellwig earlier wrote:
> Just open the nodes with O_EXCL and you'll get all the checking for
> free.
I thought that open() with O_EXCL would fail if the file is already opened RW
somewhere else. But the man page for open() says something else:
"O_EXCL: Ensure that this call creates the file: if this flag is specified
in conjunction with O_CREAT, and pathname already exists, then open() will
fail."
And especially:
"The behavior of O_EXCL is undefined if O_CREAT is not specified."
After having read this, I don't see how this can help to prevent btrfsck to
open a device that is mounted. What am I getting wrong? Currently, I would do
the same check as in the original patch, but in btrfs_open_devices() instead of
main().
Cheers,
Andi
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html