Try not to get nlink from the filesystem.

nlink, coming from stat()'s st_nlink may not be up to sync with the
database. For instance if the pipeline processes the following instructions

  touch a
  ln a b
  rm b

it will get nlink=1 from the FS when processing the hardlink, while at the
real value (at the time) would have been 2. When the rm is processed, nlink
would become 0.

Instead, set nlink to 1 during the creation, and increment it by 1 for
a hardlink.

Added a testcase.