From 7cbfba44f6ca2d707ba45c96e5273d5b0b02f1dc Mon Sep 17 00:00:00 2001 From: Dave Kleikamp Date: Tue, 22 Sep 2015 14:18:11 -0500 Subject: [PATCH] block: loop: don't enable direct-io unless the filesystem supports it Commit 3ddce635 was over-aggressive and enabled direct-io in the loop driver even if the underlying file system didn't support it. This would cause a NULL dereference of aops->direct_IO. Signed-off-by: Dave Kleikamp --- drivers/block/loop.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 7b326f2a95bf..b967126d28e2 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -555,7 +555,10 @@ static inline void loop_update_dio(struct loop_device *lo) /* * UEK kernel will use direct-io whenever possible */ - __loop_update_dio(lo, 1); + struct address_space *mapping = lo->lo_backing_file->f_mapping; + bool supports_dio = mapping->a_ops->direct_IO != NULL; + + __loop_update_dio(lo, supports_dio); } /* -- 2.50.1