aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'fs/iomap/direct-io.c')
-rw-r--r--fs/iomap/direct-io.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 933f234d5bec..70488904a778 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -6,6 +6,7 @@
6#include <linux/module.h> 6#include <linux/module.h>
7#include <linux/compiler.h> 7#include <linux/compiler.h>
8#include <linux/fs.h> 8#include <linux/fs.h>
9#include <linux/fscrypt.h>
9#include <linux/iomap.h> 10#include <linux/iomap.h>
10#include <linux/backing-dev.h> 11#include <linux/backing-dev.h>
11#include <linux/uio.h> 12#include <linux/uio.h>
@@ -185,11 +186,14 @@ static void
185iomap_dio_zero(struct iomap_dio *dio, struct iomap *iomap, loff_t pos, 186iomap_dio_zero(struct iomap_dio *dio, struct iomap *iomap, loff_t pos,
186 unsigned len) 187 unsigned len)
187{ 188{
189 struct inode *inode = file_inode(dio->iocb->ki_filp);
188 struct page *page = ZERO_PAGE(0); 190 struct page *page = ZERO_PAGE(0);
189 int flags = REQ_SYNC | REQ_IDLE; 191 int flags = REQ_SYNC | REQ_IDLE;
190 struct bio *bio; 192 struct bio *bio;
191 193
192 bio = bio_alloc(GFP_KERNEL, 1); 194 bio = bio_alloc(GFP_KERNEL, 1);
195 fscrypt_set_bio_crypt_ctx(bio, inode, pos >> inode->i_blkbits,
196 GFP_KERNEL);
193 bio_set_dev(bio, iomap->bdev); 197 bio_set_dev(bio, iomap->bdev);
194 bio->bi_iter.bi_sector = iomap_sector(iomap, pos); 198 bio->bi_iter.bi_sector = iomap_sector(iomap, pos);
195 bio->bi_private = dio; 199 bio->bi_private = dio;
@@ -255,6 +259,7 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length,
255 ret = nr_pages; 259 ret = nr_pages;
256 goto out; 260 goto out;
257 } 261 }
262 nr_pages = fscrypt_limit_dio_pages(inode, pos, nr_pages);
258 263
259 if (need_zeroout) { 264 if (need_zeroout) {
260 /* zero out from the start of the block to the write offset */ 265 /* zero out from the start of the block to the write offset */
@@ -272,6 +277,8 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length,
272 } 277 }
273 278
274 bio = bio_alloc(GFP_KERNEL, nr_pages); 279 bio = bio_alloc(GFP_KERNEL, nr_pages);
280 fscrypt_set_bio_crypt_ctx(bio, inode, pos >> inode->i_blkbits,
281 GFP_KERNEL);
275 bio_set_dev(bio, iomap->bdev); 282 bio_set_dev(bio, iomap->bdev);
276 bio->bi_iter.bi_sector = iomap_sector(iomap, pos); 283 bio->bi_iter.bi_sector = iomap_sector(iomap, pos);
277 bio->bi_write_hint = dio->iocb->ki_hint; 284 bio->bi_write_hint = dio->iocb->ki_hint;
@@ -309,6 +316,7 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length,
309 copied += n; 316 copied += n;
310 317
311 nr_pages = iov_iter_npages(dio->submit.iter, BIO_MAX_PAGES); 318 nr_pages = iov_iter_npages(dio->submit.iter, BIO_MAX_PAGES);
319 nr_pages = fscrypt_limit_dio_pages(inode, pos, nr_pages);
312 iomap_dio_submit_bio(dio, iomap, bio, pos); 320 iomap_dio_submit_bio(dio, iomap, bio, pos);
313 pos += n; 321 pos += n;
314 } while (nr_pages); 322 } while (nr_pages);