ZFS file in a snapshot with a link count of 0

Dave Baukus daveb at spectralogic.com
Fri Jun 22 15:31:32 UTC 2018


On 06/22/2018 01:00 AM, Andriy Gapon wrote:
> On 22/06/2018 02:25, Dave Baukus wrote:
>> On a ZFS running something very close to 11.0-STABLE FreeBSD, I am able to get a
>> file with a link count of 0 into a snapshot. If this file also has an extattr attached to it then
>> this file appears to break zfs diff.
>>
>> The main question is: should a file with a link count of 0 get into the snap shot ?
> Yes.  The file is on disk, so it's in the snapshot as well.
>
>> #
>> zfs diff pool0/vol0 at snapF1 pool0/vol0 at snapF2
>> Unable to determine path or stats for object 1030 in pool0/vol0 at snapF1: No such file or directory
> Is this a fatal error or merely a warning?
> If the former, then it needs to be fixed in zfs diff.
>
It is fatal. The bug here:
describe_free(FILE *fp, differ_info_t *di, uint64_t object, char *namebuf,
     int maxlen)
{
         struct zfs_stat sb;

         if (get_stats_for_obj(di, di->fromsnap, object, namebuf,
             maxlen, &sb) != 0) {
                 /* Let it slide, if in the delete queue on from side */
                 if (di->zerr == ENOENT && sb.zs_links == 0) {
                         di->zerr = 0;
                         return (0);
                 }
                 return (-1);
         }

         print_file(fp, di, ZDIFF_REMOVED, namebuf, &sb);
         return (0);
}

The object is the extattr-dir (1030) of the file (1029) that has been removed.
1029 has a zs_links == 0 so it passes the check above; 1030 has sz_links == 2 and zfs diff
exits with the error message above.


More information about the freebsd-fs mailing list