LKM:写入设备的最后一个块 [英] LKM: Last block written to device

查看:104
本文介绍了LKM:写入设备的最后一个块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在模块内部找到一种方法,以跟踪写入到块设备的最后一个块.我需要的特定设备是安装在根目录下的设备(如果有帮助,我会提前知道/dev/名称.)

I am trying to find a way, inside a module, to keep track of the last block written to a block device. The specific device I need is the one mounted at root (I know the /dev/ name ahead of time if that helps.)

我最初的想法是包装Submit_bio函数,因为如果您回显1>/proc/sys/vm/block_dump",它已经具有日志记录功能.不幸的是,似乎我需要修改源代码才能使该函数成为指针.我想尽可能将其保留在模块中.

My original idea was to wrap the submit_bio function, since it has a logging function already if you "echo 1 > /proc/sys/vm/block_dump". Unfortunately it seems I'd need to modify the source code to make that function a pointer. I'd like to keep this all inside the module if at all possible.

在那之后,我研究了查找文件系统类型,并包装了默认的文件操作(毕竟这些已经是函数指针).但是,它们都是声明为const的.

After that, I looked into finding the file system type, and wrapping the default file operations (these are already function pointers, after all). Those are declared as a const, though, so same issue.

我知道这是一件很奇怪的事情.仍然需要这样做.有人有什么想法可以带我前进吗?

This is kind of an odd thing to be trying to do, I understand. Need to do it none-the-less. Does anyone have any ideas that might get me going?

推荐答案

Linux内核提供了几种不同的跟踪工具包. blktrace工具是专门为块设备设计的. blkparse(1)工具将解析blktrace(8)实用程序的输出. (至少Ubuntu将这些软件包打包在blktrace软件包中;我希望其他发行版也是如此.)bklparse(1)工具可以为您提供扇区信息.

The Linux kernel provides several different tracing toolkits; the blktrace tools were designed specifically for block devices. The blkparse(1) tool will parse the output of the blktrace(8) utility. (At least Ubuntu has these packaged in the blktrace package; I expect other distributions to be similar.) The bklparse(1) tool can give you the sector information.

Documentation/trace/events.txt描述了另一种跟踪机制-一种跟踪机制,可以让您跟踪block:block_bio_complete事件,该事件包括扇区信息.这不需要安装bkltrace工具包,但我会(勉强地)承认我不知道在哪里读取跟踪日志.

Documentation/trace/events.txt describes another tracing mechanism -- one that could allow you to follow the block:block_bio_complete event, which includes the sector information. This won't require installing the bkltrace toolkit but I'll (sheepishly) admit that I don't know where to read the trace log.

这篇关于LKM:写入设备的最后一个块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆