2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
2006-05-18 15:09:15 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-09-01 11:05:15 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-07-02 21:12:01 +02:00
|
|
|
|
2006-02-08 11:50:51 +00:00
|
|
|
|
2006-02-27 17:23:27 -05:00
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
2006-11-30 10:14:32 -05:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2009-01-12 10:43:39 +00:00
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
2006-02-27 17:23:27 -05:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-02-27 17:23:27 -05:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-12-17 15:59:39 -08:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-12-17 15:59:39 -08:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2006-06-14 15:32:57 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-12-17 15:59:39 -08:00
|
|
|
|
2011-08-23 10:19:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-12-17 15:59:39 -08:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
2011-08-23 10:19:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-12-17 15:59:39 -08:00
|
|
|
|
2011-08-23 10:19:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-09-19 16:41:11 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-09-19 16:41:11 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
2006-06-14 15:32:57 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2006-09-04 12:49:07 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
2008-09-18 13:53:59 +01:00
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-27 12:16:06 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-10-02 11:24:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2006-10-02 11:24:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-07-18 11:40:06 +01:00
|
|
|
|
2012-05-28 15:26:56 +01:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
2006-10-02 11:24:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-28 15:26:56 +01:00
|
|
|
|
2006-10-02 11:24:43 -04:00
|
|
|
|
2006-03-31 15:01:28 -05:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
2006-04-07 11:17:32 -04:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
2013-01-23 17:07:38 -05:00
|
|
|
|
2006-06-14 15:32:57 -04:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
2006-10-02 11:24:43 -04:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
2008-09-18 13:53:59 +01:00
|
|
|
|
|
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
2006-09-25 09:26:04 -04:00
|
|
|
|
2008-11-04 10:05:22 +00:00
|
|
|
|
|
|
|
|
|
2008-07-10 16:09:29 +01:00
|
|
|
|
2006-10-02 11:24:43 -04:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-11-08 12:51:06 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-06-16 14:06:55 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-11-04 10:05:22 +00:00
|
|
|
|
2006-11-08 12:51:06 -05:00
|
|
|
|
2008-11-04 10:05:22 +00:00
|
|
|
|
2006-11-08 12:51:06 -05:00
|
|
|
|
2008-11-04 10:05:22 +00:00
|
|
|
|
2006-11-08 12:51:06 -05:00
|
|
|
|
2008-11-04 10:05:22 +00:00
|
|
|
|
2006-11-08 12:51:06 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-28 15:26:56 +01:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-07 11:17:32 -04:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
2013-01-23 17:07:38 -05:00
|
|
|
|
2006-06-14 15:32:57 -04:00
|
|
|
|
|
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-04 14:29:30 -04:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
2011-11-23 11:57:51 -05:00
|
|
|
|
2006-07-21 02:03:21 -04:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
2008-07-02 21:12:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-05-24 14:36:48 +01:00
|
|
|
|
2011-03-23 16:43:26 -07:00
|
|
|
|
2010-05-24 14:36:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-11-04 10:05:22 +00:00
|
|
|
|
2006-04-04 14:29:30 -04:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-09-25 09:26:04 -04:00
|
|
|
|
2006-05-12 17:07:56 -04:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
2006-05-12 17:07:56 -04:00
|
|
|
|
2011-06-20 19:28:19 -04:00
|
|
|
|
2006-05-12 17:07:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-17 08:47:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-04 14:29:30 -04:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
2006-04-04 14:29:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-12-14 12:36:02 +00:00
|
|
|
|
2008-11-04 10:05:22 +00:00
|
|
|
|
2006-10-31 15:07:05 -05:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
2006-11-08 12:51:06 -05:00
|
|
|
|
2007-10-17 08:47:38 +01:00
|
|
|
|
2006-04-04 14:29:30 -04:00
|
|
|
|
|
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
2008-07-02 21:12:01 +02:00
|
|
|
|
2011-12-09 08:06:57 -05:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-07 11:17:32 -04:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
2013-01-23 17:07:38 -05:00
|
|
|
|
2006-10-02 11:24:43 -04:00
|
|
|
|
2010-05-24 14:36:48 +01:00
|
|
|
|
2006-10-02 11:24:43 -04:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
2010-05-24 14:36:48 +01:00
|
|
|
|
2006-10-02 11:24:43 -04:00
|
|
|
|
2007-07-18 11:40:06 +01:00
|
|
|
|
2012-05-28 15:26:56 +01:00
|
|
|
|
2007-07-18 11:40:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
2006-04-07 11:17:32 -04:00
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
2006-10-02 11:24:43 -04:00
|
|
|
|
2006-04-07 11:17:32 -04:00
|
|
|
|
2006-10-02 11:24:43 -04:00
|
|
|
|
2006-04-07 11:17:32 -04:00
|
|
|
|
2012-02-08 12:58:32 +00:00
|
|
|
|
|
|
|
|
|
2006-03-28 14:14:04 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-26 11:30:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-23 17:07:38 -05:00
|
|
|
|
2012-07-26 11:30:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-12-10 14:13:27 -06:00
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-03-31 15:23:21 -07:00
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
2009-03-31 15:23:21 -07:00
|
|
|
|
2013-01-23 17:07:38 -05:00
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-06 10:47:50 -06:00
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
|
|
|
|
|
2011-09-07 15:12:51 +01:00
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
|
|
|
|
|
2012-06-12 16:20:41 +02:00
|
|
|
|
2011-09-07 15:12:51 +01:00
|
|
|
|
2012-06-12 16:20:26 +02:00
|
|
|
|
|
|
|
|
|
2011-09-07 15:12:51 +01:00
|
|
|
|
2012-06-06 11:17:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-26 11:30:54 +01:00
|
|
|
|
2012-07-19 08:12:40 -04:00
|
|
|
|
2008-09-18 13:53:59 +01:00
|
|
|
|
|
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-03-19 13:15:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-07 15:12:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
2011-09-07 15:12:51 +01:00
|
|
|
|
|
|
|
|
|
2012-05-18 09:28:23 -04:00
|
|
|
|
|
|
|
|
|
2008-01-10 15:18:55 +00:00
|
|
|
|
|
|
|
|
|
2008-03-10 15:34:50 +00:00
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
2012-05-18 09:28:23 -04:00
|
|
|
|
2008-12-10 10:28:10 +00:00
|
|
|
|
2012-10-31 10:37:10 +00:00
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-09-27 16:00:04 -05:00
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
2012-07-30 14:53:19 +01:00
|
|
|
|
2010-09-27 16:00:04 -05:00
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-07 15:12:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
2011-09-07 15:12:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-07 15:12:51 +01:00
|
|
|
|
|
|
|
|
|
mm: only enforce stable page writes if the backing device requires it
Create a helper function to check if a backing device requires stable
page writes and, if so, performs the necessary wait. Then, make it so
that all points in the memory manager that handle making pages writable
use the helper function. This should provide stable page write support
to most filesystems, while eliminating unnecessary waiting for devices
that don't require the feature.
Before this patchset, all filesystems would block, regardless of whether
or not it was necessary. ext3 would wait, but still generate occasional
checksum errors. The network filesystems were left to do their own
thing, so they'd wait too.
After this patchset, all the disk filesystems except ext3 and btrfs will
wait only if the hardware requires it. ext3 (if necessary) snapshots
pages instead of blocking, and btrfs provides its own bdi so the mm will
never wait. Network filesystems haven't been touched, so either they
provide their own stable page guarantees or they don't block at all.
The blocking behavior is back to what it was before 3.0 if you don't
have a disk requiring stable page writes.
Here's the result of using dbench to test latency on ext2:
3.8.0-rc3:
Operation Count AvgLat MaxLat
----------------------------------------
WriteX 109347 0.028 59.817
ReadX 347180 0.004 3.391
Flush 15514 29.828 287.283
Throughput 57.429 MB/sec 4 clients 4 procs max_latency=287.290 ms
3.8.0-rc3 + patches:
WriteX 105556 0.029 4.273
ReadX 335004 0.005 4.112
Flush 14982 30.540 298.634
Throughput 55.4496 MB/sec 4 clients 4 procs max_latency=298.650 ms
As you can see, the maximum write latency drops considerably with this
patch enabled. The other filesystems (ext3/ext4/xfs/btrfs) behave
similarly, but see the cover letter for those results.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Steven Whitehouse <swhiteho@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Ron Minnich <rminnich@sandia.gov>
Cc: Latchesar Ionkov <lucho@ionkov.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-21 16:42:51 -08:00
|
|
|
|
2011-09-07 15:12:51 +01:00
|
|
|
|
2012-06-12 16:20:41 +02:00
|
|
|
|
2011-09-07 15:12:51 +01:00
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
|
|
|
|
|
2009-09-27 22:29:37 +04:00
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
|
|
|
|
|
2012-10-08 16:28:46 -07:00
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-29 13:59:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-06-14 15:32:57 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2011-02-02 14:48:10 +00:00
|
|
|
|
|
|
|
|
|
2009-04-29 13:59:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-11-06 00:49:28 -06:00
|
|
|
|
|
|
|
|
|
2011-02-02 14:48:10 +00:00
|
|
|
|
|
|
|
|
|
2012-11-06 00:49:28 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2007-10-15 15:40:33 +01:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2009-04-29 13:59:35 +01:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-06-14 15:32:57 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-02-21 12:51:39 +00:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2006-06-14 15:32:57 -04:00
|
|
|
|
2006-02-27 17:23:27 -05:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2006-11-01 12:22:46 -05:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-08-11 09:53:11 +01:00
|
|
|
|
2007-10-16 23:30:22 -07:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-07-31 15:42:17 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2006-07-31 15:42:17 -04:00
|
|
|
|
2006-02-27 17:23:27 -05:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-11 12:56:41 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-11 12:56:41 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2012-06-06 11:17:59 +01:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2012-07-19 08:12:40 -04:00
|
|
|
|
2006-02-27 17:23:27 -05:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2012-07-19 08:12:40 -04:00
|
|
|
|
2012-06-06 11:17:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-07-16 20:44:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-14 09:54:02 +01:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2011-07-27 10:58:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-12-07 09:13:14 -05:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-07-16 20:44:56 -04:00
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2011-07-27 10:58:48 +01:00
|
|
|
|
|
|
|
|
|
2006-11-30 10:14:32 -05:00
|
|
|
|
2011-04-14 09:54:02 +01:00
|
|
|
|
2011-11-08 14:04:20 +00:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2011-07-27 10:58:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-07-16 20:44:56 -04:00
|
|
|
|
2011-04-14 09:54:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-07 10:33:25 +01:00
|
|
|
|
2011-04-14 09:54:02 +01:00
|
|
|
|
2011-08-05 10:12:47 +01:00
|
|
|
|
|
|
|
|
|
2011-09-07 10:33:25 +01:00
|
|
|
|
2006-11-30 10:14:32 -05:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2011-07-27 10:58:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
2009-12-08 10:25:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-19 08:12:40 -04:00
|
|
|
|
2013-01-23 17:07:38 -05:00
|
|
|
|
2012-06-06 11:17:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-08 10:25:33 +00:00
|
|
|
|
2012-07-26 11:30:54 +01:00
|
|
|
|
|
|
|
|
|
2009-12-08 10:25:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-08 13:16:32 -06:00
|
|
|
|
2011-09-12 18:15:24 -05:00
|
|
|
|
|
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-12 18:15:24 -05:00
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
2012-12-14 12:36:02 +00:00
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-12 18:15:24 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
2011-09-12 18:15:24 -05:00
|
|
|
|
|
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
2011-09-12 18:15:24 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
2012-03-08 13:16:32 -06:00
|
|
|
|
|
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-12 18:15:24 -05:00
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-01 13:31:59 +01:00
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-23 17:07:38 -05:00
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-11-21 10:01:25 +00:00
|
|
|
|
|
|
|
|
|
2011-04-26 01:13:24 -05:00
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
2011-09-12 18:15:24 -05:00
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-26 01:13:24 -05:00
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-26 01:13:24 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
2012-06-06 11:17:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-26 11:30:54 +01:00
|
|
|
|
2012-07-19 08:12:40 -04:00
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-08 13:16:32 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
2012-05-18 09:28:23 -04:00
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-10-31 10:37:10 +00:00
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-26 01:13:24 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-12 18:15:24 -05:00
|
|
|
|
|
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
2012-07-30 14:53:19 +01:00
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-11-21 10:01:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-12 10:43:39 +00:00
|
|
|
|
|
|
|
|
|
2007-01-15 18:33:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-12 10:43:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-09-18 15:09:31 +02:00
|
|
|
|
|
|
|
|
|
2007-01-15 18:33:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-12 10:43:39 +00:00
|
|
|
|
2008-01-30 15:34:04 +00:00
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-06-14 15:32:57 -04:00
|
|
|
|
|
|
|
|
|
2009-01-12 10:43:39 +00:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-11 12:24:45 -05:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
2006-11-14 16:37:25 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-12 10:43:39 +00:00
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2009-01-12 10:43:39 +00:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2009-01-12 10:43:39 +00:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2009-01-12 10:43:39 +00:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-02-27 17:23:27 -05:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2013-01-23 17:07:38 -05:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-05-21 17:03:22 +01:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2006-02-21 12:51:39 +00:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-09-25 09:26:04 -04:00
|
|
|
|
2007-09-13 23:35:27 -05:00
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2008-05-21 17:03:22 +01:00
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
2007-09-13 23:35:27 -05:00
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-06-14 15:32:57 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
2006-07-31 15:42:17 -04:00
|
|
|
|
2006-02-21 12:51:39 +00:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-02-27 17:23:27 -05:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
2006-02-21 12:51:39 +00:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2011-03-09 11:14:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-02-21 12:51:39 +00:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-06-01 12:30:03 -05:00
|
|
|
|
|
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-10-02 10:28:05 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
2006-10-02 10:28:05 -04:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
2009-04-07 19:42:17 +02:00
|
|
|
|
2006-09-04 15:32:10 -04:00
|
|
|
|
2006-10-02 10:28:05 -04:00
|
|
|
|
2006-09-04 15:32:10 -04:00
|
|
|
|
2006-10-02 10:28:05 -04:00
|
|
|
|
2009-12-08 10:25:33 +00:00
|
|
|
|
2006-09-04 15:32:10 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-11 12:56:41 -04:00
|
|
|
|
2006-09-04 15:32:10 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-01-15 18:33:36 -05:00
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
2009-04-07 19:42:17 +02:00
|
|
|
|
2006-09-04 15:32:10 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-11 12:56:41 -04:00
|
|
|
|
2006-09-04 15:32:10 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-15 18:52:59 +02:00
|
|
|
|
2006-01-16 16:50:04 +00:00
|
|
|
|
|
|
|
|
|
2009-01-12 10:43:39 +00:00
|
|
|
|
|
|
|
|
|
2009-04-07 19:42:17 +02:00
|
|
|
|
2007-11-29 17:56:51 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-08 10:25:33 +00:00
|
|
|
|
2007-11-29 17:56:51 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-11 12:56:41 -04:00
|
|
|
|
2007-11-29 17:56:51 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-12 10:43:39 +00:00
|
|
|
|
2011-01-14 13:07:43 +01:00
|
|
|
|
2007-11-29 17:56:51 -05:00
|
|
|
|
|
|
|
|
|
2009-04-07 19:42:17 +02:00
|
|
|
|
2007-11-29 17:56:51 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-11 12:56:41 -04:00
|
|
|
|
2007-11-29 17:56:51 -05:00
|
|
|
|
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-15 18:52:59 +02:00
|
|
|
|
2007-11-29 17:56:51 -05:00
|
|
|
|
|
|
|
|
|