[Bug 233245] [UFS] Softupdates fails to track dependency between appended data and i_size

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Nov 15 21:58:24 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=233245

            Bug ID: 233245
           Summary: [UFS] Softupdates fails to track dependency between
                    appended data and i_size
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs at FreeBSD.org
          Reporter: cem at freebsd.org

This manifests with recently appended files containing extraneous zero data at
the end of the file after power loss or crash.

Detection of append could happen in either ffs_balloc_ufs[12] (which is where
most softdep dependencies seem to be added, and which is called unconditionally
by ffs_write()) in the several "happy" cases where we discover we do not need
to actually allocate a new block, e.g., cases like:

   753         if (lbn < UFS_NDADDR) {
...
   756                 nb = dp->di_db[lbn];
   757                 if (nb != 0 && ip->i_size >= smalllblktosize(fs, lbn +
1)) {
   758                         error = bread_gb(vp, lbn, fs->fs_bsize, NOCRED,
   759                             gbflags, &bp);
...
   764                         bp->b_blkno = fsbtodb(fs, nb);

+++                            if (DOINGSOFTDEP(vp) && startoffset + size >
ip->i_size)
+++                                    softdep_setup_append(...);

   765                         *bpp = bp;
   766                         return (0);

It could also just be checked in a single location in ffs_write() itself:

   754         for (error = 0; uio->uio_resid > 0;) {
   755                 lbn = lblkno(fs, uio->uio_offset);
   756                 blkoffset = blkoff(fs, uio->uio_offset);
...
   781                 if (uio->uio_offset + xfersize > ip->i_size) {

+++                            if (DOINGSOFTDEP(vp))
+++                                    softdep_setup_append(...);

   782                         ip->i_size = uio->uio_offset + xfersize;
   783                         DIP_SET(ip, i_size, ip->i_size);
   784                 }

Append data could probably be tracked in quite similar fashion to diradd
(directory entry adds).

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list