Commit ed2f2f9b3ff8debdf512f7687b232c3c1d7d60d7

Authored by Mark Fasheh
Committed by Linus Torvalds
1 parent 6967614761

Document ->page_mkwrite() locking

There seems to be very little documentation about this callback in general.
The locking in particular is a bit tricky, so it's worth having this in
writing.

Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 10 additions and 1 deletions Side-by-side Diff

Documentation/filesystems/Locking
... ... @@ -512,13 +512,22 @@
512 512 void (*close)(struct vm_area_struct*);
513 513 struct page *(*fault)(struct vm_area_struct*, struct fault_data *);
514 514 struct page *(*nopage)(struct vm_area_struct*, unsigned long, int *);
  515 + int (*page_mkwrite)(struct vm_area_struct *, struct page *);
515 516  
516 517 locking rules:
517   - BKL mmap_sem
  518 + BKL mmap_sem PageLocked(page)
518 519 open: no yes
519 520 close: no yes
520 521 fault: no yes
521 522 nopage: no yes
  523 +page_mkwrite: no yes no
  524 +
  525 + ->page_mkwrite() is called when a previously read-only page is
  526 +about to become writeable. The file system is responsible for
  527 +protecting against truncate races. Once appropriate action has been
  528 +taking to lock out truncate, the page range should be verified to be
  529 +within i_size. The page mapping should also be checked that it is not
  530 +NULL.
522 531  
523 532 ================================================================================
524 533 Dubious stuff