^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include "reiserfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include "acl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include "xattr.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/pagemap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/swap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/writeback.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/buffer_head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/quotaops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * We pack the tails of files on file close, not at the time they are written.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * This implies an unnecessary copy of the tail and an unnecessary indirect item
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * insertion/balancing, for files that are written in one write.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * It avoids unnecessary tail packings (balances) for files that are written in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * multiple writes and are small enough to have tails.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * file_release is called by the VFS layer when the file is closed. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * this is the last open file descriptor, and the file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * small enough to have a tail, and the tail is currently in an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * unformatted node, the tail is converted back into a direct item.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * We use reiserfs_truncate_file to pack the tail, since it already has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * all the conditions coded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) static int reiserfs_file_release(struct inode *inode, struct file *filp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct reiserfs_transaction_handle th;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) int jbegin_failure = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) BUG_ON(!S_ISREG(inode->i_mode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) if (!atomic_dec_and_mutex_lock(&REISERFS_I(inode)->openers,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) &REISERFS_I(inode)->tailpack))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /* fast out for when nothing needs to be done */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) if ((!(REISERFS_I(inode)->i_flags & i_pack_on_close_mask) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) !tail_has_to_be_packed(inode)) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) REISERFS_I(inode)->i_prealloc_count <= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) mutex_unlock(&REISERFS_I(inode)->tailpack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) reiserfs_write_lock(inode->i_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * freeing preallocation only involves relogging blocks that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * are already in the current transaction. preallocation gets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * freed at the end of each transaction, so it is impossible for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * us to log any additional blocks (including quota blocks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) err = journal_begin(&th, inode->i_sb, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * uh oh, we can't allow the inode to go away while there
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * is still preallocation blocks pending. Try to join the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * aborted transaction
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) jbegin_failure = err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) err = journal_join_abort(&th, inode->i_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * hmpf, our choices here aren't good. We can pin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * the inode which will disallow unmount from ever
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * happening, we can do nothing, which will corrupt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * random memory on unmount, or we can forcibly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * remove the file from the preallocation list, which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * will leak blocks on disk. Lets pin the inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * and let the admin know what is going on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) igrab(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) reiserfs_warning(inode->i_sb, "clm-9001",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) "pinning inode %lu because the "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) "preallocation can't be freed",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) inode->i_ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) reiserfs_update_inode_transaction(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #ifdef REISERFS_PREALLOCATE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) reiserfs_discard_prealloc(&th, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) err = journal_end(&th);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /* copy back the error code from journal_begin */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) if (!err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) err = jbegin_failure;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) if (!err &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) (REISERFS_I(inode)->i_flags & i_pack_on_close_mask) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) tail_has_to_be_packed(inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * if regular file is released by last holder and it has been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * appended (we append by unformatted node only) or its direct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * item(s) had to be converted, then it may have to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * indirect2direct converted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) err = reiserfs_truncate_file(inode, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) reiserfs_write_unlock(inode->i_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) mutex_unlock(&REISERFS_I(inode)->tailpack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) static int reiserfs_file_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) int err = dquot_file_open(inode, file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /* somebody might be tailpacking on final close; wait for it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) if (!atomic_inc_not_zero(&REISERFS_I(inode)->openers)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) mutex_lock(&REISERFS_I(inode)->tailpack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) atomic_inc(&REISERFS_I(inode)->openers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) mutex_unlock(&REISERFS_I(inode)->tailpack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) void reiserfs_vfs_truncate_file(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) mutex_lock(&REISERFS_I(inode)->tailpack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) reiserfs_truncate_file(inode, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) mutex_unlock(&REISERFS_I(inode)->tailpack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) /* Sync a reiserfs file. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * FIXME: sync_mapping_buffers() never has anything to sync. Can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * be removed...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static int reiserfs_sync_file(struct file *filp, loff_t start, loff_t end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) int datasync)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct inode *inode = filp->f_mapping->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) int barrier_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) err = file_write_and_wait_range(filp, start, end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) inode_lock(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) BUG_ON(!S_ISREG(inode->i_mode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) err = sync_mapping_buffers(inode->i_mapping);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) reiserfs_write_lock(inode->i_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) barrier_done = reiserfs_commit_for_inode(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) reiserfs_write_unlock(inode->i_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) if (barrier_done != 1 && reiserfs_barrier_flush(inode->i_sb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) inode_unlock(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) if (barrier_done < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) return barrier_done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) return (err < 0) ? -EIO : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /* taken fs/buffer.c:__block_commit_write */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) int reiserfs_commit_page(struct inode *inode, struct page *page,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) unsigned from, unsigned to)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) unsigned block_start, block_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) int partial = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) unsigned blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) struct buffer_head *bh, *head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) unsigned long i_size_index = inode->i_size >> PAGE_SHIFT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) int new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) int logit = reiserfs_file_data_log(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) struct super_block *s = inode->i_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) int bh_per_page = PAGE_SIZE / s->s_blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) struct reiserfs_transaction_handle th;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) th.t_trans_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) blocksize = i_blocksize(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) if (logit) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) reiserfs_write_lock(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) ret = journal_begin(&th, s, bh_per_page + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) goto drop_write_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) reiserfs_update_inode_transaction(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) for (bh = head = page_buffers(page), block_start = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) bh != head || !block_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) block_start = block_end, bh = bh->b_this_page) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) new = buffer_new(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) clear_buffer_new(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) block_end = block_start + blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if (block_end <= from || block_start >= to) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) if (!buffer_uptodate(bh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) partial = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) set_buffer_uptodate(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (logit) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) reiserfs_prepare_for_journal(s, bh, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) journal_mark_dirty(&th, bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) } else if (!buffer_dirty(bh)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) mark_buffer_dirty(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) * do data=ordered on any page past the end
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * of file and any buffer marked BH_New.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) if (reiserfs_data_ordered(inode->i_sb) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) (new || page->index >= i_size_index)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) reiserfs_add_ordered_list(inode, bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) if (logit) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) ret = journal_end(&th);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) drop_write_lock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) reiserfs_write_unlock(s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) * If this is a partial write which happened to make all buffers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * uptodate then we can optimize away a bogus readpage() for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * the next read(). Here we 'discover' whether the page went
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * uptodate as a result of this (potentially partial) write.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) if (!partial)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) SetPageUptodate(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) const struct file_operations reiserfs_file_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) .unlocked_ioctl = reiserfs_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) .compat_ioctl = reiserfs_compat_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) .mmap = generic_file_mmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) .open = reiserfs_file_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) .release = reiserfs_file_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) .fsync = reiserfs_sync_file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) .read_iter = generic_file_read_iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) .write_iter = generic_file_write_iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) .splice_read = generic_file_splice_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) .splice_write = iter_file_splice_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) .llseek = generic_file_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) const struct inode_operations reiserfs_file_inode_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) .setattr = reiserfs_setattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) .listxattr = reiserfs_listxattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) .permission = reiserfs_permission,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) .get_acl = reiserfs_get_acl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) .set_acl = reiserfs_set_acl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) };