loader: zfs reader should only store devdesc in f_devdata
Use d_opendata for device specific data. PR: 265825 Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D36202
This commit is contained in:
parent
c0b65123d0
commit
d98de74405
@ -108,7 +108,8 @@ struct zfs_be_entry {
|
||||
static int
|
||||
zfs_open(const char *upath, struct open_file *f)
|
||||
{
|
||||
struct zfsmount *mount = (struct zfsmount *)f->f_devdata;
|
||||
struct devdesc *dev = f->f_devdata;
|
||||
struct zfsmount *mount = dev->d_opendata;
|
||||
struct file *fp;
|
||||
int rc;
|
||||
|
||||
@ -149,7 +150,8 @@ zfs_close(struct open_file *f)
|
||||
static int
|
||||
zfs_read(struct open_file *f, void *start, size_t size, size_t *resid /* out */)
|
||||
{
|
||||
const spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa;
|
||||
struct devdesc *dev = f->f_devdata;
|
||||
const spa_t *spa = ((struct zfsmount *)dev->d_opendata)->spa;
|
||||
struct file *fp = (struct file *)f->f_fsdata;
|
||||
struct stat sb;
|
||||
size_t n;
|
||||
@ -213,7 +215,8 @@ zfs_seek(struct open_file *f, off_t offset, int where)
|
||||
static int
|
||||
zfs_stat(struct open_file *f, struct stat *sb)
|
||||
{
|
||||
const spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa;
|
||||
struct devdesc *dev = f->f_devdata;
|
||||
const spa_t *spa = ((struct zfsmount *)dev->d_opendata)->spa;
|
||||
struct file *fp = (struct file *)f->f_fsdata;
|
||||
|
||||
return (zfs_dnode_stat(spa, &fp->f_dnode, sb));
|
||||
@ -222,7 +225,8 @@ zfs_stat(struct open_file *f, struct stat *sb)
|
||||
static int
|
||||
zfs_readdir(struct open_file *f, struct dirent *d)
|
||||
{
|
||||
const spa_t *spa = ((struct zfsmount *)f->f_devdata)->spa;
|
||||
struct devdesc *dev = f->f_devdata;
|
||||
const spa_t *spa = ((struct zfsmount *)dev->d_opendata)->spa;
|
||||
struct file *fp = (struct file *)f->f_fsdata;
|
||||
mzap_ent_phys_t mze;
|
||||
struct stat sb;
|
||||
@ -1586,8 +1590,7 @@ zfs_dev_open(struct open_file *f, ...)
|
||||
rv = zfs_mount(devformat(&dev->dd), NULL, (void **)&mount);
|
||||
|
||||
if (rv == 0) {
|
||||
f->f_devdata = mount;
|
||||
free(dev);
|
||||
dev->dd.d_opendata = mount;
|
||||
}
|
||||
return (rv);
|
||||
}
|
||||
@ -1595,25 +1598,18 @@ zfs_dev_open(struct open_file *f, ...)
|
||||
static int
|
||||
zfs_dev_close(struct open_file *f)
|
||||
{
|
||||
struct devdesc *dev;
|
||||
struct zfsmount *mnt, *mount;
|
||||
|
||||
mnt = f->f_devdata;
|
||||
dev = f->f_devdata;
|
||||
mnt = dev->d_opendata;
|
||||
|
||||
STAILQ_FOREACH(mount, &zfsmount, next) {
|
||||
if (mnt->spa->spa_guid == mount->spa->spa_guid)
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* devclose() will free f->f_devdata, but since we do have
|
||||
* pointer to zfsmount structure in f->f_devdata, and
|
||||
* zfs_unmount() will also free the zfsmount structure,
|
||||
* we will get double free. To prevent double free,
|
||||
* we must set f_devdata to NULL there.
|
||||
*/
|
||||
if (mount != NULL)
|
||||
f->f_devdata = NULL;
|
||||
|
||||
/* XXX */
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user