Commit 2a79f17e4a641a2f463cb512cb0ec349844a147b

Authored by Al Viro
1 parent 8c9379e972

vfs: mnt_drop_write_file()

new helper (wrapper around mnt_drop_write()) to be used in pair with
mnt_want_write_file().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 22 changed files with 55 additions and 48 deletions Side-by-side Diff

... ... @@ -259,7 +259,7 @@
259 259  
260 260 btrfs_end_transaction(trans, root);
261 261  
262   - mnt_drop_write(file->f_path.mnt);
  262 + mnt_drop_write_file(file);
263 263  
264 264 ret = 0;
265 265 out_unlock:
... ... @@ -1971,7 +1971,7 @@
1971 1971 dput(dentry);
1972 1972 out_unlock_dir:
1973 1973 mutex_unlock(&dir->i_mutex);
1974   - mnt_drop_write(file->f_path.mnt);
  1974 + mnt_drop_write_file(file);
1975 1975 out:
1976 1976 kfree(vol_args);
1977 1977 return err;
... ... @@ -2040,7 +2040,7 @@
2040 2040 ret = -EINVAL;
2041 2041 }
2042 2042 out:
2043   - mnt_drop_write(file->f_path.mnt);
  2043 + mnt_drop_write_file(file);
2044 2044 return ret;
2045 2045 }
2046 2046  
... ... @@ -2510,7 +2510,7 @@
2510 2510 out_fput:
2511 2511 fput(src_file);
2512 2512 out_drop_write:
2513   - mnt_drop_write(file->f_path.mnt);
  2513 + mnt_drop_write_file(file);
2514 2514 return ret;
2515 2515 }
2516 2516  
... ... @@ -2565,7 +2565,7 @@
2565 2565  
2566 2566 out_drop:
2567 2567 atomic_dec(&root->fs_info->open_ioctl_trans);
2568   - mnt_drop_write(file->f_path.mnt);
  2568 + mnt_drop_write_file(file);
2569 2569 out:
2570 2570 return ret;
2571 2571 }
... ... @@ -2800,7 +2800,7 @@
2800 2800  
2801 2801 atomic_dec(&root->fs_info->open_ioctl_trans);
2802 2802  
2803   - mnt_drop_write(file->f_path.mnt);
  2803 + mnt_drop_write_file(file);
2804 2804 return 0;
2805 2805 }
2806 2806  
... ... @@ -83,7 +83,7 @@
83 83 inode->i_ctime = CURRENT_TIME_SEC;
84 84 mark_inode_dirty(inode);
85 85 setflags_out:
86   - mnt_drop_write(filp->f_path.mnt);
  86 + mnt_drop_write_file(filp);
87 87 return ret;
88 88 }
89 89 case EXT2_IOC_GETVERSION:
... ... @@ -100,7 +100,7 @@
100 100 inode->i_ctime = CURRENT_TIME_SEC;
101 101 mark_inode_dirty(inode);
102 102 }
103   - mnt_drop_write(filp->f_path.mnt);
  103 + mnt_drop_write_file(filp);
104 104 return ret;
105 105 case EXT2_IOC_GETRSVSZ:
106 106 if (test_opt(inode->i_sb, RESERVATION)
... ... @@ -145,7 +145,7 @@
145 145 rsv->rsv_goal_size = rsv_window_size;
146 146 }
147 147 mutex_unlock(&ei->truncate_mutex);
148   - mnt_drop_write(filp->f_path.mnt);
  148 + mnt_drop_write_file(filp);
149 149 return 0;
150 150 }
151 151 default:
... ... @@ -110,7 +110,7 @@
110 110 err = ext3_change_inode_journal_flag(inode, jflag);
111 111 flags_out:
112 112 mutex_unlock(&inode->i_mutex);
113   - mnt_drop_write(filp->f_path.mnt);
  113 + mnt_drop_write_file(filp);
114 114 return err;
115 115 }
116 116 case EXT3_IOC_GETVERSION:
... ... @@ -147,7 +147,7 @@
147 147 }
148 148 ext3_journal_stop(handle);
149 149 setversion_out:
150   - mnt_drop_write(filp->f_path.mnt);
  150 + mnt_drop_write_file(filp);
151 151 return err;
152 152 }
153 153 case EXT3_IOC_GETRSVSZ:
... ... @@ -195,7 +195,7 @@
195 195 }
196 196 mutex_unlock(&ei->truncate_mutex);
197 197 setrsvsz_out:
198   - mnt_drop_write(filp->f_path.mnt);
  198 + mnt_drop_write_file(filp);
199 199 return err;
200 200 }
201 201 case EXT3_IOC_GROUP_EXTEND: {
... ... @@ -221,7 +221,7 @@
221 221 if (err == 0)
222 222 err = err2;
223 223 group_extend_out:
224   - mnt_drop_write(filp->f_path.mnt);
  224 + mnt_drop_write_file(filp);
225 225 return err;
226 226 }
227 227 case EXT3_IOC_GROUP_ADD: {
... ... @@ -249,7 +249,7 @@
249 249 if (err == 0)
250 250 err = err2;
251 251 group_add_out:
252   - mnt_drop_write(filp->f_path.mnt);
  252 + mnt_drop_write_file(filp);
253 253 return err;
254 254 }
255 255 case FITRIM: {
... ... @@ -134,7 +134,7 @@
134 134 err = ext4_ext_migrate(inode);
135 135 flags_out:
136 136 mutex_unlock(&inode->i_mutex);
137   - mnt_drop_write(filp->f_path.mnt);
  137 + mnt_drop_write_file(filp);
138 138 return err;
139 139 }
140 140 case EXT4_IOC_GETVERSION:
... ... @@ -171,7 +171,7 @@
171 171 }
172 172 ext4_journal_stop(handle);
173 173 setversion_out:
174   - mnt_drop_write(filp->f_path.mnt);
  174 + mnt_drop_write_file(filp);
175 175 return err;
176 176 }
177 177 case EXT4_IOC_GROUP_EXTEND: {
... ... @@ -204,7 +204,7 @@
204 204 }
205 205 if (err == 0)
206 206 err = err2;
207   - mnt_drop_write(filp->f_path.mnt);
  207 + mnt_drop_write_file(filp);
208 208 ext4_resize_end(sb);
209 209  
210 210 return err;
... ... @@ -246,7 +246,7 @@
246 246  
247 247 err = ext4_move_extents(filp, donor_filp, me.orig_start,
248 248 me.donor_start, me.len, &me.moved_len);
249   - mnt_drop_write(filp->f_path.mnt);
  249 + mnt_drop_write_file(filp);
250 250 if (me.moved_len > 0)
251 251 file_remove_suid(donor_filp);
252 252  
... ... @@ -289,7 +289,7 @@
289 289 }
290 290 if (err == 0)
291 291 err = err2;
292   - mnt_drop_write(filp->f_path.mnt);
  292 + mnt_drop_write_file(filp);
293 293 ext4_resize_end(sb);
294 294  
295 295 return err;
... ... @@ -313,7 +313,7 @@
313 313 mutex_lock(&(inode->i_mutex));
314 314 err = ext4_ext_migrate(inode);
315 315 mutex_unlock(&(inode->i_mutex));
316   - mnt_drop_write(filp->f_path.mnt);
  316 + mnt_drop_write_file(filp);
317 317 return err;
318 318 }
319 319  
... ... @@ -327,7 +327,7 @@
327 327 if (err)
328 328 return err;
329 329 err = ext4_alloc_da_blocks(inode);
330   - mnt_drop_write(filp->f_path.mnt);
  330 + mnt_drop_write_file(filp);
331 331 return err;
332 332 }
333 333  
... ... @@ -108,7 +108,7 @@
108 108 fat_save_attrs(inode, attr);
109 109 mark_inode_dirty(inode);
110 110 out_drop_write:
111   - mnt_drop_write(file->f_path.mnt);
  111 + mnt_drop_write_file(file);
112 112 out_unlock_inode:
113 113 mutex_unlock(&inode->i_mutex);
114 114 out:
... ... @@ -285,7 +285,7 @@
285 285 out:
286 286 gfs2_glock_dq_uninit(&gh);
287 287 out_drop_write:
288   - mnt_drop_write(filp->f_path.mnt);
  288 + mnt_drop_write_file(filp);
289 289 return error;
290 290 }
291 291  
... ... @@ -94,7 +94,7 @@
94 94 out_unlock_inode:
95 95 mutex_unlock(&inode->i_mutex);
96 96 out_drop_write:
97   - mnt_drop_write(file->f_path.mnt);
  97 + mnt_drop_write_file(file);
98 98 out:
99 99 return err;
100 100 }
... ... @@ -1508,7 +1508,7 @@
1508 1508 if (sync_it & S_MTIME)
1509 1509 inode->i_mtime = now;
1510 1510 mark_inode_dirty_sync(inode);
1511   - mnt_drop_write(file->f_path.mnt);
  1511 + mnt_drop_write_file(file);
1512 1512 }
1513 1513 EXPORT_SYMBOL(file_update_time);
1514 1514  
... ... @@ -120,7 +120,7 @@
120 120 inode->i_ctime = CURRENT_TIME_SEC;
121 121 mark_inode_dirty(inode);
122 122 setflags_out:
123   - mnt_drop_write(filp->f_path.mnt);
  123 + mnt_drop_write_file(filp);
124 124 return err;
125 125 }
126 126 default:
... ... @@ -392,6 +392,12 @@
392 392 }
393 393 EXPORT_SYMBOL_GPL(mnt_drop_write);
394 394  
  395 +void mnt_drop_write_file(struct file *file)
  396 +{
  397 + mnt_drop_write(file->f_path.mnt);
  398 +}
  399 +EXPORT_SYMBOL(mnt_drop_write_file);
  400 +
395 401 static int mnt_make_readonly(struct vfsmount *mnt)
396 402 {
397 403 int ret = 0;
... ... @@ -901,7 +901,7 @@
901 901 ret = __ncp_ioctl(inode, cmd, arg);
902 902 outDropWrite:
903 903 if (need_drop_write)
904   - mnt_drop_write(filp->f_path.mnt);
  904 + mnt_drop_write_file(filp);
905 905 out:
906 906 return ret;
907 907 }
fs/nfsd/nfs4recover.c
... ... @@ -151,7 +151,7 @@
151 151 if (status)
152 152 goto out_put;
153 153 status = vfs_mkdir(dir->d_inode, dentry, S_IRWXU);
154   - mnt_drop_write(rec_file->f_path.mnt);
  154 + mnt_drop_write_file(rec_file);
155 155 out_put:
156 156 dput(dentry);
157 157 out_unlock:
... ... @@ -281,7 +281,7 @@
281 281 nfs4_reset_creds(original_cred);
282 282 if (status == 0)
283 283 vfs_fsync(rec_file, 0);
284   - mnt_drop_write(rec_file->f_path.mnt);
  284 + mnt_drop_write_file(rec_file);
285 285 out:
286 286 if (status)
287 287 printk("NFSD: Failed to remove expired client state directory"
... ... @@ -317,7 +317,7 @@
317 317 status = nfsd4_list_rec_dir(purge_old);
318 318 if (status == 0)
319 319 vfs_fsync(rec_file, 0);
320   - mnt_drop_write(rec_file->f_path.mnt);
  320 + mnt_drop_write_file(rec_file);
321 321 out:
322 322 if (status)
323 323 printk("nfsd4: failed to purge old clients from recovery"
... ... @@ -27,7 +27,7 @@
27 27 #include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */
28 28 #include <linux/vmalloc.h>
29 29 #include <linux/compat.h> /* compat_ptr() */
30   -#include <linux/mount.h> /* mnt_want_write_file(), mnt_drop_write() */
  30 +#include <linux/mount.h> /* mnt_want_write_file(), mnt_drop_write_file() */
31 31 #include <linux/buffer_head.h>
32 32 #include <linux/nilfs2_fs.h>
33 33 #include "nilfs.h"
... ... @@ -154,7 +154,7 @@
154 154 ret = nilfs_transaction_commit(inode->i_sb);
155 155 out:
156 156 mutex_unlock(&inode->i_mutex);
157   - mnt_drop_write(filp->f_path.mnt);
  157 + mnt_drop_write_file(filp);
158 158 return ret;
159 159 }
160 160  
... ... @@ -194,7 +194,7 @@
194 194  
195 195 up_read(&inode->i_sb->s_umount);
196 196 out:
197   - mnt_drop_write(filp->f_path.mnt);
  197 + mnt_drop_write_file(filp);
198 198 return ret;
199 199 }
200 200  
... ... @@ -225,7 +225,7 @@
225 225 else
226 226 nilfs_transaction_commit(inode->i_sb); /* never fails */
227 227 out:
228   - mnt_drop_write(filp->f_path.mnt);
  228 + mnt_drop_write_file(filp);
229 229 return ret;
230 230 }
231 231  
... ... @@ -675,7 +675,7 @@
675 675 vfree(kbufs[n]);
676 676 kfree(kbufs[4]);
677 677 out:
678   - mnt_drop_write(filp->f_path.mnt);
  678 + mnt_drop_write_file(filp);
679 679 return ret;
680 680 }
681 681  
... ... @@ -721,7 +721,7 @@
721 721 ret = nilfs_resize_fs(inode->i_sb, newsize);
722 722  
723 723 out_drop_write:
724   - mnt_drop_write(filp->f_path.mnt);
  724 + mnt_drop_write_file(filp);
725 725 out:
726 726 return ret;
727 727 }
... ... @@ -911,7 +911,7 @@
911 911 return status;
912 912 status = ocfs2_set_inode_attr(inode, flags,
913 913 OCFS2_FL_MODIFIABLE);
914   - mnt_drop_write(filp->f_path.mnt);
  914 + mnt_drop_write_file(filp);
915 915 return status;
916 916 case OCFS2_IOC_RESVSP:
917 917 case OCFS2_IOC_RESVSP64:
fs/ocfs2/move_extents.c
... ... @@ -1145,7 +1145,7 @@
1145 1145  
1146 1146 kfree(context);
1147 1147  
1148   - mnt_drop_write(filp->f_path.mnt);
  1148 + mnt_drop_write_file(filp);
1149 1149  
1150 1150 return status;
1151 1151 }
... ... @@ -608,7 +608,7 @@
608 608 dentry = file->f_path.dentry;
609 609 audit_inode(NULL, dentry);
610 610 error = chown_common(&file->f_path, user, group);
611   - mnt_drop_write(file->f_path.mnt);
  611 + mnt_drop_write_file(file);
612 612 out_fput:
613 613 fput(file);
614 614 out:
... ... @@ -96,7 +96,7 @@
96 96 inode->i_ctime = CURRENT_TIME_SEC;
97 97 mark_inode_dirty(inode);
98 98 setflags_out:
99   - mnt_drop_write(filp->f_path.mnt);
  99 + mnt_drop_write_file(filp);
100 100 break;
101 101 }
102 102 case REISERFS_IOC_GETVERSION:
... ... @@ -117,7 +117,7 @@
117 117 inode->i_ctime = CURRENT_TIME_SEC;
118 118 mark_inode_dirty(inode);
119 119 setversion_out:
120   - mnt_drop_write(filp->f_path.mnt);
  120 + mnt_drop_write_file(filp);
121 121 break;
122 122 default:
123 123 err = -ENOTTY;
... ... @@ -178,7 +178,7 @@
178 178 return err;
179 179 dbg_gen("set flags: %#x, i_flags %#x", flags, inode->i_flags);
180 180 err = setflags(inode, flags);
181   - mnt_drop_write(file->f_path.mnt);
  181 + mnt_drop_write_file(file);
182 182 return err;
183 183 }
184 184  
... ... @@ -397,7 +397,7 @@
397 397 error = mnt_want_write_file(f);
398 398 if (!error) {
399 399 error = setxattr(dentry, name, value, size, flags);
400   - mnt_drop_write(f->f_path.mnt);
  400 + mnt_drop_write_file(f);
401 401 }
402 402 fput(f);
403 403 return error;
... ... @@ -624,7 +624,7 @@
624 624 error = mnt_want_write_file(f);
625 625 if (!error) {
626 626 error = removexattr(dentry, name);
627   - mnt_drop_write(f->f_path.mnt);
  627 + mnt_drop_write_file(f);
628 628 }
629 629 fput(f);
630 630 return error;
... ... @@ -566,7 +566,7 @@
566 566 dentry->d_inode, attr_name,
567 567 ops[i].am_attrvalue, ops[i].am_length,
568 568 ops[i].am_flags);
569   - mnt_drop_write(parfilp->f_path.mnt);
  569 + mnt_drop_write_file(parfilp);
570 570 break;
571 571 case ATTR_OP_REMOVE:
572 572 ops[i].am_error = mnt_want_write_file(parfilp);
... ... @@ -575,7 +575,7 @@
575 575 ops[i].am_error = xfs_attrmulti_attr_remove(
576 576 dentry->d_inode, attr_name,
577 577 ops[i].am_flags);
578   - mnt_drop_write(parfilp->f_path.mnt);
  578 + mnt_drop_write_file(parfilp);
579 579 break;
580 580 default:
581 581 ops[i].am_error = EINVAL;
fs/xfs/xfs_ioctl32.c
... ... @@ -461,7 +461,7 @@
461 461 dentry->d_inode, attr_name,
462 462 compat_ptr(ops[i].am_attrvalue),
463 463 ops[i].am_length, ops[i].am_flags);
464   - mnt_drop_write(parfilp->f_path.mnt);
  464 + mnt_drop_write_file(parfilp);
465 465 break;
466 466 case ATTR_OP_REMOVE:
467 467 ops[i].am_error = mnt_want_write_file(parfilp);
... ... @@ -470,7 +470,7 @@
470 470 ops[i].am_error = xfs_attrmulti_attr_remove(
471 471 dentry->d_inode, attr_name,
472 472 ops[i].am_flags);
473   - mnt_drop_write(parfilp->f_path.mnt);
  473 + mnt_drop_write_file(parfilp);
474 474 break;
475 475 default:
476 476 ops[i].am_error = EINVAL;
include/linux/mount.h
... ... @@ -94,6 +94,7 @@
94 94 extern int mnt_want_write_file(struct file *file);
95 95 extern int mnt_clone_write(struct vfsmount *mnt);
96 96 extern void mnt_drop_write(struct vfsmount *mnt);
  97 +extern void mnt_drop_write_file(struct file *file);
97 98 extern void mntput(struct vfsmount *mnt);
98 99 extern struct vfsmount *mntget(struct vfsmount *mnt);
99 100 extern void mnt_pin(struct vfsmount *mnt);