# Disk usage discrepancy?

**URL:** <https://forum.storj.io/t/disk-usage-discrepancy/24715>\
**Category:** troubleshooting\
**Tags:** storage, xfs, btrfs, ntfs, zfs\
**Created:** [December 19, 2023, 6:18pm UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715 "2023-12-19T18:18:00Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![jammerdan](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/jammerdan/32/1121_2.png) [@jammerdan](https://forum.storj.io/u/jammerdan)\
**Post date:** [December 27, 2023, 8:49am UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/97 "2023-12-27T08:49:26Z")

</div>

This sounds interesting.  
However in my config the storage directory destination is `/app/storage`. As the temp folder is located in the storage folder shouldn’t the destination therefore be `/app/storage/temp`?  
I just want to make sure the node will find and use the new temp location.

---

<div class="post-metadata">

**Author:** ![jammerdan](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/jammerdan/32/1121_2.png) [@jammerdan](https://forum.storj.io/u/jammerdan)\
**Post date:** [December 27, 2023, 9:54am UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/98 "2023-12-27T09:54:06Z")

</div>

> [@jammerdan](#):
>
> shouldn’t the destination therefore be `/app/storage/temp`

Nvm. Tried it and received failed upload errors.

With

> [@Alexey](#):
>
> –mount type=tmpfs,destination=/app/config/storage/temp

it seems to work. At least I don’t see failed uploads now. Now let’s wait and check if this is going well.

---

<div class="post-metadata">

**Author:** ![jammerdan](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/jammerdan/32/1121_2.png) [@jammerdan](https://forum.storj.io/u/jammerdan)\
**Post date:** [December 27, 2023, 10:02am UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/99 "2023-12-27T10:02:26Z")

</div>

When I check the temp folder on the disk, I can still see new partial files being created.  
So it does not seem to work as it should.

---

<div class="post-metadata">

**Author:** ![zip](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/zip/32/7813_2.png) [@zip](https://forum.storj.io/u/zip)\
**Post date:** [December 27, 2023, 10:11am UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/100 "2023-12-27T10:11:29Z")

</div>

They will show up there, these files are however stored in RAM then swap in case of tmpfs.

---

<div class="post-metadata">

**Author:** ![jammerdan](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/jammerdan/32/1121_2.png) [@jammerdan](https://forum.storj.io/u/jammerdan)\
**Post date:** [December 27, 2023, 10:34am UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/101 "2023-12-27T10:34:27Z")

</div>

You mean they are supposed to show up in the temp folder on the disk although they get stored in RAM? This does not sound right.  
But even if that is how it should be, then after removal of the container, the should disappear. But I can still see them. I have just tested it and there are numerous new partial files with current timestamp and they remain there even after removal of the container. I can even open the partial files.

---

<div class="post-metadata">

**Author:** ![jammerdan](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/jammerdan/32/1121_2.png) [@jammerdan](https://forum.storj.io/u/jammerdan)\
**Post date:** [December 27, 2023, 10:38am UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/102 "2023-12-27T10:38:24Z")

</div>

> [@Alexey](#):
>
> `--mount type=tmpfs,destination=/app/config/storage/temp`

When I use `--mount type=tmpfs,destination=/app/storage/temp` then I get `ERROR piecestore upload failed` with `invalid cross-device link` when it tries to rename/move the partial file as sj1 piece.

---

<div class="post-metadata">

**Author:** ![zip](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/zip/32/7813_2.png) [@zip](https://forum.storj.io/u/zip)\
**Post date:** [December 27, 2023, 10:49am UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/103 "2023-12-27T10:49:55Z")

</div>

> [@jammerdan](#):
>
> You mean they are supposed to show up in the temp folder on the disk although they get stored in RAM? This does not sound right.  
> But even if that is how it should be, then after removal of the container, the should disappear. But I can still see them.

Correct, this way it is transparent to the application. I use the same for storagenode logs and if I reboot the system the logs are gone.  
Not sure how it works in Docker, but maybe you would have to restart the whole host/Docker for the files to be gone.  
Also, if you had files on drive at that location before you mounted tmpfs, then after unmounting tmpfs the original files at that location stored on drive will be displayed.

---

<div class="post-metadata">

**Author:** ![jammerdan](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/jammerdan/32/1121_2.png) [@jammerdan](https://forum.storj.io/u/jammerdan)\
**Post date:** [December 27, 2023, 10:53am UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/104 "2023-12-27T10:53:28Z")

</div>

> [@zip](#):
>
> Also, if you had files on drive at that location before you mounted tmpfs, then after unmounting tmpfs the original files at that location stored on drive will be displayed.

Yes, but then I should no longer see the files that have been created while the tmpfs was mounted, right?  
But I still see those files even after removal of the container and as said I can even open them. So they are still present.

---

<div class="post-metadata">

**Author:** ![zip](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/zip/32/7813_2.png) [@zip](https://forum.storj.io/u/zip)\
**Post date:** [December 27, 2023, 11:04am UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/105 "2023-12-27T11:04:54Z")

</div>

> [@jammerdan](#):
>
> Yes, but then I should no longer see the files that have been created while the tmpfs was mounted, right?

Correct.

> [@jammerdan](#):
>
> But I still see those files even after removal of the container and as said I can even open them. So they are still present.

This shouldn’t be the case.

There is more about how it works in Docker here: [tmpfs mounts | Docker Docs](https://docs.docker.com/storage/tmpfs/). From the text it looks like it only works on Linux hosts however, so if you are using Windows maybe this doesn’t work there.

---

<div class="post-metadata">

**Author:** ![jammerdan](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/jammerdan/32/1121_2.png) [@jammerdan](https://forum.storj.io/u/jammerdan)\
**Post date:** [December 27, 2023, 11:30am UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/106 "2023-12-27T11:30:00Z")

</div>

> [@zip](#):
>
> so if you are using Windows maybe this doesn’t work there.

No I am talking about Linux too.  
Maybe my issue is this. I have already a bind mount for `/app/storage` in the docker run command. Now when I add a tmpfs mount for `/app/storage/temp` or `/app/config/storage/temp`, maybe it is not supposed to work as there is already a bind mount for the storage destination?

---

<div class="post-metadata">

**Author:** ![Toyoo](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/toyoo/32/1126_2.png) [@Toyoo](https://forum.storj.io/u/Toyoo)\
**Post date:** [December 27, 2023, 2:46pm UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/107 "2023-12-27T14:46:13Z")

</div>

> [@thepaul](#):
>
> It would be bad if an uplink requested a piece and the storagenode started streaming the data in the piece but stopped early because the piece wasn’t fully uploaded. The uplink would have to “rewind” at that point, request a new set of pieces from other nodes, and continue from that point. The node should only begin streaming the data if it has a fully intact piece.

Oh, this is interesting. I assumed libuplink already can handle this case, as the same observed behavior might be caused by simple data loss on node’s HDD. File might have been truncated after a bad shutdown, or simply some garbage substituted for metadata.

> [@thepaul](#):
>
> The space-used filewalker also needs to be able to differentiate; partially-uploaded blobs that may never be completed should not count toward used space.

This is also interesting. Unless a node would be shut down uncleanly, the files would still be removed as part of the upload procedure if the node knows the upload was canceled or failed. As such, the only leftover files would be due to pending uploads during an unclean shutdown, which would be maybe tens of megabytes. Insignificant at node’s scale, and certainly not worth correcting for if it requires more I/O.

> [@thepaul](#):
>
> I suppose the “cleanup temp files” step that happens on startup would also need to be able to differentiate, and it would have to traverse the whole data hierarchy. That would be awful. I suppose that step needs to be rearchitected anyway, though.

The node wouldn’t have to do it at all. GC would do it as part of normal operation, as file names wouldn’t be matched by the bloom filter.

> [@Alexey](#):
>
> We read a header of the each piece, where Metadata is stored, not only size and update time from the filesystem’s Metadata, so they are different metadata. We use system functions though too.

I can’t verify this now, but IIRC not during the file walker process unless a piece is to be trashed.

> [@Alexey](#):
>
> I think you can do this
> 
> ```auto
> $ storagenode setup --help | grep write-buf
> 
> --filestore.write-buffer-size memory.Size in-memory buffer for uploads (default 128.0 KiB)
> 
> ```

Sure. Though, the idea is that if we take an assumption that all partial uploads ever will always be stored in RAM, with no option to have partial uploads stored on disk, then we can change the structure of data on disk to make it more IOPS-efficient.

> [@jammerdan](#):
>
> What would that mean in cases of bloating temp folders that don’t get cleaned up: [Large temporary folder - #28 by jammerdan](https://forum.storj.io/t/large-temporary-folder/8687/28)  
> I think I’d rather have these zombie files on disk than in RAM.

That’s a quality of implementation issue. A basic measure is the fact that a node restart will free up RAM of all pending uploads. Another measure, which is not the default now, but can be turned on even now, is upload speed—no upload should take more than few minutes, after all.

> [@Alexey](#):
>
> Then you may use the tempfs for the temp folder.

You can’t, the rename() syscall doesn’t work across file systems. The storage node code would have to explicitly copy the file, this is not implemented.

---

<div class="post-metadata">

**Author:** ![thepaul](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/thepaul/32/65_2.png) [@thepaul](https://forum.storj.io/u/thepaul)\
**Post date:** [December 28, 2023, 12:47am UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/108 "2023-12-28T00:47:02Z")

</div>

> [@Toyoo](#):
>
> You can’t, the rename() syscall doesn’t work across file systems. The storage node code would have to explicitly copy the file, this is not implemented.

@Toyoo is right- don’t use a tempfs for the partial uploads directory. The benefit of keeping the storage and temp directories on the same device is that once blobs are complete, they can be moved into the live storage directory atomically.

---

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [December 28, 2023, 7:18am UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/109 "2023-12-28T07:18:17Z")

</div>

Seems I was wrong:

> [@Disk usage discrepancy?](https://forum.storj.io/t/disk-usage-discrepancy/24715/65):
>
> wow im impressed You actually took time to look into that, please check, as Alex said, if dissableing lazy-filewalker ( pieces.enable-lazy-filewalker: false) makes any differences for better? im super curious.

> [@Toyoo](#):
>
> You can’t, the rename() syscall doesn’t work across file systems. The storage node code would have to explicitly copy the file, this is not implemented.

> [@thepaul](#):
>
> @Toyoo is right- don’t use a tempfs for the partial uploads directory. The benefit of keeping the storage and temp directories on the same device is that once blobs are complete, they can be moved into the live storage directory atomically.

---

<div class="post-metadata">

**Author:** ![jammerdan](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/jammerdan/32/1121_2.png) [@jammerdan](https://forum.storj.io/u/jammerdan)\
**Post date:** [December 28, 2023, 8:14am UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/110 "2023-12-28T08:14:09Z")

</div>

> [@Alexey](#):
>
> Seems I was wrong:

Yes, but no problem. It’s always worth a try to see if the node behavior can be improved.

---

<div class="post-metadata">

**Author:** ![jammerdan](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/jammerdan/32/1121_2.png) [@jammerdan](https://forum.storj.io/u/jammerdan)\
**Post date:** [December 28, 2023, 12:33pm UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/111 "2023-12-28T12:33:41Z")

</div>

> [@Alexey](#):
>
> I’m not sure that this process is exist.

Then I don’t know what process @thepaul is referring to when claiming that temp files get deleted on startup.

---

<div class="post-metadata">

**Author:** ![Luis](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/luis/32/69_2.png) [@Luis](https://forum.storj.io/u/Luis)\
**Post date:** [December 28, 2023, 5:17pm UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/112 "2023-12-28T17:17:35Z")

</div>

My node is around 9TB, but the space statistics are not correct.  
I recently deleted all the .db files because there was an error in some of the files.  
What can I do ?

 ![Node](https://storj-s3.bcdn.literatehosting.net/original/2X/d/d231750f07fe32d528b25ed65cf9c5d2f5968146.jpeg)

---

<div class="post-metadata">

**Author:** ![daki82](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/daki82/32/1128_2.png) [@daki82](https://forum.storj.io/u/daki82)\
**Post date:** [December 28, 2023, 5:55pm UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/113 "2023-12-28T17:55:01Z")

</div>

investigate why the filewalk does not finish.?  
provide logs? try this example here.

> [@When will average node space be the same as my currently used space?](https://forum.storj.io/t/when-will-average-node-space-be-the-same-as-my-currently-used-space/24609/2):
>
> Please check: Wich filesystem and clustersize are on the drive? How big and what type number? in the blobs folder, are there 4 or 6 folders? Fatal errors in the log? Log to big to open? defragmentation ? Temp folder not empty when node stopped? in gerneral provide hardware, internet and software info.

---

<div class="post-metadata">

**Author:** ![thepaul](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/thepaul/32/65_2.png) [@thepaul](https://forum.storj.io/u/thepaul)\
**Post date:** [December 28, 2023, 9:42pm UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/114 "2023-12-28T21:42:55Z")

</div>

> [@jammerdan](#):
>
> Then I don’t know what process @thepaul is referring to when claiming that temp files get deleted on startup.

I was wrong, as some people pointed out. There isn’t such a thing. Maybe I’m remembering something from the past or something we planned to do but haven’t yet.

> [@Toyoo](#):
>
> > [@thepaul](#):
> >
> > It would be bad if an uplink requested a piece and the storagenode started streaming the data in the piece but stopped early because the piece wasn’t fully uploaded. The uplink would have to “rewind” at that point, request a new set of pieces from other nodes, and continue from that point. The node should only begin streaming the data if it has a fully intact piece.
> 
> Oh, this is interesting. I assumed libuplink already can handle this case, as the same observed behavior might be caused by simple data loss on node’s HDD. File might have been truncated after a bad shutdown, or simply some garbage substituted for metadata.

You’re right, the uplink can handle that case, as long as there are enough other input streams. I didn’t think that through.

> [@Toyoo](#):
>
> > [@thepaul](#):
> >
> > The space-used filewalker also needs to be able to differentiate; partially-uploaded blobs that may never be completed should not count toward used space.
> 
> This is also interesting. Unless a node would be shut down uncleanly, the files would still be removed as part of the upload procedure if the node knows the upload was canceled or failed. As such, the only leftover files would be due to pending uploads during an unclean shutdown, which would be maybe tens of megabytes. Insignificant at node’s scale, and certainly not worth correcting for if it requires more I/O.

This is what I’d expect also, but I’ve heard we have people who end up with massive `temp` directories containing gigabytes of detritus. It’s not clear to me whether there is a bug in the node code that fails to delete temp files when an upload fails, or if those nodes are restarting a lot more frequently than I think they should. I also don’t know how widespread of a problem that is; maybe it’s nothing to worry about.

Overall, I am intrigued by your suggestion and I’ll be eager to read your storage architecture proposal, if you get a chance to put it together.

---

<div class="post-metadata">

**Author:** ![daki82](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/daki82/32/1128_2.png) [@daki82](https://forum.storj.io/u/daki82)\
**Post date:** [December 28, 2023, 11:48pm UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/115 "2023-12-28T23:48:36Z")

</div>

> [@thepaul](#):
>
> This is what I’d expect also, but I’ve heard we have people who end up with massive `temp` directories containing gigabytes of detritus. It’s not clear to me whether there is a bug in the node code that fails to delete temp files when an upload fails, or if those nodes are restarting a lot more frequently than I think they should. I also don’t know how widespread of a problem that is; maybe it’s nothing to worry about.

Had this temp/\*.partial problem (detected) in June 2023, since then, its gone. (just checked)

I think people notice this propably old problem way later as it happened, or only when the node has undetected bigger problems, that cause constant restarts, unplausible stats, or downtime.  
like the 1min timeout problem that so many sno had. and some have.

maybe depends on the configuration of the node( databases on ssd??). (write buffer size? there was a change from 128kib to 4Mib) afaik

Would be interesting to know wich version was running at the time the .partial was “leftover”.

---

<div class="post-metadata">

**Author:** ![Alexey](https://storj.bcdn.literatehosting.com/user_avatar/forum.storj.io/alexey/32/41_2.png) [@Alexey](https://forum.storj.io/u/Alexey)\
**Post date:** [December 29, 2023, 1:52am UTC](https://forum.storj.io/t/disk-usage-discrepancy/24715/116 "2023-12-29T01:52:58Z")

</div>

> [@daki82](#):
>
> there was a change from 128kib to 4Mib) afaik

Accordingly `storagenode setup --help | grep buffer` it’s still 128KiB

```auto
      --filestore.write-buffer-size memory.Size in-memory buffer for uploads (default 128.0 KiB)

```

[Previous page](https://forum.storj.io/t/disk-usage-discrepancy/24715.md?page=3)

[Next page](https://forum.storj.io/t/disk-usage-discrepancy/24715.md?page=5)
