diff options
author | Renato Botelho <renato@netgate.com> | 2016-06-14 14:40:19 -0500 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-06-14 14:40:19 -0500 |
commit | 20a32898b6944f9ebcdbb846253d812943036066 (patch) | |
tree | 2d3bb1c4acf6d65a66c132d4c59643a3e99dfe34 /sys/fs | |
parent | 4fdb7654ef71cc3e4f0353cc46f28f652cd35605 (diff) | |
parent | a048478c507785f68e86db1a32431aa36773ee06 (diff) | |
download | FreeBSD-src-20a32898b6944f9ebcdbb846253d812943036066.zip FreeBSD-src-20a32898b6944f9ebcdbb846253d812943036066.tar.gz |
Merge remote-tracking branch 'origin/master' into devel-11
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/ext2fs/ext2_alloc.c | 4 | ||||
-rw-r--r-- | sys/fs/ext2fs/ext2_bmap.c | 43 | ||||
-rw-r--r-- | sys/fs/ext2fs/ext2_extents.h | 4 | ||||
-rw-r--r-- | sys/fs/ext2fs/ext2_vfsops.c | 22 | ||||
-rw-r--r-- | sys/fs/ext2fs/ext2fs.h | 18 | ||||
-rw-r--r-- | sys/fs/nfsclient/nfs_clvfsops.c | 63 |
6 files changed, 67 insertions, 87 deletions
diff --git a/sys/fs/ext2fs/ext2_alloc.c b/sys/fs/ext2fs/ext2_alloc.c index 35e24c3..e0201cc 100644 --- a/sys/fs/ext2fs/ext2_alloc.c +++ b/sys/fs/ext2fs/ext2_alloc.c @@ -407,9 +407,11 @@ ext2_valloc(struct vnode *pvp, int mode, struct ucred *cred, struct vnode **vpp) /* * Set up a new generation number for this inode. + * Avoid zero values. */ - while (ip->i_gen == 0 || ++ip->i_gen == 0) + do { ip->i_gen = arc4random(); + } while ( ip->i_gen == 0); vfs_timestamp(&ts); ip->i_birthtime = ts.tv_sec; diff --git a/sys/fs/ext2fs/ext2_bmap.c b/sys/fs/ext2fs/ext2_bmap.c index 7966b9b..6f4ec34 100644 --- a/sys/fs/ext2fs/ext2_bmap.c +++ b/sys/fs/ext2fs/ext2_bmap.c @@ -86,8 +86,8 @@ ext2_bmap(struct vop_bmap_args *ap) } /* - * This function converts the logical block number of a file to - * its physical block number on the disk within ext4 extents. + * Convert the logical block number of a file to its physical block number + * on the disk within ext4 extents. */ static int ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bnp, int *runp, int *runb) @@ -97,7 +97,7 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bnp, int *runp, int *runb) struct ext4_extent *ep; struct ext4_extent_path path = { .ep_bp = NULL }; daddr_t lbn; - int ret = 0; + int error; ip = VTOI(vp); fs = ip->i_e2fs; @@ -105,9 +105,9 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bnp, int *runp, int *runb) if (runp != NULL) *runp = 0; - if (runb != NULL) *runb = 0; + error = 0; ext4_ext_find_extent(fs, ip, lbn, &path); if (path.ep_is_sparse) { @@ -118,29 +118,28 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bnp, int *runp, int *runb) if (runb != NULL) *runb = lbn - path.ep_sparse_ext.e_blk; } else { - ep = path.ep_ext; - if (ep == NULL) - ret = EIO; - else { - *bnp = fsbtodb(fs, lbn - ep->e_blk + - (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32)); - - if (*bnp == 0) - *bnp = -1; - - if (runp != NULL) - *runp = ep->e_len - (lbn - ep->e_blk) - 1; - if (runb != NULL) - *runb = lbn - ep->e_blk; + if (path.ep_ext == NULL) { + error = EIO; + goto out; } + ep = path.ep_ext; + *bnp = fsbtodb(fs, lbn - ep->e_blk + + (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32)); + + if (*bnp == 0) + *bnp = -1; + + if (runp != NULL) + *runp = ep->e_len - (lbn - ep->e_blk) - 1; + if (runb != NULL) + *runb = lbn - ep->e_blk; } - if (path.ep_bp != NULL) { +out: + if (path.ep_bp != NULL) brelse(path.ep_bp); - path.ep_bp = NULL; - } - return (ret); + return (error); } /* diff --git a/sys/fs/ext2fs/ext2_extents.h b/sys/fs/ext2fs/ext2_extents.h index 70eb685..b6a7fc2 100644 --- a/sys/fs/ext2fs/ext2_extents.h +++ b/sys/fs/ext2fs/ext2_extents.h @@ -40,8 +40,8 @@ * Ext4 file system extent on disk. */ struct ext4_extent { - uint32_t e_blk; /* first logical block */ - uint16_t e_len; /* number of blocks */ + uint32_t e_blk; /* first logical block */ + uint16_t e_len; /* number of blocks */ uint16_t e_start_hi; /* high 16 bits of physical block */ uint32_t e_start_lo; /* low 32 bits of physical block */ }; diff --git a/sys/fs/ext2fs/ext2_vfsops.c b/sys/fs/ext2fs/ext2_vfsops.c index 9f73357..2083fb6 100644 --- a/sys/fs/ext2fs/ext2_vfsops.c +++ b/sys/fs/ext2fs/ext2_vfsops.c @@ -158,11 +158,9 @@ ext2_mount(struct mount *mp) } fs->e2fs_ronly = 1; vfs_flagopt(opts, "ro", &mp->mnt_flag, MNT_RDONLY); - DROP_GIANT(); g_topology_lock(); g_access(ump->um_cp, 0, -1, 0); g_topology_unlock(); - PICKUP_GIANT(); } if (!error && (mp->mnt_flag & MNT_RELOAD)) error = ext2_reload(mp, td); @@ -187,11 +185,9 @@ ext2_mount(struct mount *mp) return (error); } VOP_UNLOCK(devvp, 0); - DROP_GIANT(); g_topology_lock(); error = g_access(ump->um_cp, 0, 1, 0); g_topology_unlock(); - PICKUP_GIANT(); if (error) return (error); @@ -547,11 +543,9 @@ ext2_mountfs(struct vnode *devvp, struct mount *mp) ronly = vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0); /* XXX: use VOP_ACESS to check FS perms */ - DROP_GIANT(); g_topology_lock(); error = g_vfs_open(devvp, &cp, "ext2fs", ronly ? 0 : 1); g_topology_unlock(); - PICKUP_GIANT(); VOP_UNLOCK(devvp, 0); if (error) return (error); @@ -559,11 +553,9 @@ ext2_mountfs(struct vnode *devvp, struct mount *mp) /* XXX: should we check for some sectorsize or 512 instead? */ if (((SBSIZE % cp->provider->sectorsize) != 0) || (SBSIZE < cp->provider->sectorsize)) { - DROP_GIANT(); g_topology_lock(); g_vfs_close(cp); g_topology_unlock(); - PICKUP_GIANT(); return (EINVAL); } @@ -683,11 +675,9 @@ out: if (bp) brelse(bp); if (cp != NULL) { - DROP_GIANT(); g_topology_lock(); g_vfs_close(cp); g_topology_unlock(); - PICKUP_GIANT(); } if (ump) { mtx_destroy(EXT2_MTX(ump)); @@ -729,11 +719,9 @@ ext2_unmount(struct mount *mp, int mntflags) ext2_sbupdate(ump, MNT_WAIT); } - DROP_GIANT(); g_topology_lock(); g_vfs_close(ump->um_cp); g_topology_unlock(); - PICKUP_GIANT(); vrele(ump->um_devvp); sump = fs->e2fs_clustersum; for (i = 0; i < fs->e2fs_gcount; i++, sump++) @@ -993,16 +981,6 @@ ext2_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp) * Finish inode initialization. */ - /* - * Set up a generation number for this inode if it does not - * already have one. This should only happen on old filesystems. - */ - if (ip->i_gen == 0) { - while (ip->i_gen == 0) - ip->i_gen = arc4random(); - if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0) - ip->i_flag |= IN_MODIFIED; - } *vpp = vp; return (0); } diff --git a/sys/fs/ext2fs/ext2fs.h b/sys/fs/ext2fs/ext2fs.h index c23f2a2..b005ddd 100644 --- a/sys/fs/ext2fs/ext2fs.h +++ b/sys/fs/ext2fs/ext2fs.h @@ -87,7 +87,7 @@ struct ext2fs { uint32_t e3fs_journal_dev; /* device number of journal file */ uint32_t e3fs_last_orphan; /* start of list of inodes to delete */ uint32_t e3fs_hash_seed[4]; /* HTREE hash seed */ - char e3fs_def_hash_version; /* Default hash version to use */ + char e3fs_def_hash_version;/* Default hash version to use */ char e3fs_jnl_backup_type; uint16_t e3fs_desc_size; /* size of group descriptor */ uint32_t e3fs_default_mount_opts; @@ -97,13 +97,13 @@ struct ext2fs { uint32_t e4fs_bcount_hi; /* high bits of blocks count */ uint32_t e4fs_rbcount_hi; /* high bits of reserved blocks count */ uint32_t e4fs_fbcount_hi; /* high bits of free blocks count */ - uint16_t e4fs_min_extra_isize; /* all inodes have at least some bytes */ - uint16_t e4fs_want_extra_isize; /* inodes must reserve some bytes */ + uint16_t e4fs_min_extra_isize; /* all inodes have some bytes */ + uint16_t e4fs_want_extra_isize;/* inodes must reserve some bytes */ uint32_t e4fs_flags; /* miscellaneous flags */ uint16_t e4fs_raid_stride; /* RAID stride */ - uint16_t e4fs_mmpintv; /* number of seconds to wait in MMP checking */ + uint16_t e4fs_mmpintv; /* seconds to wait in MMP checking */ uint64_t e4fs_mmpblk; /* block for multi-mount protection */ - uint32_t e4fs_raid_stripe_wid; /* blocks on all data disks (N * stride) */ + uint32_t e4fs_raid_stripe_wid; /* blocks on data disks (N * stride) */ uint8_t e4fs_log_gpf; /* FLEX_BG group size */ uint8_t e4fs_chksum_type; /* metadata checksum algorithm used */ uint8_t e4fs_encrypt; /* versioning level for encryption */ @@ -117,7 +117,7 @@ struct ext2fs { uint32_t e4fs_first_errtime; /* first time an error happened */ uint32_t e4fs_first_errino; /* inode involved in first error */ uint64_t e4fs_first_errblk; /* block involved of first error */ - uint8_t e4fs_first_errfunc[32]; /* function where error happened */ + uint8_t e4fs_first_errfunc[32];/* function where error happened */ uint32_t e4fs_first_errline; /* line number where error happened */ uint32_t e4fs_last_errtime; /* most recent time of an error */ uint32_t e4fs_last_errino; /* inode involved in last error */ @@ -127,10 +127,10 @@ struct ext2fs { uint8_t e4fs_mount_opts[64]; uint32_t e4fs_usrquota_inum; /* inode for tracking user quota */ uint32_t e4fs_grpquota_inum; /* inode for tracking group quota */ - uint32_t e4fs_overhead_clusters; /* overhead blocks/clusters */ + uint32_t e4fs_overhead_clusters;/* overhead blocks/clusters */ uint32_t e4fs_backup_bgs[2]; /* groups with sparse_super2 SBs */ - uint8_t e4fs_encrypt_algos[4]; /* encryption algorithms in use */ - uint8_t e4fs_encrypt_pw_salt[16]; /* salt used for string2key */ + uint8_t e4fs_encrypt_algos[4];/* encryption algorithms in use */ + uint8_t e4fs_encrypt_pw_salt[16];/* salt used for string2key */ uint32_t e4fs_lpf_ino; /* location of the lost+found inode */ uint32_t e4fs_proj_quota_inum; /* inode for tracking project quota */ uint32_t e4fs_chksum_seed; /* checksum seed */ diff --git a/sys/fs/nfsclient/nfs_clvfsops.c b/sys/fs/nfsclient/nfs_clvfsops.c index db1ee9d..a3e2c70 100644 --- a/sys/fs/nfsclient/nfs_clvfsops.c +++ b/sys/fs/nfsclient/nfs_clvfsops.c @@ -763,37 +763,37 @@ nfs_mount_parse_from(struct vfsoptlist *opts, char **hostnamep, /* * This part comes from sbin/mount_nfs/mount_nfs.c:getnfsargs(). */ - if (*spec == '[' && (delimp = strchr(spec + 1, ']')) != NULL && - *(delimp + 1) == ':') { - hostp = spec + 1; - spec = delimp + 2; - have_bracket = 1; - } else if ((delimp = strrchr(spec, ':')) != NULL) { - hostp = spec; - spec = delimp + 1; - } else if ((delimp = strrchr(spec, '@')) != NULL) { - printf("%s: path@server syntax is deprecated, " + if (*spec == '[' && (delimp = strchr(spec + 1, ']')) != NULL && + *(delimp + 1) == ':') { + hostp = spec + 1; + spec = delimp + 2; + have_bracket = 1; + } else if ((delimp = strrchr(spec, ':')) != NULL) { + hostp = spec; + spec = delimp + 1; + } else if ((delimp = strrchr(spec, '@')) != NULL) { + printf("%s: path@server syntax is deprecated, " "use server:path\n", __func__); - hostp = delimp + 1; - } else { - printf("%s: no <host>:<dirpath> nfs-name\n", __func__); - return (EINVAL); - } - *delimp = '\0'; - - /* - * If there has been a trailing slash at mounttime it seems - * that some mountd implementations fail to remove the mount - * entries from their mountlist while unmounting. - */ - for (speclen = strlen(spec); - speclen > 1 && spec[speclen - 1] == '/'; - speclen--) - spec[speclen - 1] = '\0'; - if (strlen(hostp) + strlen(spec) + 1 > MNAMELEN) { - printf("%s: %s:%s: name too long", __func__, hostp, spec); - return (EINVAL); - } + hostp = delimp + 1; + } else { + printf("%s: no <host>:<dirpath> nfs-name\n", __func__); + return (EINVAL); + } + *delimp = '\0'; + + /* + * If there has been a trailing slash at mounttime it seems + * that some mountd implementations fail to remove the mount + * entries from their mountlist while unmounting. + */ + for (speclen = strlen(spec); + speclen > 1 && spec[speclen - 1] == '/'; + speclen--) + spec[speclen - 1] = '\0'; + if (strlen(hostp) + strlen(spec) + 1 > MNAMELEN) { + printf("%s: %s:%s: name too long", __func__, hostp, spec); + return (EINVAL); + } /* Make both '@' and ':' notations equal */ if (*hostp != '\0') { len = strlen(hostp); @@ -806,7 +806,8 @@ nfs_mount_parse_from(struct vfsoptlist *opts, char **hostnamep, nam[len + offset++] = ':'; memmove(nam + len + offset, spec, speclen); nam[len + speclen + offset] = '\0'; - } + } else + nam[0] = '\0'; /* * XXX: IPv6 |