]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/ntfs/aops.c
[PKT_SCHED] HTB: htb_classid is dead static inline
[linux-2.6-omap-h63xx.git] / fs / ntfs / aops.c
index cfdc7900d2710f70bee9aa7d591d8b8fb4c85c31..ad87cb01299b6d8febb7ae670fddb36ce33cc666 100644 (file)
@@ -405,6 +405,15 @@ static int ntfs_readpage(struct file *file, struct page *page)
 
 retry_readpage:
        BUG_ON(!PageLocked(page));
+       vi = page->mapping->host;
+       i_size = i_size_read(vi);
+       /* Is the page fully outside i_size? (truncate in progress) */
+       if (unlikely(page->index >= (i_size + PAGE_CACHE_SIZE - 1) >>
+                       PAGE_CACHE_SHIFT)) {
+               zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0);
+               ntfs_debug("Read outside i_size - truncated?");
+               goto done;
+       }
        /*
         * This can potentially happen because we clear PageUptodate() during
         * ntfs_writepage() of MstProtected() attributes.
@@ -413,7 +422,6 @@ retry_readpage:
                unlock_page(page);
                return 0;
        }
-       vi = page->mapping->host;
        ni = NTFS_I(vi);
        /*
         * Only $DATA attributes can be encrypted and only unnamed $DATA