NVSL / linux-nova

NOVA is a log-structured file system designed for byte-addressable non-volatile memories, developed at the University of California, San Diego.
http://nvsl.ucsd.edu/index.php?path=projects/nova
Other
422 stars 117 forks source link

Different block count/size before and after remount #117

Closed hayley-leblanc closed 2 years ago

hayley-leblanc commented 2 years ago

Hi,

It looks like after some operations (we have observed it in mkdir and symlink), files in NOVA may have incorrect block counts or sizes until the system is unmounted and remounted.

I can reproduce this issue by mounting a fresh instance of NOVA and creating a new file A/. Running stat A gives this:

  File: A
  Size: 4096        Blocks: 0          IO Block: 4096   directory
Device: 10301h/66305d   Inode: 33          Links: 2
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-10-26 19:32:10.000000000 +0000
Modify: 2021-10-26 19:32:10.000000000 +0000
Change: 2021-10-26 19:32:10.000000000 +0000
 Birth: -

But if I unmount and remount NOVA, running stat A gives this:

  File: A
  Size: 4096        Blocks: 1          IO Block: 4096   directory
Device: 10301h/66305d   Inode: 33          Links: 2
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-10-26 19:32:10.000000000 +0000
Modify: 2021-10-26 19:32:10.000000000 +0000
Change: 2021-10-26 19:32:10.000000000 +0000
 Birth: -

Before umount, the number of blocks is 0, but after it, the number of blocks is 1.

I can also reproduce it with symbolic links. If I create a symlink ln -s . file0 in a fresh NOVA instance and run stat file0, I get:

  File: file0 -> .
  Size: 1           Blocks: 0          IO Block: 4096   symbolic link
Device: 10301h/66305d   Inode: 33          Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-10-26 19:35:35.000000000 +0000
Modify: 2021-10-26 19:35:35.000000000 +0000
Change: 2021-10-26 19:35:35.000000000 +0000
 Birth: -

Remounting NOVA and stat-ing file0 again gives:

  File: file0 -> .
  Size: 2           Blocks: 1          IO Block: 4096   symbolic link
Device: 10301h/66305d   Inode: 33          Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-10-26 19:35:36.000000000 +0000
Modify: 2021-10-26 19:35:35.000000000 +0000
Change: 2021-10-26 19:35:35.000000000 +0000
 Birth: -

Here, there's a mismatch with both the number of blocks and the size of the file.

Any idea what the cause of this might be?

Thanks!

Andiry commented 2 years ago

This issue is because before umount, we report the number of blocks of data pages. Upon remount, we count the number of blocks as the sum of log pages and data pages. We should the make the logic uniform.

Andiry commented 2 years ago

Fixed.