diff options
author | Hugh Dickins <hughd@google.com> | 2012-07-11 17:02:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-11 19:04:48 -0400 |
commit | f21f8062201fc6361f65de92e758a76375ba8c59 (patch) | |
tree | e15ec62a2167a3fbf6e853fb2445ba13d404cad1 /mm | |
parent | 6b91bf1a3f52f5fdf40f5aaeb09a06b4d49556cc (diff) |
tmpfs: revert SEEK_DATA and SEEK_HOLE
Revert 4fb5ef089b28 ("tmpfs: support SEEK_DATA and SEEK_HOLE"). I believe
it's correct, and it's been nice to have from rc1 to rc6; but as the
original commit said:
I don't know who actually uses SEEK_DATA or SEEK_HOLE, and whether it
would be of any use to them on tmpfs. This code adds 92 lines and 752
bytes on x86_64 - is that bloat or worthwhile?
Nobody asked for it, so I conclude that it's bloat: let's revert tmpfs to
the dumb generic support for v3.5. We can always reinstate it later if
useful, and anyone needing it in a hurry can just get it out of git.
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Josef Bacik <josef@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Andreas Dilger <adilger@dilger.ca>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Marco Stornelli <marco.stornelli@gmail.com>
Cc: Jeff liu <jeff.liu@oracle.com>
Cc: Chris Mason <chris.mason@fusionio.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/shmem.c | 94 |
1 files changed, 1 insertions, 93 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index 4ce02e0673db..3f696f7d9bac 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -1692,98 +1692,6 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos, | |||
1692 | return error; | 1692 | return error; |
1693 | } | 1693 | } |
1694 | 1694 | ||
1695 | /* | ||
1696 | * llseek SEEK_DATA or SEEK_HOLE through the radix_tree. | ||
1697 | */ | ||
1698 | static pgoff_t shmem_seek_hole_data(struct address_space *mapping, | ||
1699 | pgoff_t index, pgoff_t end, int origin) | ||
1700 | { | ||
1701 | struct page *page; | ||
1702 | struct pagevec pvec; | ||
1703 | pgoff_t indices[PAGEVEC_SIZE]; | ||
1704 | bool done = false; | ||
1705 | int i; | ||
1706 | |||
1707 | pagevec_init(&pvec, 0); | ||
1708 | pvec.nr = 1; /* start small: we may be there already */ | ||
1709 | while (!done) { | ||
1710 | pvec.nr = shmem_find_get_pages_and_swap(mapping, index, | ||
1711 | pvec.nr, pvec.pages, indices); | ||
1712 | if (!pvec.nr) { | ||
1713 | if (origin == SEEK_DATA) | ||
1714 | index = end; | ||
1715 | break; | ||
1716 | } | ||
1717 | for (i = 0; i < pvec.nr; i++, index++) { | ||
1718 | if (index < indices[i]) { | ||
1719 | if (origin == SEEK_HOLE) { | ||
1720 | done = true; | ||
1721 | break; | ||
1722 | } | ||
1723 | index = indices[i]; | ||
1724 | } | ||
1725 | page = pvec.pages[i]; | ||
1726 | if (page && !radix_tree_exceptional_entry(page)) { | ||
1727 | if (!PageUptodate(page)) | ||
1728 | page = NULL; | ||
1729 | } | ||
1730 | if (index >= end || | ||
1731 | (page && origin == SEEK_DATA) || | ||
1732 | (!page && origin == SEEK_HOLE)) { | ||
1733 | done = true; | ||
1734 | break; | ||
1735 | } | ||
1736 | } | ||
1737 | shmem_deswap_pagevec(&pvec); | ||
1738 | pagevec_release(&pvec); | ||
1739 | pvec.nr = PAGEVEC_SIZE; | ||
1740 | cond_resched(); | ||
1741 | } | ||
1742 | return index; | ||
1743 | } | ||
1744 | |||
1745 | static loff_t shmem_file_llseek(struct file *file, loff_t offset, int origin) | ||
1746 | { | ||
1747 | struct address_space *mapping; | ||
1748 | struct inode *inode; | ||
1749 | pgoff_t start, end; | ||
1750 | loff_t new_offset; | ||
1751 | |||
1752 | if (origin != SEEK_DATA && origin != SEEK_HOLE) | ||
1753 | return generic_file_llseek_size(file, offset, origin, | ||
1754 | MAX_LFS_FILESIZE); | ||
1755 | mapping = file->f_mapping; | ||
1756 | inode = mapping->host; | ||
1757 | mutex_lock(&inode->i_mutex); | ||
1758 | /* We're holding i_mutex so we can access i_size directly */ | ||
1759 | |||
1760 | if (offset < 0) | ||
1761 | offset = -EINVAL; | ||
1762 | else if (offset >= inode->i_size) | ||
1763 | offset = -ENXIO; | ||
1764 | else { | ||
1765 | start = offset >> PAGE_CACHE_SHIFT; | ||
1766 | end = (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; | ||
1767 | new_offset = shmem_seek_hole_data(mapping, start, end, origin); | ||
1768 | new_offset <<= PAGE_CACHE_SHIFT; | ||
1769 | if (new_offset > offset) { | ||
1770 | if (new_offset < inode->i_size) | ||
1771 | offset = new_offset; | ||
1772 | else if (origin == SEEK_DATA) | ||
1773 | offset = -ENXIO; | ||
1774 | else | ||
1775 | offset = inode->i_size; | ||
1776 | } | ||
1777 | } | ||
1778 | |||
1779 | if (offset >= 0 && offset != file->f_pos) { | ||
1780 | file->f_pos = offset; | ||
1781 | file->f_version = 0; | ||
1782 | } | ||
1783 | mutex_unlock(&inode->i_mutex); | ||
1784 | return offset; | ||
1785 | } | ||
1786 | |||
1787 | static long shmem_fallocate(struct file *file, int mode, loff_t offset, | 1695 | static long shmem_fallocate(struct file *file, int mode, loff_t offset, |
1788 | loff_t len) | 1696 | loff_t len) |
1789 | { | 1697 | { |
@@ -2787,7 +2695,7 @@ static const struct address_space_operations shmem_aops = { | |||
2787 | static const struct file_operations shmem_file_operations = { | 2695 | static const struct file_operations shmem_file_operations = { |
2788 | .mmap = shmem_mmap, | 2696 | .mmap = shmem_mmap, |
2789 | #ifdef CONFIG_TMPFS | 2697 | #ifdef CONFIG_TMPFS |
2790 | .llseek = shmem_file_llseek, | 2698 | .llseek = generic_file_llseek, |
2791 | .read = do_sync_read, | 2699 | .read = do_sync_read, |
2792 | .write = do_sync_write, | 2700 | .write = do_sync_write, |
2793 | .aio_read = shmem_file_aio_read, | 2701 | .aio_read = shmem_file_aio_read, |