Makes sense to me martin. 

Kill it with fire

ok beck@

On Sat, May 21, 2016 at 10:49:29PM +0200, Martin Natano wrote:
> VOP_ALLOCBLKS() and related code is unused since the removal of
> cluster_write(). This diff even shrinks /bsd by 8kb. Ok?
> 
> natano
> 
> 
> Index: sbin/sysctl/sysctl.8
> ===================================================================
> RCS file: /cvs/src/sbin/sysctl/sysctl.8,v
> retrieving revision 1.194
> diff -u -p -r1.194 sysctl.8
> --- sbin/sysctl/sysctl.8      19 May 2016 11:34:40 -0000      1.194
> +++ sbin/sysctl/sysctl.8      21 May 2016 20:36:12 -0000
> @@ -334,11 +334,6 @@ and a few require a kernel compiled with
>  .It net.pipex.outq.drops=0 Ta integer Ta no
>  .It debug.syncprt Ta integer Ta yes
>  .It debug.busyprt Ta integer Ta yes
> -.It debug.doclusterread Ta integer Ta yes
> -.It debug.doclusterwrite Ta integer Ta yes
> -.It debug.doreallocblks Ta integer Ta yes
> -.It debug.doasyncfree Ta integer Ta yes
> -.It debug.prtrealloc Ta integer Ta yes
>  .It hw.machine Ta string Ta no
>  .It hw.model Ta string Ta no
>  .It hw.ncpu Ta integer Ta no
> @@ -384,10 +379,6 @@ and a few require a kernel compiled with
>  .It ddb.log Ta integer Ta yes
>  .It ddb.trigger Ta integer Ta yes
>  .It vfs.mounts.* Ta struct Ta no
> -.It vfs.ffs.doclusterread Ta integer Ta yes
> -.It vfs.ffs.doclusterwrite Ta integer Ta yes
> -.It vfs.ffs.doreallocblks Ta integer Ta yes
> -.It vfs.ffs.doasyncfree Ta integer Ta yes
>  .It vfs.ffs.max_softdeps Ta integer Ta yes
>  .It vfs.ffs.sd_tickdelay Ta integer Ta yes
>  .It vfs.ffs.sd_worklist_push Ta integer Ta no
> Index: share/man/man9/VOP_LOOKUP.9
> ===================================================================
> RCS file: /cvs/src/share/man/man9/VOP_LOOKUP.9,v
> retrieving revision 1.34
> diff -u -p -r1.34 VOP_LOOKUP.9
> --- share/man/man9/VOP_LOOKUP.9       19 Mar 2016 15:03:55 -0000      1.34
> +++ share/man/man9/VOP_LOOKUP.9       21 May 2016 20:36:12 -0000
> @@ -52,7 +52,6 @@
>  .Nm VOP_READ ,
>  .Nm VOP_READDIR ,
>  .Nm VOP_READLINK ,
> -.Nm VOP_REALLOCBLKS ,
>  .Nm VOP_RECLAIM ,
>  .Nm VOP_REMOVE ,
>  .Nm VOP_RENAME ,
> @@ -226,11 +225,6 @@
>  .Fa "struct ucred *cred"
>  .Fc
>  .Ft int
> -.Fo VOP_REALLOCBLKS
> -.Fa "struct vnode *vp"
> -.Fa "struct cluster_save *buflist"
> -.Fc
> -.Ft int
>  .Fo VOP_RECLAIM
>  .Fa "struct vnode *vp"
>  .Fa "struct proc *p"
> @@ -765,16 +759,6 @@ Read a symbolic link and return the targ
>  .Fa uio .
>  .Fa vp
>  is locked on entry and exit and must be a symlink.
> -.Pp
> -.It Fn VOP_REALLOCBLKS vp buflist
> -Called by the VFS write clustering code.
> -It gives the file system an opportunity to rearrange the on-disk blocks
> -for a file to reduce fragmentation.
> -.Fa vp
> -is the locked vnode for the file, and
> -.Fa buflist
> -is a cluster of the outstanding buffers about to be written.
> -Currently, only FFS implements this call.
>  .Pp
>  .It Fn VOP_RECLAIM vp p
>  Used by
> Index: sys/kern/vfs_vops.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/vfs_vops.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 vfs_vops.c
> --- sys/kern/vfs_vops.c       19 Mar 2016 12:04:15 -0000      1.15
> +++ sys/kern/vfs_vops.c       21 May 2016 20:36:13 -0000
> @@ -612,21 +612,6 @@ VOP_ADVLOCK(struct vnode *vp, void *id, 
>  }
>  
>  int
> -VOP_REALLOCBLKS(struct vnode *vp, struct cluster_save *buflist)
> -{
> -     struct vop_reallocblks_args a;
> -     a.a_vp = vp;
> -     a.a_buflist = buflist;
> -
> -     ASSERT_VP_ISLOCKED(vp);
> -
> -     if (vp->v_op->vop_reallocblks == NULL)
> -             return (EOPNOTSUPP);
> -
> -     return ((vp->v_op->vop_reallocblks)(&a));
> -}
> -
> -int
>  VOP_STRATEGY(struct buf *bp)
>  {
>       struct vop_strategy_args a;
> Index: sys/sys/buf.h
> ===================================================================
> RCS file: /cvs/src/sys/sys/buf.h,v
> retrieving revision 1.102
> diff -u -p -r1.102 buf.h
> --- sys/sys/buf.h     10 Mar 2016 06:52:37 -0000      1.102
> +++ sys/sys/buf.h     21 May 2016 20:36:13 -0000
> @@ -229,20 +229,6 @@ struct bufcache {
>      "\025SCANNED\026DAEMON\027RELEASED\030WARM\031COLD\032BC\033DMA"
>  
>  /*
> - * This structure describes a clustered I/O.  It is stored in the b_saveaddr
> - * field of the buffer on which I/O is done.  At I/O completion, cluster
> - * callback uses the structure to parcel I/O's to individual buffers, and
> - * then free's this structure.
> - */
> -struct cluster_save {
> -     long    bs_bcount;              /* Saved b_bcount. */
> -     long    bs_bufsize;             /* Saved b_bufsize. */
> -     void    *bs_saveaddr;           /* Saved b_addr. */
> -     int     bs_nchildren;           /* Number of associated buffers. */
> -     struct buf **bs_children;       /* List of associated buffers. */
> -};
> -
> -/*
>   * Zero out the buffer's data area.
>   */
>  #define      clrbuf(bp) {                                                    
> \
> Index: sys/sys/vnode.h
> ===================================================================
> RCS file: /cvs/src/sys/sys/vnode.h,v
> retrieving revision 1.134
> diff -u -p -r1.134 vnode.h
> --- sys/sys/vnode.h   19 Mar 2016 12:04:16 -0000      1.134
> +++ sys/sys/vnode.h   21 May 2016 20:36:13 -0000
> @@ -276,7 +276,6 @@ struct vops {
>       int     (*vop_read)(void *);
>       int     (*vop_readdir)(void *);
>       int     (*vop_readlink)(void *);
> -     int     (*vop_reallocblks)(void *);
>       int     (*vop_reclaim)(void *);
>       int     (*vop_remove)(void *);
>       int     (*vop_rename)(void *);
> @@ -549,12 +548,6 @@ struct vop_advlock_args {
>       int a_flags;
>  };
>  int VOP_ADVLOCK(struct vnode *, void *, int, struct flock *, int);
> -
> -struct vop_reallocblks_args {
> -     struct vnode *a_vp;
> -     struct cluster_save *a_buflist;
> -};
> -int VOP_REALLOCBLKS(struct vnode *, struct cluster_save *);
>  
>  /* Special cases: */
>  struct vop_strategy_args {
> Index: sys/ufs/ffs/ffs_alloc.c
> ===================================================================
> RCS file: /cvs/src/sys/ufs/ffs/ffs_alloc.c,v
> retrieving revision 1.106
> diff -u -p -r1.106 ffs_alloc.c
> --- sys/ufs/ffs/ffs_alloc.c   28 Nov 2015 21:52:02 -0000      1.106
> +++ sys/ufs/ffs/ffs_alloc.c   21 May 2016 20:36:13 -0000
> @@ -66,7 +66,6 @@
>  daddr_t              ffs_alloccg(struct inode *, int, daddr_t, int);
>  struct buf * ffs_cgread(struct fs *, struct inode *, int);
>  daddr_t              ffs_alloccgblk(struct inode *, struct buf *, daddr_t);
> -daddr_t              ffs_clusteralloc(struct inode *, int, daddr_t, int);
>  ufsino_t     ffs_dirpref(struct inode *);
>  daddr_t              ffs_fragextend(struct inode *, int, daddr_t, int, int);
>  daddr_t              ffs_hashalloc(struct inode *, int, daddr_t, int,
> @@ -74,15 +73,6 @@ daddr_t            ffs_hashalloc(struct inode *, i
>  daddr_t              ffs_nodealloccg(struct inode *, int, daddr_t, int);
>  daddr_t              ffs_mapsearch(struct fs *, struct cg *, daddr_t, int);
>  
> -int ffs1_reallocblks(void *);
> -#ifdef FFS2
> -int ffs2_reallocblks(void *);
> -#endif
> -
> -#ifdef DIAGNOSTIC
> -int      ffs_checkblk(struct inode *, daddr_t, long);
> -#endif
> -
>  static const struct timeval  fserr_interval = { 2, 0 };
>  
>  
> @@ -347,465 +337,6 @@ error:
>  }
>  
>  /*
> - * Reallocate a sequence of blocks into a contiguous sequence of blocks.
> - *
> - * The vnode and an array of buffer pointers for a range of sequential
> - * logical blocks to be made contiguous are given. The allocator attempts
> - * to find a range of sequential blocks starting as close as possible to
> - * an fs_rotdelay offset from the end of the allocation for the logical
> - * block immediately preceding the current range. If successful, the
> - * physical block numbers in the buffer pointers and in the inode are
> - * changed to reflect the new allocation. If unsuccessful, the allocation
> - * is left unchanged. The success in doing the reallocation is returned.
> - * Note that the error return is not reflected back to the user. Rather
> - * the previous block allocation will be used.
> - */
> -
> -int doasyncfree = 1;
> -int doreallocblks = 1;
> -int prtrealloc = 0;
> -
> -int
> -ffs1_reallocblks(void *v)
> -{
> -     struct vop_reallocblks_args *ap = v;
> -     struct fs *fs;
> -     struct inode *ip;
> -     struct vnode *vp;
> -     struct buf *sbp, *ebp;
> -     int32_t *bap, *sbap, *ebap = NULL;
> -     struct cluster_save *buflist;
> -     daddr_t start_lbn, end_lbn, soff, newblk, blkno;
> -     struct indir start_ap[NIADDR + 1], end_ap[NIADDR + 1], *idp;
> -     int i, len, start_lvl, end_lvl, pref, ssize;
> -
> -     vp = ap->a_vp;
> -     ip = VTOI(vp);
> -     fs = ip->i_fs;
> -     if (fs->fs_contigsumsize <= 0)
> -             return (ENOSPC);
> -     buflist = ap->a_buflist;
> -     len = buflist->bs_nchildren;
> -     start_lbn = buflist->bs_children[0]->b_lblkno;
> -     end_lbn = start_lbn + len - 1;
> -
> -#ifdef DIAGNOSTIC
> -     for (i = 0; i < len; i++)
> -             if (!ffs_checkblk(ip,
> -                dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize))
> -                     panic("ffs1_reallocblks: unallocated block 1");
> -
> -     for (i = 1; i < len; i++)
> -             if (buflist->bs_children[i]->b_lblkno != start_lbn + i)
> -                     panic("ffs1_reallocblks: non-logical cluster");
> -
> -     blkno = buflist->bs_children[0]->b_blkno;
> -     ssize = fsbtodb(fs, fs->fs_frag);
> -     for (i = 1; i < len - 1; i++)
> -             if (buflist->bs_children[i]->b_blkno != blkno + (i * ssize))
> -                     panic("ffs1_reallocblks: non-physical cluster %d", i);
> -#endif
> -     /*
> -      * If the latest allocation is in a new cylinder group, assume that
> -      * the filesystem has decided to move and do not force it back to
> -      * the previous cylinder group.
> -      */
> -     if (dtog(fs, dbtofsb(fs, buflist->bs_children[0]->b_blkno)) !=
> -         dtog(fs, dbtofsb(fs, buflist->bs_children[len - 1]->b_blkno)))
> -             return (ENOSPC);
> -     if (ufs_getlbns(vp, start_lbn, start_ap, &start_lvl) ||
> -         ufs_getlbns(vp, end_lbn, end_ap, &end_lvl))
> -             return (ENOSPC);
> -     /*
> -      * Get the starting offset and block map for the first block.
> -      */
> -     if (start_lvl == 0) {
> -             sbap = &ip->i_ffs1_db[0];
> -             soff = start_lbn;
> -     } else {
> -             idp = &start_ap[start_lvl - 1];
> -             if (bread(vp, idp->in_lbn, (int)fs->fs_bsize, &sbp)) {
> -                     brelse(sbp);
> -                     return (ENOSPC);
> -             }
> -             sbap = (int32_t *)sbp->b_data;
> -             soff = idp->in_off;
> -     }
> -     /*
> -      * Find the preferred location for the cluster.
> -      */
> -     pref = ffs1_blkpref(ip, start_lbn, soff, sbap);
> -     /*
> -      * If the block range spans two block maps, get the second map.
> -      */
> -     if (end_lvl == 0 || (idp = &end_ap[end_lvl - 1])->in_off + 1 >= len) {
> -             ssize = len;
> -     } else {
> -#ifdef DIAGNOSTIC
> -             if (start_lvl > 1 &&
> -                 start_ap[start_lvl-1].in_lbn == idp->in_lbn)
> -                     panic("ffs1_reallocblk: start == end");
> -#endif
> -             ssize = len - (idp->in_off + 1);
> -             if (bread(vp, idp->in_lbn, (int)fs->fs_bsize, &ebp))
> -                     goto fail;
> -             ebap = (int32_t *)ebp->b_data;
> -     }
> -     /*
> -      * Search the block map looking for an allocation of the desired size.
> -      */
> -     if ((newblk = ffs_hashalloc(ip, dtog(fs, pref), pref, len,
> -         ffs_clusteralloc)) == 0)
> -             goto fail;
> -     /*
> -      * We have found a new contiguous block.
> -      *
> -      * First we have to replace the old block pointers with the new
> -      * block pointers in the inode and indirect blocks associated
> -      * with the file.
> -      */
> -#ifdef DEBUG
> -     if (prtrealloc)
> -             printf("realloc: ino %u, lbns %lld-%lld\n\told:", ip->i_number,
> -                 (long long)start_lbn, (long long)end_lbn);
> -#endif
> -     blkno = newblk;
> -     for (bap = &sbap[soff], i = 0; i < len; i++, blkno += fs->fs_frag) {
> -             if (i == ssize) {
> -                     bap = ebap;
> -                     soff = -i;
> -             }
> -#ifdef DIAGNOSTIC
> -             if (!ffs_checkblk(ip,
> -                dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize))
> -                     panic("ffs1_reallocblks: unallocated block 2");
> -             if (dbtofsb(fs, buflist->bs_children[i]->b_blkno) != *bap)
> -                     panic("ffs1_reallocblks: alloc mismatch");
> -#endif
> -#ifdef DEBUG
> -             if (prtrealloc)
> -                     printf(" %d,", *bap);
> -#endif
> -             if (DOINGSOFTDEP(vp)) {
> -                     if (sbap == &ip->i_ffs1_db[0] && i < ssize)
> -                             softdep_setup_allocdirect(ip, start_lbn + i,
> -                                 blkno, *bap, fs->fs_bsize, fs->fs_bsize,
> -                                 buflist->bs_children[i]);
> -                     else
> -                             softdep_setup_allocindir_page(ip, start_lbn + i,
> -                                 i < ssize ? sbp : ebp, soff + i, blkno,
> -                                 *bap, buflist->bs_children[i]);
> -             }
> -
> -             *bap++ = blkno;
> -     }
> -     /*
> -      * Next we must write out the modified inode and indirect blocks.
> -      * For strict correctness, the writes should be synchronous since
> -      * the old block values may have been written to disk. In practise
> -      * they are almost never written, but if we are concerned about
> -      * strict correctness, the `doasyncfree' flag should be set to zero.
> -      *
> -      * The test on `doasyncfree' should be changed to test a flag
> -      * that shows whether the associated buffers and inodes have
> -      * been written. The flag should be set when the cluster is
> -      * started and cleared whenever the buffer or inode is flushed.
> -      * We can then check below to see if it is set, and do the
> -      * synchronous write only when it has been cleared.
> -      */
> -     if (sbap != &ip->i_ffs1_db[0]) {
> -             if (doasyncfree)
> -                     bdwrite(sbp);
> -             else
> -                     bwrite(sbp);
> -     } else {
> -             ip->i_flag |= IN_CHANGE | IN_UPDATE;
> -             if (!doasyncfree) {
> -                     UFS_UPDATE(ip, 1);
> -             }
> -     }
> -     if (ssize < len) {
> -             if (doasyncfree)
> -                     bdwrite(ebp);
> -             else
> -                     bwrite(ebp);
> -     }
> -     /*
> -      * Last, free the old blocks and assign the new blocks to the buffers.
> -      */
> -#ifdef DEBUG
> -     if (prtrealloc)
> -             printf("\n\tnew:");
> -#endif
> -     for (blkno = newblk, i = 0; i < len; i++, blkno += fs->fs_frag) {
> -             if (!DOINGSOFTDEP(vp))
> -                     ffs_blkfree(ip,
> -                         dbtofsb(fs, buflist->bs_children[i]->b_blkno),
> -                         fs->fs_bsize);
> -             buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno);
> -#ifdef DIAGNOSTIC
> -             if (!ffs_checkblk(ip,
> -                dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize))
> -                     panic("ffs1_reallocblks: unallocated block 3");
> -             if (prtrealloc)
> -                     printf(" %lld,", (long long)blkno);
> -#endif
> -     }
> -#ifdef DEBUG
> -     if (prtrealloc) {
> -             prtrealloc--;
> -             printf("\n");
> -     }
> -#endif
> -     return (0);
> -
> -fail:
> -     if (ssize < len)
> -             brelse(ebp);
> -     if (sbap != &ip->i_ffs1_db[0])
> -             brelse(sbp);
> -     return (ENOSPC);
> -}
> -
> -#ifdef FFS2
> -int
> -ffs2_reallocblks(void *v)
> -{
> -     struct vop_reallocblks_args *ap = v;
> -     struct fs *fs;
> -     struct inode *ip;
> -     struct vnode *vp;
> -     struct buf *sbp, *ebp;
> -     daddr_t *bap, *sbap, *ebap = NULL;
> -     struct cluster_save *buflist;
> -     daddr_t start_lbn, end_lbn;
> -     daddr_t soff, newblk, blkno, pref;
> -     struct indir start_ap[NIADDR + 1], end_ap[NIADDR + 1], *idp;
> -     int i, len, start_lvl, end_lvl, ssize;
> -
> -     vp = ap->a_vp;
> -     ip = VTOI(vp);
> -     fs = ip->i_fs;
> -
> -     if (fs->fs_contigsumsize <= 0)
> -             return (ENOSPC);
> -
> -     buflist = ap->a_buflist;
> -     len = buflist->bs_nchildren;
> -     start_lbn = buflist->bs_children[0]->b_lblkno;
> -     end_lbn = start_lbn + len - 1;
> -
> -#ifdef DIAGNOSTIC
> -     for (i = 0; i < len; i++)
> -             if (!ffs_checkblk(ip,
> -                dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize))
> -                     panic("ffs2_reallocblks: unallocated block 1");
> -
> -     for (i = 1; i < len; i++)
> -             if (buflist->bs_children[i]->b_lblkno != start_lbn + i)
> -                     panic("ffs2_reallocblks: non-logical cluster");
> -
> -     blkno = buflist->bs_children[0]->b_blkno;
> -     ssize = fsbtodb(fs, fs->fs_frag);
> -
> -     for (i = 1; i < len - 1; i++)
> -             if (buflist->bs_children[i]->b_blkno != blkno + (i * ssize))
> -                     panic("ffs2_reallocblks: non-physical cluster %d", i);
> -#endif
> -
> -     /*
> -      * If the latest allocation is in a new cylinder group, assume that
> -      * the filesystem has decided to move and do not force it back to
> -      * the previous cylinder group.
> -      */
> -     if (dtog(fs, dbtofsb(fs, buflist->bs_children[0]->b_blkno)) !=
> -         dtog(fs, dbtofsb(fs, buflist->bs_children[len - 1]->b_blkno)))
> -             return (ENOSPC);
> -     if (ufs_getlbns(vp, start_lbn, start_ap, &start_lvl) ||
> -         ufs_getlbns(vp, end_lbn, end_ap, &end_lvl))
> -             return (ENOSPC);
> -
> -     /*
> -      * Get the starting offset and block map for the first block.
> -      */
> -     if (start_lvl == 0) {
> -             sbap = &ip->i_din2->di_db[0];
> -             soff = start_lbn;
> -     } else {
> -             idp = &start_ap[start_lvl - 1];
> -             if (bread(vp, idp->in_lbn, (int)fs->fs_bsize, &sbp)) {
> -                     brelse(sbp);
> -                     return (ENOSPC);
> -             }
> -             sbap = (daddr_t *)sbp->b_data;
> -             soff = idp->in_off;
> -     }
> -
> -     /*
> -      * If the block range spans two block maps, get the second map.
> -      */
> -     if (end_lvl == 0 || (idp = &end_ap[end_lvl - 1])->in_off + 1 >= len) {
> -             ssize = len;
> -     } else {
> -#ifdef DIAGNOSTIC
> -             if (start_ap[start_lvl-1].in_lbn == idp->in_lbn)
> -                     panic("ffs2_reallocblk: start == end");
> -#endif
> -             ssize = len - (idp->in_off + 1);
> -             if (bread(vp, idp->in_lbn, (int)fs->fs_bsize, &ebp))
> -                     goto fail;
> -             ebap = (daddr_t *)ebp->b_data;
> -     }
> -
> -     /*
> -      * Find the preferred location for the cluster.
> -      */
> -     pref = ffs2_blkpref(ip, start_lbn, soff, sbap);
> -
> -     /*
> -      * Search the block map looking for an allocation of the desired size.
> -      */
> -     if ((newblk = ffs_hashalloc(ip, dtog(fs, pref), pref,
> -         len, ffs_clusteralloc)) == 0)
> -             goto fail;
> -
> -     /*
> -      * We have found a new contiguous block.
> -      *
> -      * First we have to replace the old block pointers with the new
> -      * block pointers in the inode and indirect blocks associated
> -      * with the file.
> -      */
> -#ifdef DEBUG
> -     if (prtrealloc)
> -             printf("realloc: ino %u, lbns %lld-%lld\n\told:", ip->i_number,
> -                 (long long)start_lbn, (long long)end_lbn);
> -#endif
> -
> -     blkno = newblk;
> -
> -     for (bap = &sbap[soff], i = 0; i < len; i++, blkno += fs->fs_frag) {
> -             if (i == ssize) {
> -                     bap = ebap;
> -                     soff = -i;
> -             }
> -#ifdef DIAGNOSTIC
> -             if (!ffs_checkblk(ip,
> -                dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize))
> -                     panic("ffs2_reallocblks: unallocated block 2");
> -             if (dbtofsb(fs, buflist->bs_children[i]->b_blkno) != *bap)
> -                     panic("ffs2_reallocblks: alloc mismatch");
> -#endif
> -#ifdef DEBUG
> -             if (prtrealloc)
> -                     printf(" %lld,", (long long)*bap);
> -#endif
> -             if (DOINGSOFTDEP(vp)) {
> -                     if (sbap == &ip->i_din2->di_db[0] && i < ssize)
> -                             softdep_setup_allocdirect(ip, start_lbn + i,
> -                                 blkno, *bap, fs->fs_bsize, fs->fs_bsize,
> -                                 buflist->bs_children[i]);
> -                     else
> -                             softdep_setup_allocindir_page(ip, start_lbn + i,
> -                                 i < ssize ? sbp : ebp, soff + i, blkno,
> -                                 *bap, buflist->bs_children[i]);
> -             }
> -             *bap++ = blkno;
> -     }
> -
> -     /*
> -      * Next we must write out the modified inode and indirect blocks.
> -      * For strict correctness, the writes should be synchronous since
> -      * the old block values may have been written to disk. In practise
> -      * they are almost never written, but if we are concerned about
> -      * strict correctness, the `doasyncfree' flag should be set to zero.
> -      *
> -      * The test on `doasyncfree' should be changed to test a flag
> -      * that shows whether the associated buffers and inodes have
> -      * been written. The flag should be set when the cluster is
> -      * started and cleared whenever the buffer or inode is flushed.
> -      * We can then check below to see if it is set, and do the
> -      * synchronous write only when it has been cleared.
> -      */
> -     if (sbap != &ip->i_din2->di_db[0]) {
> -             if (doasyncfree)
> -                     bdwrite(sbp);
> -             else
> -                     bwrite(sbp);
> -     } else {
> -             ip->i_flag |= IN_CHANGE | IN_UPDATE;
> -             if (!doasyncfree)
> -                     ffs_update(ip, 1);
> -     }
> -
> -     if (ssize < len) {
> -             if (doasyncfree)
> -                     bdwrite(ebp);
> -             else
> -                     bwrite(ebp);
> -     }
> -
> -     /*
> -      * Last, free the old blocks and assign the new blocks to the buffers.
> -      */
> -#ifdef DEBUG
> -     if (prtrealloc)
> -             printf("\n\tnew:");
> -#endif
> -     for (blkno = newblk, i = 0; i < len; i++, blkno += fs->fs_frag) {
> -             if (!DOINGSOFTDEP(vp))
> -                     ffs_blkfree(ip, dbtofsb(fs,
> -                         buflist->bs_children[i]->b_blkno), fs->fs_bsize);
> -             buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno);
> -#ifdef DIAGNOSTIC
> -             if (!ffs_checkblk(ip,
> -                dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize))
> -                     panic("ffs2_reallocblks: unallocated block 3");
> -#endif
> -#ifdef DEBUG
> -             if (prtrealloc)
> -                     printf(" %lld,", (long long)blkno);
> -#endif
> -     }
> -#ifdef DEBUG
> -     if (prtrealloc) {
> -             prtrealloc--;
> -             printf("\n");
> -     }
> -#endif
> -
> -     return (0);
> -
> -fail:
> -     if (ssize < len)
> -             brelse(ebp);
> -
> -     if (sbap != &ip->i_din2->di_db[0])
> -             brelse(sbp);
> -
> -     return (ENOSPC);
> -}
> -#endif /* FFS2 */
> -
> -int
> -ffs_reallocblks(void *v)
> -{
> -#ifdef FFS2
> -     struct vop_reallocblks_args *ap = v;
> -#endif
> -
> -     if (!doreallocblks)
> -             return (ENOSPC);
> -
> -#ifdef FFS2
> -     if (VTOI(ap->a_vp)->i_ump->um_fstype == UM_UFS2)
> -             return (ffs2_reallocblks(v));
> -#endif
> -
> -     return (ffs1_reallocblks(v));
> -}
> -
> -/*
>   * Allocate an inode in the file system.
>   *
>   * If allocating a directory, use ffs_dirpref to select the inode.
> @@ -1548,119 +1079,6 @@ gotit:
>       return (blkno);
>  }
>  
> -/*
> - * Determine whether a cluster can be allocated.
> - *
> - * We do not currently check for optimal rotational layout if there
> - * are multiple choices in the same cylinder group. Instead we just
> - * take the first one that we find following bpref.
> - */
> -daddr_t
> -ffs_clusteralloc(struct inode *ip, int cg, daddr_t bpref, int len)
> -{
> -     struct fs *fs;
> -     struct cg *cgp;
> -     struct buf *bp;
> -     int i, got, run, bno, bit, map;
> -     u_char *mapp;
> -     int32_t *lp;
> -
> -     fs = ip->i_fs;
> -     if (fs->fs_maxcluster[cg] < len)
> -             return (0);
> -
> -     if (!(bp = ffs_cgread(fs, ip, cg)))
> -             return (0);
> -
> -     cgp = (struct cg *)bp->b_data;
> -
> -     /*
> -      * Check to see if a cluster of the needed size (or bigger) is
> -      * available in this cylinder group.
> -      */
> -     lp = &cg_clustersum(cgp)[len];
> -     for (i = len; i <= fs->fs_contigsumsize; i++)
> -             if (*lp++ > 0)
> -                     break;
> -     if (i > fs->fs_contigsumsize) {
> -             /*
> -              * This is the first time looking for a cluster in this
> -              * cylinder group. Update the cluster summary information
> -              * to reflect the true maximum sized cluster so that
> -              * future cluster allocation requests can avoid reading
> -              * the cylinder group map only to find no clusters.
> -              */
> -             lp = &cg_clustersum(cgp)[len - 1];
> -             for (i = len - 1; i > 0; i--)
> -                     if (*lp-- > 0)
> -                             break;
> -             fs->fs_maxcluster[cg] = i;
> -             goto fail;
> -     }
> -     /*
> -      * Search the cluster map to find a big enough cluster.
> -      * We take the first one that we find, even if it is larger
> -      * than we need as we prefer to get one close to the previous
> -      * block allocation. We do not search before the current
> -      * preference point as we do not want to allocate a block
> -      * that is allocated before the previous one (as we will
> -      * then have to wait for another pass of the elevator
> -      * algorithm before it will be read). We prefer to fail and
> -      * be recalled to try an allocation in the next cylinder group.
> -      */
> -     if (dtog(fs, bpref) != cg)
> -             bpref = cgdata(fs, cg);
> -     else
> -             bpref = blknum(fs, bpref);
> -     bpref = fragstoblks(fs, dtogd(fs, bpref));
> -     mapp = &cg_clustersfree(cgp)[bpref / NBBY];
> -     map = *mapp++;
> -     bit = 1 << (bpref % NBBY);
> -     for (run = 0, got = bpref; got < cgp->cg_nclusterblks; got++) {
> -             if ((map & bit) == 0) {
> -                     run = 0;
> -             } else {
> -                     run++;
> -                     if (run == len)
> -                             break;
> -             }
> -             if ((got & (NBBY - 1)) != (NBBY - 1)) {
> -                     bit <<= 1;
> -             } else {
> -                     map = *mapp++;
> -                     bit = 1;
> -             }
> -     }
> -     if (got >= cgp->cg_nclusterblks)
> -             goto fail;
> -     /*
> -      * Allocate the cluster that we have found.
> -      */
> -     cgp->cg_ffs2_time = cgp->cg_time = time_second;
> -
> -#ifdef DIAGNOSTIC
> -     for (i = 1; i <= len; i++)
> -             if (!ffs_isblock(fs, cg_blksfree(cgp), got - run + i))
> -                     panic("ffs_clusteralloc: map mismatch");
> -#endif
> -     bno = cgbase(fs, cg) + blkstofrags(fs, got - run + 1);
> -#ifdef DIAGNOSTIC
> -     if (dtog(fs, bno) != cg)
> -             panic("ffs_clusteralloc: allocated out of group");
> -#endif
> -
> -     len = blkstofrags(fs, len);
> -     for (i = 0; i < len; i += fs->fs_frag)
> -             if (ffs_alloccgblk(ip, bp, bno + i) != bno + i)
> -                     panic("ffs_clusteralloc: lost block");
> -     bdwrite(bp);
> -     return (bno);
> -
> -fail:
> -     brelse(bp);
> -     return (0);
> -}
> -
>  /* inode allocation routine */
>  daddr_t
>  ffs_nodealloccg(struct inode *ip, int cg, daddr_t ipref, int mode)
> @@ -1985,48 +1403,6 @@ ffs_freefile(struct inode *pip, ufsino_t
>       bdwrite(bp);
>       return (0);
>  }
> -
> -#ifdef DIAGNOSTIC
> -/*
> - * Verify allocation of a block or fragment. Returns true if block or
> - * fragment is allocated, false if it is free.
> - */
> -int
> -ffs_checkblk(struct inode *ip, daddr_t bno, long size)
> -{
> -     struct fs *fs;
> -     struct cg *cgp;
> -     struct buf *bp;
> -     int i, frags, free;
> -
> -     fs = ip->i_fs;
> -     if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) {
> -             printf("bsize = %d, size = %ld, fs = %s\n",
> -                 fs->fs_bsize, size, fs->fs_fsmnt);
> -             panic("ffs_checkblk: bad size");
> -     }
> -     if ((u_int)bno >= fs->fs_size)
> -             panic("ffs_checkblk: bad block %lld", (long long)bno);
> -
> -     if (!(bp = ffs_cgread(fs, ip, dtog(fs, bno))))
> -             return (0);
> -
> -     cgp = (struct cg *)bp->b_data;
> -     bno = dtogd(fs, bno);
> -     if (size == fs->fs_bsize) {
> -             free = ffs_isblock(fs, cg_blksfree(cgp), fragstoblks(fs, bno));
> -     } else {
> -             frags = numfrags(fs, size);
> -             for (free = 0, i = 0; i < frags; i++)
> -                     if (isset(cg_blksfree(cgp), bno + i))
> -                             free++;
> -             if (free != 0 && free != frags)
> -                     panic("ffs_checkblk: partially free fragment");
> -     }
> -     brelse(bp);
> -     return (!free);
> -}
> -#endif /* DIAGNOSTIC */
>  
>  
>  /*
> Index: sys/ufs/ffs/ffs_extern.h
> ===================================================================
> RCS file: /cvs/src/sys/ufs/ffs/ffs_extern.h,v
> retrieving revision 1.41
> diff -u -p -r1.41 ffs_extern.h
> --- sys/ufs/ffs/ffs_extern.h  12 Jan 2016 11:41:00 -0000      1.41
> +++ sys/ufs/ffs/ffs_extern.h  21 May 2016 20:36:13 -0000
> @@ -57,8 +57,8 @@
>       { 0, 0 }, \
>       { 0, 0 }, \
>       { 0, 0 }, \
> -     { "doreallocblks", CTLTYPE_INT }, \
> -     { "doasyncfree", CTLTYPE_INT }, \
> +     { 0, 0 }, \
> +     { 0, 0 }, \
>       { "max_softdeps", CTLTYPE_INT }, \
>       { "sd_tickdelay", CTLTYPE_INT }, \
>       { "sd_worklist_push", CTLTYPE_INT }, \
> @@ -103,7 +103,6 @@ int ffs_alloc(struct inode *, daddr_t, d
>                  daddr_t *);
>  int ffs_realloccg(struct inode *, daddr_t, daddr_t, int, int ,
>                      struct ucred *, struct buf **, daddr_t *);
> -int ffs_reallocblks(void *);
>  int ffs_inode_alloc(struct inode *, mode_t, struct ucred *, struct vnode **);
>  int ffs_inode_free(struct inode *, ufsino_t, mode_t);
>  int ffs_freefile(struct inode *, ufsino_t, mode_t);
> Index: sys/ufs/ffs/ffs_vfsops.c
> ===================================================================
> RCS file: /cvs/src/sys/ufs/ffs/ffs_vfsops.c,v
> retrieving revision 1.156
> diff -u -p -r1.156 ffs_vfsops.c
> --- sys/ufs/ffs/ffs_vfsops.c  10 May 2016 10:37:57 -0000      1.156
> +++ sys/ufs/ffs/ffs_vfsops.c  21 May 2016 20:36:14 -0000
> @@ -1540,7 +1540,6 @@ int
>  ffs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
>      size_t newlen, struct proc *p)
>  {
> -     extern int doreallocblks, doasyncfree;
>  #ifdef FFS_SOFTUPDATES
>       extern int max_softdeps, tickdelay, stat_worklist_push;
>       extern int stat_blk_limit_push, stat_ino_limit_push, stat_blk_limit_hit;
> @@ -1555,12 +1554,9 @@ ffs_sysctl(int *name, u_int namelen, voi
>       switch (name[0]) {
>       case FFS_CLUSTERREAD:
>       case FFS_CLUSTERWRITE:
> -             return (EOPNOTSUPP);
>       case FFS_REALLOCBLKS:
> -             return (sysctl_int(oldp, oldlenp, newp, newlen,
> -                 &doreallocblks));
>       case FFS_ASYNCFREE:
> -             return (sysctl_int(oldp, oldlenp, newp, newlen, &doasyncfree));
> +             return (EOPNOTSUPP);
>  #ifdef FFS_SOFTUPDATES
>       case FFS_MAX_SOFTDEPS:
>               return (sysctl_int(oldp, oldlenp, newp, newlen, &max_softdeps));
> Index: sys/ufs/ffs/ffs_vnops.c
> ===================================================================
> RCS file: /cvs/src/sys/ufs/ffs/ffs_vnops.c,v
> retrieving revision 1.86
> diff -u -p -r1.86 ffs_vnops.c
> --- sys/ufs/ffs/ffs_vnops.c   7 Apr 2016 11:13:01 -0000       1.86
> +++ sys/ufs/ffs/ffs_vnops.c   21 May 2016 20:36:14 -0000
> @@ -93,7 +93,6 @@ struct vops ffs_vops = {
>       .vop_islocked   = ufs_islocked,
>       .vop_pathconf   = ufs_pathconf,
>       .vop_advlock    = ufs_advlock,
> -     .vop_reallocblks = ffs_reallocblks,
>       .vop_bwrite     = vop_generic_bwrite
>  };
>  

Reply via email to