Skip to content

Commit 4e02ed4

Browse files
Nick Piggintorvalds
authored andcommitted
fs: remove prepare_write/commit_write
Nothing uses prepare_write or commit_write. Remove them from the tree completely. [akpm@linux-foundation.org: schedule simple_prepare_write() for unexporting] Signed-off-by: Nick Piggin <npiggin@suse.de> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 9b91373 commit 4e02ed4

9 files changed

Lines changed: 23 additions & 293 deletions

File tree

‎Documentation/filesystems/Locking‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,12 @@ prototypes:
161161
int (*set_page_dirty)(struct page *page);
162162
int (*readpages)(struct file *filp, struct address_space *mapping,
163163
struct list_head *pages, unsigned nr_pages);
164-
int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
165-
int (*commit_write)(struct file *, struct page *, unsigned, unsigned);
164+
int (*write_begin)(struct file *, struct address_space *mapping,
165+
loff_t pos, unsigned len, unsigned flags,
166+
struct page **pagep, void **fsdata);
167+
int (*write_end)(struct file *, struct address_space *mapping,
168+
loff_t pos, unsigned len, unsigned copied,
169+
struct page *page, void *fsdata);
166170
sector_t (*bmap)(struct address_space *, sector_t);
167171
int (*invalidatepage) (struct page *, unsigned long);
168172
int (*releasepage) (struct page *, int);
@@ -180,8 +184,6 @@ sync_page: no maybe
180184
writepages: no
181185
set_page_dirty no no
182186
readpages: no
183-
prepare_write: no yes yes
184-
commit_write: no yes yes
185187
write_begin: no locks the page yes
186188
write_end: no yes, unlocks yes
187189
perform_write: no n/a yes
@@ -191,7 +193,7 @@ releasepage: no yes
191193
direct_IO: no
192194
launder_page: no yes
193195

194-
->prepare_write(), ->commit_write(), ->sync_page() and ->readpage()
196+
->write_begin(), ->write_end(), ->sync_page() and ->readpage()
195197
may be called from the request handler (/dev/loop).
196198

197199
->readpage() unlocks the page, either synchronously or via I/O

‎Documentation/filesystems/vfs.txt‎

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ written-back to storage typically in whole pages, however the
492492
address_space has finer control of write sizes.
493493

494494
The read process essentially only requires 'readpage'. The write
495-
process is more complicated and uses prepare_write/commit_write or
495+
process is more complicated and uses write_begin/write_end or
496496
set_page_dirty to write data into the address_space, and writepage,
497497
sync_page, and writepages to writeback data to storage.
498498

@@ -521,8 +521,6 @@ struct address_space_operations {
521521
int (*set_page_dirty)(struct page *page);
522522
int (*readpages)(struct file *filp, struct address_space *mapping,
523523
struct list_head *pages, unsigned nr_pages);
524-
int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
525-
int (*commit_write)(struct file *, struct page *, unsigned, unsigned);
526524
int (*write_begin)(struct file *, struct address_space *mapping,
527525
loff_t pos, unsigned len, unsigned flags,
528526
struct page **pagep, void **fsdata);
@@ -598,37 +596,7 @@ struct address_space_operations {
598596
readpages is only used for read-ahead, so read errors are
599597
ignored. If anything goes wrong, feel free to give up.
600598

601-
prepare_write: called by the generic write path in VM to set up a write
602-
request for a page. This indicates to the address space that
603-
the given range of bytes is about to be written. The
604-
address_space should check that the write will be able to
605-
complete, by allocating space if necessary and doing any other
606-
internal housekeeping. If the write will update parts of
607-
any basic-blocks on storage, then those blocks should be
608-
pre-read (if they haven't been read already) so that the
609-
updated blocks can be written out properly.
610-
The page will be locked.
611-
612-
Note: the page _must not_ be marked uptodate in this function
613-
(or anywhere else) unless it actually is uptodate right now. As
614-
soon as a page is marked uptodate, it is possible for a concurrent
615-
read(2) to copy it to userspace.
616-
617-
commit_write: If prepare_write succeeds, new data will be copied
618-
into the page and then commit_write will be called. It will
619-
typically update the size of the file (if appropriate) and
620-
mark the inode as dirty, and do any other related housekeeping
621-
operations. It should avoid returning an error if possible -
622-
errors should have been handled by prepare_write.
623-
624-
write_begin: This is intended as a replacement for prepare_write. The
625-
key differences being that:
626-
- it returns a locked page (in *pagep) rather than being
627-
given a pre locked page;
628-
- it must be able to cope with short writes (where the
629-
length passed to write_begin is greater than the number
630-
of bytes copied into the page).
631-
599+
write_begin:
632600
Called by the generic buffered write code to ask the filesystem to
633601
prepare to write len bytes at the given offset in the file. The
634602
address_space should check that the write will be able to complete,
@@ -640,6 +608,9 @@ struct address_space_operations {
640608
The filesystem must return the locked pagecache page for the specified
641609
offset, in *pagep, for the caller to write into.
642610

611+
It must be able to cope with short writes (where the length passed to
612+
write_begin is greater than the number of bytes copied into the page).
613+
643614
flags is a field for AOP_FLAG_xxx flags, described in
644615
include/linux/fs.h.
645616

‎drivers/block/loop.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040
* Heinz Mauelshagen <mge@sistina.com>, Feb 2002
4141
*
4242
* Support for falling back on the write file operation when the address space
43-
* operations prepare_write and/or commit_write are not available on the
44-
* backing filesystem.
43+
* operations write_begin is not available on the backing filesystem.
4544
* Anton Altaparmakov, 16 Feb 2005
4645
*
4746
* Still To Fix:
@@ -765,7 +764,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
765764
*/
766765
if (!file->f_op->splice_read)
767766
goto out_putf;
768-
if (aops->prepare_write || aops->write_begin)
767+
if (aops->write_begin)
769768
lo_flags |= LO_FLAGS_USE_AOPS;
770769
if (!(lo_flags & LO_FLAGS_USE_AOPS) && !file->f_op->write)
771770
lo_flags |= LO_FLAGS_READ_ONLY;

‎fs/fat/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb,
175175

176176
if (rw == WRITE) {
177177
/*
178-
* FIXME: blockdev_direct_IO() doesn't use ->prepare_write(),
178+
* FIXME: blockdev_direct_IO() doesn't use ->write_begin(),
179179
* so we need to update the ->mmu_private to block boundary.
180180
*
181181
* But we must fill the remaining area or hole by nul for

‎fs/libfs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ EXPORT_SYMBOL(simple_getattr);
814814
EXPORT_SYMBOL(simple_link);
815815
EXPORT_SYMBOL(simple_lookup);
816816
EXPORT_SYMBOL(simple_pin_fs);
817-
EXPORT_SYMBOL(simple_prepare_write);
817+
EXPORT_UNUSED_SYMBOL(simple_prepare_write);
818818
EXPORT_SYMBOL(simple_readpage);
819819
EXPORT_SYMBOL(simple_release_fs);
820820
EXPORT_SYMBOL(simple_rename);

‎fs/ocfs2/file.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,7 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start,
679679

680680
/* Some parts of this taken from generic_cont_expand, which turned out
681681
* to be too fragile to do exactly what we need without us having to
682-
* worry about recursive locking in ->prepare_write() and
683-
* ->commit_write(). */
682+
* worry about recursive locking in ->write_begin() and ->write_end(). */
684683
static int ocfs2_write_zero_page(struct inode *inode,
685684
u64 size)
686685
{

‎fs/splice.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,8 @@ ssize_t splice_from_pipe(struct pipe_inode_info *pipe, struct file *out,
731731
};
732732

733733
/*
734-
* The actor worker might be calling ->prepare_write and
735-
* ->commit_write. Most of the time, these expect i_mutex to
734+
* The actor worker might be calling ->write_begin and
735+
* ->write_end. Most of the time, these expect i_mutex to
736736
* be held. Since this may result in an ABBA deadlock with
737737
* pipe->inode, we have to order lock acquiry here.
738738
*/

‎include/linux/fs.h‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,6 @@ struct address_space_operations {
489489
int (*readpages)(struct file *filp, struct address_space *mapping,
490490
struct list_head *pages, unsigned nr_pages);
491491

492-
/*
493-
* ext3 requires that a successful prepare_write() call be followed
494-
* by a commit_write() call - they must be balanced
495-
*/
496-
int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
497-
int (*commit_write)(struct file *, struct page *, unsigned, unsigned);
498-
499492
int (*write_begin)(struct file *, struct address_space *mapping,
500493
loff_t pos, unsigned len, unsigned flags,
501494
struct page **pagep, void **fsdata);

0 commit comments

Comments
 (0)