Re: Modify a file content from block layer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




As usual, I'm going to start with:

Step 0:  What problem are you trying to solve by doing this?
 
Working on a custom driver that tracks I/Os on block level. For some use case, I need to write metadata of tracked I/Os from driver in shutdown sequence (more likely in reboot handler). In reboot handler, performing I/O on disk is tricky (no userspace, no VFS. no sysfs). 
Although, I am able to write one sector, by creating custom bio and giving manually sector to disk. Still, looking some correct API like write_IO_on_disk(buffer, dev, offset, len)
 
The problem is that the kernel shouldn't be scribbling on files itself, and
that's *extremely* discouraged.   The gory details of why basically boil down
to "the VFS assumes that all filesytem scribbling is called from a user process
context", which causes all sorts of problems if you're in a non-user process
context, or a non-process context entirely.
 
I understand it. Ideally, best practices, I should be not do that, but here is custom scenario, in which in reboot handler no VFS APIs will be accessible.

(There's also deep philosophical issues if you're over-writing blocks of a user
created file, because users have a very reasonable expectation that if they
write a given piece of data into a file system, they get the exact same data
back when they read it...)

But kernel developer should have an interface which takes only buffer, and write on a particular sector, even though it discouraged, but having that facility would not harm.
---
Jitendra
 
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux