On Sun, Aug 27, 2006 at 08:27:55AM -0600, Mark Maybee
wrote:> Pawel Jakub Dawidek wrote:
>
> >Hi.
> >
> >I''m currently working on snapshots and can''t
understand one thing.
> >
> >When someone lookups a snapshot directory it gets automatically mounted
> >from zfsctl_snapdir_lookup() via domount().
> >
> >Ok, domount() ends up in zfs_domount(). zfs_domount() wants to open
> >dataset through dmu_objset_open().
> >dmu_objset_open() fails at first time returning EROFS, so we retry with
> >DS_MODE_READONLY, but for me it fails again (EBUSY).
> >
> >I investigated that this dataset was DOS_MODE_PRIMARY open on file
> >system mount, so snapshot cannot DOS_MODE_PRIMARY open it again.
> >
> >What am I missing here or what have I messed up?
> >Any ideas?
> >
>
> The mode is staying set after the failed EROFS open? This should have
> been cleared when the open failed, so the second attempt can succeed.
This is what I thought too, but no. dsl_dataset_open_spa() is returning
EROFS in this situation:
err = dsl_dataset_open_obj(dp, obj, NULL,
DS_MODE_NONE, tag, &ds);
if (err) {
ZFS_LOG(2, "return %d", err);
goto out;
}
obj = ds->ds_phys->ds_snapnames_zapobj;
dsl_dataset_close(ds, DS_MODE_NONE, tag);
ds = NULL;
if (tail[0] != ''@'') {
err = ENOENT;
goto out;
}
tail++;
/* Look for a snapshot */
if (!DS_MODE_IS_READONLY(mode)) {
err = EROFS;
goto out;
}
So the dataset is only opened DS_MODE_NONE (and closed right after).
ds_open_refcount stays the same after this call ((DOS_REF_MAX >> 1) + 1),
which means this is still too large to allow another DS_MODE_PRIMARY
open. When I change zfs_domount() to open with
''DS_MODE_STANDARD | DS_MODE_READONLY'' it seems to work, but
this is
probably unsafe and I''d like to know where is source of the problem.
Bascially, regular mount opens dataset in DS_MODE_PRIMARY mode, which
prevents other DS_MODE_PRIMARY opens and snapshot tries to open the
same dataset also with DS_MODE_PRIMARY, which of course fails.
It seems that I''m missing something obvious here...
Where my understanding is not correct?
BTW. There is a typo at in ds_refcnt_weight[]''s comments:
s/DOS_MODE_/DS_MODE_/g.
--
Pawel Jakub Dawidek http://www.wheel.pl
pjd at FreeBSD.org http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL:
<http://mail.opensolaris.org/pipermail/zfs-code/attachments/20060827/8edfc26b/attachment.bin>