这边有个需求是替换adobe fms 热点文件的时候防止删除正在访问的文件,保证用户请求不中断
但是发现adobe fms open的文件lsof看不到,但是iostat能证实该磁盘是在读取的,很奇怪
尝试用inotify去捕捉事件,可以发现:
[@dg_80_65 inotify-tools-3.14]# inotifywait -m \ --timefmt '%d/%m/%y %H:%M' --format '%T %e %w%f' \ /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
Setting up watches.
Watches established.
01/11/10 18:37 OPEN /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:37 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:37 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:37 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:37 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:37 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:37 CLOSE_NOWRITE,CLOSE /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:37 OPEN /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:37 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:37 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:37 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:37 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:37 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:37 CLOSE_NOWRITE,CLOSE /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:38 OPEN /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:38 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:38 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:38 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:38 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:38 CLOSE_NOWRITE,CLOSE /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:38 OPEN /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:38 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:38 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:38 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:38 ACCESS /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
01/11/10 18:38 CLOSE_NOWRITE,CLOSE /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4
所有文件迅速的打开,读取,关闭,所以lsof捕捉不到
adobe的文档是这么说的:
When a stream is requested from the server, segments of the stream are stored in a cache on the server. As long as the cache has not reached capacity, the server places segments in the cache. Each time a stream attempts to access a segment, the server checks the cache. If the segment is available, the server gives the stream a reference to the segment for playback. If the segment is not available, the server retrieves the segment from its source, inserts it into the cache, and returns a reference to that segment to the stream.
When the cache is full, the server removes unused segments, starting with the least recently used. After removing all unused segments, if there still isn’t enough room for a new segment, the server notifies the client that the stream is not available and makes an entry in the core log file.
大意是说fms是从缓存区取文件的,如果不存在该文件的这一部分,就会从源文件读取,放入缓存区,再给用户
因此,比较可以接受的办法是删除文件之前判断下access time的时间戳
stat -c %X /data/video/ssdcached/stream/20100525/57d4f5a6-fc8d-4f8f-b0f7-c00020f6c7ac.mp4