History log of /haiku/src/add-ons/kernel/drivers/disk/virtual/ram_disk/ram_disk.cpp
Revision Date Author Comments
# 215b685f 11-Dec-2022 X512 <danger_mail@list.ru>

kernel: Drop non-standard GNU inline assignment syntax

* We needed this previously due to our gcc2 compiled kernel.
* Now that our kernel is always latest gcc, we can move to the
c++20 syntax for inline assignment.
* Improves compatibility with clang, less GNU-specific stuff

Change-Id: Ib7272a0a52554a31e9a0e788fd3f031db9049795
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5898
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# 688acf41 15-Sep-2022 Jérôme Duval <jerome.duval@gmail.com>

add physical_block_size field where applicable

only scsi_disk checks the actual value, other drivers take the logical block size.

This change reports the physical block size from the disk rather than the block
size used by IDE/SATA/SCSI commands. On typical modern SATA disks, the SATA
commands will use 512 byte blocks, but the disk will actually read and write
4K blocks internally. This is only of importance for partition alignment for DriveSetup,
and is independant of file systems or partitioning systems. This could also influence
the recommended block size for some file systems.

Change-Id: Id0f2e22659e89fcef64c1f8d04f81cd68995e01f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5667
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# fce7f3a7 09-Dec-2020 X512 <danger_mail@list.ru>

integrate AutoDeleter's into pointers

Change-Id: I6c3925a7aec4d0647c76c2a03aad7b08985d7166
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3490
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# bd02d81c 30-Jun-2021 David Sebek <dasebek@gmail.com>

Fix trim-related issues

Fixes:
* Use uint64 instead of off_t when handling offset and size
of the trimmed range in the fs_trim_data structure
* BlockAllocator::Trim: Correct the size of a buffer
* ram_disk, mmc: Do not trim past device capacity

Improvements:
* BlockAllocator::Trim: Because the received offset and size
are ignored by BFS (the functionality is not implemented yet),
return B_UNSUPPORTED if the range does not cover the whole
partition
* ram_disk, mmc: More accurate calculation of the number
of trimmed bytes
* devfs: Add a uint64 version of translate_partition_access()

Change-Id: I24f4c08674f123ad33a5fef6e28996a4ada6ff0d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4155
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# cef80a1f 17-Jan-2021 Adrien Destugues <pulkomandy@pulkomandy.tk>

devfs: translate partition offsets in B_TRIM_DEVICE

Fixes bfs part of #10336. Untested on SATA (don't have a testing drive
to sacrifice) but working fine on SD/MMC.

This requires moving the copy from kernel to userland into the devfs. As
a result the code in the disk drivers becomes a bit simpler.

Also add some documentation for the common ioctls to implement for a
disk device.

Change-Id: Ie84b6a1d293828d33902a64b3c9d4b19aa6eacb1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3640
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>


# 69c34116 31-Aug-2019 Augustin Cavalier <waddlesplash@gmail.com>

ram_disk: Add note about code duplication with ramfs.


# bdac77bf 03-Nov-2016 Rene Gollent <rene@gollent.com>

ram_disk: FIx x86-64 build.


# 96fef5d1 03-Nov-2016 Adrien Destugues <pulkomandy@pulkomandy.tk>

ramdisk: implement trim and icon, add to image

- B_TRIM_DEVICE on a ram disk frees all requested pages. Reading from a
trimmed page returns all 0s. This can be used with fstrim to release
memory for the parts not used by the filesystem, without unregistering
then registering the device.
- Add icon and ioctl to get it.
- Add it to the image, because it works reasonably well and there is no
reason not to include it.


# dac7b7c9 06-Dec-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Fix various 64 bit related warnings

Mostly printf() format strings and signed-unsigned comparisons.
Fixes the x86_64 build.


# 25a83d13 30-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

ramdisk: Switch to CLI command for user interface

* Drop the old "echo to control device" interface in favor of an ioctl
interface.
* Add CLI program "ramdisk" to manage RAM disks.


# 4a5eb160 29-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

ramdisk: Add required DEBUG_PAGE_ACCESS_*() macros


# 065e6eb2 28-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

ramdisk: Support file backing

* When registering a ram disk, a file can be specified. Its content will
be loaded into the ram disk:
echo register <file> > /dev/disk/virtual/ramdisk/control
* At any time changes to the ram disk data can be written back to the
file:
echo flush /path/to/ramdisk > /dev/disk/virtual/ramdisk/control
If not explicitly written back, the changes will be lost on reboot.


# 8e416d27 10-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Add a simple RAM disk driver

* It uses physical pages directly, not wasting kernel address space.
* The user interface is somewhat crude, it uses writes to a control
device (output to serial debug/syslog), e.g.
echo register 4g > /dev/disk/virtual/ram/control
to register a 4 GB RAM disk. It is published under
/dev/disk/virtual/ram/<index>/raw and can be formatted with DriveSetup
like any other disk. Unregistering is broken ATM.
* It's not on the image by default, but can be added via
AddNewDriversToHaikuImage disk virtual : ram_disk ;
* I found it quite useful when working on large HaikuPorts ports.
E.g. mounting a RAM disk at the port's work directory shaves a lot of
time off disk heavy operations. Obviously one shouldn't let changes
lie around on it without back up.


# dac7b7c9805cb3c1291a98ceacb4dea94b0cfd65 06-Dec-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Fix various 64 bit related warnings

Mostly printf() format strings and signed-unsigned comparisons.
Fixes the x86_64 build.


# 25a83d13b95b7ef244ecff48dc1b0e027dcad340 30-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

ramdisk: Switch to CLI command for user interface

* Drop the old "echo to control device" interface in favor of an ioctl
interface.
* Add CLI program "ramdisk" to manage RAM disks.


# 4a5eb160530cec0e87772e2aa3aa1a7f1703b55e 29-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

ramdisk: Add required DEBUG_PAGE_ACCESS_*() macros


# 065e6eb2f4d661a462bd89130ed3ba6fd9813a45 28-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

ramdisk: Support file backing

* When registering a ram disk, a file can be specified. Its content will
be loaded into the ram disk:
echo register <file> > /dev/disk/virtual/ramdisk/control
* At any time changes to the ram disk data can be written back to the
file:
echo flush /path/to/ramdisk > /dev/disk/virtual/ramdisk/control
If not explicitly written back, the changes will be lost on reboot.


# 8e416d27ff2edcf0458e7916357584a4d35c2d58 10-Nov-2013 Ingo Weinhold <ingo_weinhold@gmx.de>

Add a simple RAM disk driver

* It uses physical pages directly, not wasting kernel address space.
* The user interface is somewhat crude, it uses writes to a control
device (output to serial debug/syslog), e.g.
echo register 4g > /dev/disk/virtual/ram/control
to register a 4 GB RAM disk. It is published under
/dev/disk/virtual/ram/<index>/raw and can be formatted with DriveSetup
like any other disk. Unregistering is broken ATM.
* It's not on the image by default, but can be added via
AddNewDriversToHaikuImage disk virtual : ram_disk ;
* I found it quite useful when working on large HaikuPorts ports.
E.g. mounting a RAM disk at the port's work directory shaves a lot of
time off disk heavy operations. Obviously one shouldn't let changes
lie around on it without back up.