On Sat, 2008-08-16 at 16:33 +0100, David Woodhouse wrote: > Any particular reason why I shouldn't do this? ... and (something similar to) this... diff --git a/include/linux/fadvise.h b/include/linux/fadvise.h index e8e7471..344ab0e 100644 --- a/include/linux/fadvise.h +++ b/include/linux/fadvise.h @@ -18,4 +18,6 @@ #define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */ #endif +#define LINUX_FADV_REMOVE 16 /* Discard data permanently */ + #endif /* FADVISE_H_INCLUDED */ diff --git a/mm/fadvise.c b/mm/fadvise.c index 343cfdf..c2e1baf 100644 --- a/mm/fadvise.c +++ b/mm/fadvise.c @@ -57,6 +57,7 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) case POSIX_FADV_WILLNEED: case POSIX_FADV_NOREUSE: case POSIX_FADV_DONTNEED: + case LINUX_FADV_REMOVE: /* no bad return value, but ignore advice */ break; default: @@ -119,6 +120,29 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) invalidate_mapping_pages(mapping, start_index, end_index); break; + case LINUX_FADV_REMOVE: + if (!(file->f_mode & FMODE_WRITE)) { + ret = -EBADF; + goto out; + } + if ((offset & ~PAGE_MASK) || (len & ~PAGE_MASK)) { + /* truncate_inode_pages_range() can't cope */ + ret = -EINVAL; + goto out; + } + if (endbyte == -1) { + /* FIXME: truncate to end */ + ret = -EINVAL; + goto out; + } + + if (!mapping->host || !mapping->host->i_op || + !mapping->host->i_op->truncate_range) { + ret = -EINVAL; + goto out; + } + vmtruncate_range(mapping->host, offset, endbyte); + break; default: ret = -EINVAL; } -- David Woodhouse Open Source Technology Centre David.Woodhouse@xxxxxxxxx Intel Corporation -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html