Hi, When using the BLKZEROOUT ioctl what should be the impact on buffer cache data? Is the caller expected to invalidate the cache and if so how? The following program demonstrates the issue: #!/usr/bin/python2 import fcntl import os import struct def ioctl(fd, req, fmt, *args): buf = struct.pack(fmt, *(args or [0])) buf = fcntl.ioctl(fd, req, buf) return struct.unpack(fmt, buf)[0] def file_is_null(f): CHUNKSIZE = 1 * 1024 * 1024 null_chunk = "\0" * CHUNKSIZE f.seek(0) while True: chunk = f.read(CHUNKSIZE) if not(chunk): return True elif chunk != null_chunk: return False def write_ones(f): CHUNKSIZE = 1 * 1024 * 1024 ones_chunk = "\xff" * CHUNKSIZE f.seek(0) try: while True: f.write(ones_chunk) except IOError as e: if e.errno != 28: raise f.flush() IOCTL_BLKFLSBUF = 0x1261 IOCTL_BLKGETSIZE64 = 0x80081272 IOCTL_BLKZEROOUT = 0x127f # /dev/sde is a 2GByte fixed size Hyper-V VHDX file fd = open('/dev/sde', 'w') f = open('/dev/sde', 'r') size = ioctl(fd, IOCTL_BLKGETSIZE64, 'L') write_ones(fd) os.fsync(fd) print ioctl(fd, IOCTL_BLKZEROOUT, 'LL', 0, size) os.fsync(fd) print file_is_null(f) # Returns False write_ones(fd) print ioctl(fd, IOCTL_BLKFLSBUF, 'LL', 0, 0) print ioctl(fd, IOCTL_BLKZEROOUT, 'LL', 0, size) print file_is_null(f) # Returns True # grep . /sys/block/sde/queue/* 2> /dev/null /sys/block/sde/queue/add_random:1 /sys/block/sde/queue/discard_granularity:33554432 /sys/block/sde/queue/discard_max_bytes:4294966784 /sys/block/sde/queue/discard_zeroes_data:0 /sys/block/sde/queue/hw_sector_size:512 /sys/block/sde/queue/iostats:1 /sys/block/sde/queue/logical_block_size:512 /sys/block/sde/queue/max_hw_sectors_kb:512 /sys/block/sde/queue/max_integrity_segments:0 /sys/block/sde/queue/max_sectors_kb:512 /sys/block/sde/queue/max_segments:2048 /sys/block/sde/queue/max_segment_size:4096 /sys/block/sde/queue/minimum_io_size:4096 /sys/block/sde/queue/nomerges:0 /sys/block/sde/queue/nr_requests:128 /sys/block/sde/queue/optimal_io_size:0 /sys/block/sde/queue/physical_block_size:4096 /sys/block/sde/queue/read_ahead_kb:128 /sys/block/sde/queue/rotational:1 /sys/block/sde/queue/rq_affinity:1 /sys/block/sde/queue/scheduler:[noop] deadline cfq /sys/block/sde/queue/write_same_max_bytes:0 -- Sitsofe | http://sucs.org/~sits/ -- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html