]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/ext4/file.c
ext4: fix SEEK_HOLE/SEEK_DATA for blocksize < pagesize
[karo-tx-linux.git] / fs / ext4 / file.c
index 58e2eeaa0bc49134ad86eabef47d53ab6b019705..0d7cf0cc9b87562bbc52b17224794d9147208910 100644 (file)
@@ -364,13 +364,6 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma)
        if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
                return -EIO;
 
-       if (ext4_encrypted_inode(inode)) {
-               int err = fscrypt_get_encryption_info(inode);
-               if (err)
-                       return 0;
-               if (!fscrypt_has_encryption_key(inode))
-                       return -ENOKEY;
-       }
        file_accessed(file);
        if (IS_DAX(file_inode(file))) {
                vma->vm_ops = &ext4_dax_vm_ops;
@@ -544,6 +537,8 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
                                lastoff = page_offset(page);
                                bh = head = page_buffers(page);
                                do {
+                                       if (lastoff + bh->b_size <= startoff)
+                                               goto next;
                                        if (buffer_uptodate(bh) ||
                                            buffer_unwritten(bh)) {
                                                if (whence == SEEK_DATA)
@@ -558,6 +553,7 @@ static int ext4_find_unwritten_pgoff(struct inode *inode,
                                                unlock_page(page);
                                                goto out;
                                        }
+next:
                                        lastoff += bh->b_size;
                                        bh = bh->b_this_page;
                                } while (bh != head);