[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] dd: add a flag to discard cached data
From: |
Pádraig Brady |
Subject: |
[PATCH] dd: add a flag to discard cached data |
Date: |
Tue, 22 Feb 2011 23:58:02 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 |
I noticed fadvise(DONTNEED) getting some love in the kernel recently
http://lkml.org/lkml/2011/2/17/169
Which prompted me to implement this. With the attached one can now:
# Advise to drop cache for whole file
dd if=ifile iflag=nocache count=0
# Ensure drop cache for whole file
dd of=ofile oflag=nocache conv=notrunc,fdatasync count=0
# Drop cache for part of file
dd if=ifile iflag=nocache skip=10 count=10 of=/dev/null
# Stream data just using readahead cache
dd if=ifile of=ofile iflag=nocache oflag=nocache
When count=0, i.e. when only manipulating the cache,
we propagate the posix_fadvise() return to the exit status.
Note this will invalidate the cache even if another
process has the file open. That could be avoided with mincor:
http://insights.oetiker.ch/linux/fadvise.html
However, I don't think that's needed for a tool like dd.
cheers,
Pádraig.
dd-nocache.diff
Description: Text Data
- [PATCH] dd: add a flag to discard cached data,
Pádraig Brady <=