kernel - TMPFS - Bug fixing pass
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 13 Feb 2010 03:15:21 +0000 (19:15 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sat, 13 Feb 2010 03:15:21 +0000 (19:15 -0800)
commit9fc94b5f0ece4794f4f859f149d8f61883bccf70
tree1675083e9ed3408dc0d46d228d7136cd0e964282
parent0a8aee15320dd5b32f4f0651e3dee5e934057b01
kernel - TMPFS - Bug fixing pass

* TMPFS_ASSERT_ELOCKED() is called in numerous places where
  tn_vnode is not necessarily assigned, for example during
  tmpfs_nremove() after the directory entry has been cleaned out.

  Remove the assertion that tn_vnode != NULL.

* Add tmpfs_mount->tm_flags and TMPFS_FLAG_UNMOUNTING, used during
  unmounting to tell tmpfs_fsync() to throw away the contents of
  the file (normally it ignores it).  This fixes a panic on umount
  when the main kernel checks that all dirty buffers have been
  cleaned out.

* Fix two places where the wrong length for a string is
  being kmalloc()'d.  The softlink and the directory entry
  string allocations were wrong and resulted in a string
  terminator being stuffed beyond the end of the malloced
  buffer.

* Do a safety-NULL-out of a few fields after kfree()ing them.

* Refactor tmpfs_dir_lookup() a little.

* Enhance tmpfs_reg_resize() to also resize the SWAP VM object.
  Failing to do so can leave extranious swap assignments for
  deleted areas of the file which become visible again (instead
  of becoming zero-fill) if the file is then later ftruncate()d
  larger.

  Also fix the block size parameters to nvtruncbuf() and nvextendbuf().
  It must match the block size used for the buffer cache.

* Temporarily turn off all the MPSAFE flags.  Run under the BGL.

* The buffer offset (offset) in tmpfs_read() and tmpfs_write()
  can be a size_t.  It does not have to be off_t.

* tmpfs_write() was using getblk().  It actually has to use bread()
  in order to ensure that the buffer contents is valid when potentially
  doing a piecemeal write which does not cover the whole buffer.

* Refactor tmpfs_write() to leave the underlying VM pages dirty,
  except in cases the system page daemon wants to flush pages to
  clear space in ram (IO_SYNC, IO_ASYNC).  Use buwrite() to do this.

* Fix an error path in tmpfs_strategy() which was not biodone()ing
  the bio.

* tmpfs_remove() was making assumptions with regards to v->a_nch.ncp->nc_vp
  which were not correct.  The vp is not referenced and can get ripped
  out from under the caller unless properly handled.

* Fix sequencing in tmpfs_inactive().  If tn_links is 0 and the node
  is not in the middle of being allocated we can destroy it.

* Remove unnecessary vnode locks from tmpfs_reclaim().  There are also other
  vnode locks scattered around that aren't needed (for another time).

* Implement vop_bmap(), it is basically a dummy.
sys/vfs/tmpfs/tmpfs.h
sys/vfs/tmpfs/tmpfs_subr.c
sys/vfs/tmpfs/tmpfs_vfsops.c
sys/vfs/tmpfs/tmpfs_vnops.c