Pull more vfs updates from Al Viro: "In this pile: - autofs-namespace series - dedupe stuff - more struct path constification" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (40 commits) ocfs2: implement the VFS clone_range, copy_range, and dedupe_range features ocfs2: charge quota for reflinked blocks ocfs2: fix bad pointer cast ocfs2: always unlock when completing dio writes ocfs2: don't eat io errors during _dio_end_io_write ocfs2: budget for extent tree splits when adding refcount flag ocfs2: prohibit refcounted swapfiles ocfs2: add newlines to some error messages ocfs2: convert inode refcount test to a helper simple_write_end(): don't zero in short copy into uptodate exofs: don't mess with simple_write_{begin,end} 9p: saner ->write_end() on failing copy into non-uptodate page fix gfs2_stuffed_write_end() on short copies fix ceph_write_end() nfs_write_end(): fix handling of short copies vfs: refactor clone/dedupe_file_range common functions fs: try to clone files first in vfs_copy_file_range vfs: misc struct path constification namespace.c: constify struct path passed to a bunch of primitives quota: constify struct path in quota_on ...
Unified · Split
| @@ -20,7 +20,7 @@ prototypes: · 19 unmodified lines | |||
| 20 | void (*d_iput)(struct dentry *, struct inode *); | 20 | void (*d_iput)(struct dentry *, struct inode *); |
| 21 | char *(*d_dname)((struct dentry *dentry, char *buffer, int buflen); | 21 | char *(*d_dname)((struct dentry *dentry, char *buffer, int buflen); |
| 22 | struct vfsmount *(*d_automount)(struct path *path); | 22 | struct vfsmount *(*d_automount)(struct path *path); |
| 23 | int (*d_manage)(struct dentry *, bool); | 23 | int (*d_manage)(const struct path *, bool); |
| 24 | struct dentry *(*d_real)(struct dentry *, const struct inode *, | 24 | struct dentry *(*d_real)(struct dentry *, const struct inode *, |
| 25 | unsigned int); | 25 | unsigned int); |
| 26 | 26 | ||
| @@ -948,7 +948,7 @@ struct dentry_operations { · 947 unmodified lines | |||
| 948 | void (*d_iput)(struct dentry *, struct inode *); | 948 | void (*d_iput)(struct dentry *, struct inode *); |
| 949 | char *(*d_dname)(struct dentry *, char *, int); | 949 | char *(*d_dname)(struct dentry *, char *, int); |
| 950 | struct vfsmount *(*d_automount)(struct path *); | 950 | struct vfsmount *(*d_automount)(struct path *); |
| 951 | int (*d_manage)(struct dentry *, bool); | 951 | int (*d_manage)(const struct path *, bool); |
| 952 | struct dentry *(*d_real)(struct dentry *, const struct inode *, | 952 | struct dentry *(*d_real)(struct dentry *, const struct inode *, |
| 953 | unsigned int); | 953 | unsigned int); |
| 954 | }; | 954 | }; |
| @@ -295,7 +295,7 @@ out: · 294 unmodified lines | |||
| 295 | * dcookie user still being registered (namely, the reader | 295 | * dcookie user still being registered (namely, the reader |
| 296 | * of the event buffer). | 296 | * of the event buffer). |
| 297 | */ | 297 | */ |
| 298 | static inline unsigned long fast_get_dcookie(struct path *path) | 298 | static inline unsigned long fast_get_dcookie(const struct path *path) |
| 299 | { | 299 | { |
| 300 | unsigned long cookie; | 300 | unsigned long cookie; |
| 301 | 301 | ||
| @@ -206,7 +206,7 @@ void sync_stop(void) · 205 unmodified lines | |||
| 206 | * because we cannot reach this code without at least one | 206 | * because we cannot reach this code without at least one |
| 207 | * dcookie user still being registered (namely, the reader | 207 | * dcookie user still being registered (namely, the reader |
| 208 | * of the event buffer). */ | 208 | * of the event buffer). */ |
| 209 | static inline unsigned long fast_get_dcookie(struct path *path) | 209 | static inline unsigned long fast_get_dcookie(const struct path *path) |
| 210 | { | 210 | { |
| 211 | unsigned long cookie; | 211 | unsigned long cookie; |
| 212 | 212 | ||
| @@ -310,18 +310,10 @@ static int v9fs_write_end(struct file *filp, struct address_space *mapping, · 309 unmodified lines | |||
| 310 | 310 | ||
| 311 | p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping); | 311 | p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping); |
| 312 | 312 | ||
| 313 | if (unlikely(copied < len)) { | 313 | if (unlikely(copied < len && !PageUptodate(page))) { |
| 314 | /* | 314 | copied = 0; |
| 315 | * zero out the rest of the area | 315 | goto out; |
| 316 | */ | ||
| 317 | unsigned from = pos & (PAGE_SIZE - 1); | ||
| 318 | |||
| 319 | zero_user(page, from + copied, len - copied); | ||
| 320 | flush_dcache_page(page); | ||
| 321 | } | 316 | } |
| 322 | |||
| 323 | if (!PageUptodate(page)) | ||
| 324 | SetPageUptodate(page); | ||
| 325 | /* | 317 | /* |
| 326 | * No need to use i_size_read() here, the i_size | 318 | * No need to use i_size_read() here, the i_size |
| 327 | * cannot change under us because we hold the i_mutex. | 319 | * cannot change under us because we hold the i_mutex. |
| @@ -331,6 +323,7 @@ static int v9fs_write_end(struct file *filp, struct address_space *mapping, · 3 unmodified lines | |||
| 331 | i_size_write(inode, last_pos); | 323 | i_size_write(inode, last_pos); |
| 332 | } | 324 | } |
| 333 | set_page_dirty(page); | 325 | set_page_dirty(page); |
| 326 | out: | ||
| 334 | unlock_page(page); | 327 | unlock_page(page); |
| 335 | put_page(page); | 328 | put_page(page); |
| 336 | 329 | ||
| @@ -145,7 +145,7 @@ void autofs4_free_ino(struct autofs_info *); · 144 unmodified lines | |||
| 145 | 145 | ||
| 146 | /* Expiration */ | 146 | /* Expiration */ |
| 147 | int is_autofs4_dentry(struct dentry *); | 147 | int is_autofs4_dentry(struct dentry *); |
| 148 | int autofs4_expire_wait(struct dentry *dentry, int rcu_walk); | 148 | int autofs4_expire_wait(const struct path *path, int rcu_walk); |
| 149 | int autofs4_expire_run(struct super_block *, struct vfsmount *, | 149 | int autofs4_expire_run(struct super_block *, struct vfsmount *, |
| 150 | struct autofs_sb_info *, | 150 | struct autofs_sb_info *, |
| 151 | struct autofs_packet_expire __user *); | 151 | struct autofs_packet_expire __user *); |
| @@ -217,7 +217,8 @@ static inline int autofs_prepare_pipe(struct file *pipe) · 65 unmodified lines | |||
| 217 | 217 | ||
| 218 | /* Queue management functions */ | 218 | /* Queue management functions */ |
| 219 | 219 | ||
| 220 | int autofs4_wait(struct autofs_sb_info *, struct dentry *, enum autofs_notify); | 220 | int autofs4_wait(struct autofs_sb_info *, |
| 221 | const struct path *, enum autofs_notify); | ||
| 221 | int autofs4_wait_release(struct autofs_sb_info *, autofs_wqt_t, int); | 222 | int autofs4_wait_release(struct autofs_sb_info *, autofs_wqt_t, int); |
| 222 | void autofs4_catatonic_mode(struct autofs_sb_info *); | 223 | void autofs4_catatonic_mode(struct autofs_sb_info *); |
| 223 | 224 | ||
| @@ -204,7 +204,7 @@ static int autofs_dev_ioctl_protosubver(struct file *fp, · 203 unmodified lines | |||
| 204 | /* Find the topmost mount satisfying test() */ | 204 | /* Find the topmost mount satisfying test() */ |
| 205 | static int find_autofs_mount(const char *pathname, | 205 | static int find_autofs_mount(const char *pathname, |
| 206 | struct path *res, | 206 | struct path *res, |
| 207 | int test(struct path *path, void *data), | 207 | int test(const struct path *path, void *data), |
| 208 | void *data) | 208 | void *data) |
| 209 | { | 209 | { |
| 210 | struct path path; | 210 | struct path path; |
| @@ -230,12 +230,12 @@ static int find_autofs_mount(const char *pathname, · 19 unmodified lines | |||
| 230 | return err; | 230 | return err; |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | static int test_by_dev(struct path *path, void *p) | 233 | static int test_by_dev(const struct path *path, void *p) |
| 234 | { | 234 | { |
| 235 | return path->dentry->d_sb->s_dev == *(dev_t *)p; | 235 | return path->dentry->d_sb->s_dev == *(dev_t *)p; |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | static int test_by_type(struct path *path, void *p) | 238 | static int test_by_type(const struct path *path, void *p) |
| 239 | { | 239 | { |
| 240 | struct autofs_info *ino = autofs4_dentry_ino(path->dentry); | 240 | struct autofs_info *ino = autofs4_dentry_ino(path->dentry); |
| 241 | 241 | ||
| @@ -468,7 +468,7 @@ static int autofs_dev_ioctl_requester(struct file *fp, · 226 unmodified lines | |||
| 468 | ino = autofs4_dentry_ino(path.dentry); | 468 | ino = autofs4_dentry_ino(path.dentry); |
| 469 | if (ino) { | 469 | if (ino) { |
| 470 | err = 0; | 470 | err = 0; |
| 471 | autofs4_expire_wait(path.dentry, 0); | 471 | autofs4_expire_wait(&path, 0); |
| 472 | spin_lock(&sbi->fs_lock); | 472 | spin_lock(&sbi->fs_lock); |
| 473 | param->requester.uid = | 473 | param->requester.uid = |
| 474 | from_kuid_munged(current_user_ns(), ino->uid); | 474 | from_kuid_munged(current_user_ns(), ino->uid); |
| @@ -575,7 +575,7 @@ static int autofs_dev_ioctl_ismountpoint(struct file *fp, · 100 unmodified lines | |||
| 575 | 575 | ||
| 576 | devid = new_encode_dev(dev); | 576 | devid = new_encode_dev(dev); |
| 577 | 577 | ||
| 578 | err = have_submounts(path.dentry); | 578 | err = path_has_submounts(&path); |
| 579 | 579 | ||
| 580 | if (follow_down_one(&path)) | 580 | if (follow_down_one(&path)) |
| 581 | magic = path.dentry->d_sb->s_magic; | 581 | magic = path.dentry->d_sb->s_magic; |
| @@ -310,26 +310,29 @@ struct dentry *autofs4_expire_direct(struct super_block *sb, · 309 unmodified lines | |||
| 310 | now = jiffies; | 310 | now = jiffies; |
| 311 | timeout = sbi->exp_timeout; | 311 | timeout = sbi->exp_timeout; |
| 312 | 312 | ||
| 313 | spin_lock(&sbi->fs_lock); | ||
| 314 | ino = autofs4_dentry_ino(root); | ||
| 315 | /* No point expiring a pending mount */ | ||
| 316 | if (ino->flags & AUTOFS_INF_PENDING) | ||
| 317 | goto out; | ||
| 318 | if (!autofs4_direct_busy(mnt, root, timeout, do_now)) { | 313 | if (!autofs4_direct_busy(mnt, root, timeout, do_now)) { |
| 314 | spin_lock(&sbi->fs_lock); | ||
| 315 | ino = autofs4_dentry_ino(root); | ||
| 316 | /* No point expiring a pending mount */ | ||
| 317 | if (ino->flags & AUTOFS_INF_PENDING) { | ||
| 318 | spin_unlock(&sbi->fs_lock); | ||
| 319 | goto out; | ||
| 320 | } | ||
| 319 | ino->flags |= AUTOFS_INF_WANT_EXPIRE; | 321 | ino->flags |= AUTOFS_INF_WANT_EXPIRE; |
| 320 | spin_unlock(&sbi->fs_lock); | 322 | spin_unlock(&sbi->fs_lock); |
| 321 | synchronize_rcu(); | 323 | synchronize_rcu(); |
| 322 | spin_lock(&sbi->fs_lock); | ||
| 323 | if (!autofs4_direct_busy(mnt, root, timeout, do_now)) { | 324 | if (!autofs4_direct_busy(mnt, root, timeout, do_now)) { |
| 325 | spin_lock(&sbi->fs_lock); | ||
| 324 | ino->flags |= AUTOFS_INF_EXPIRING; | 326 | ino->flags |= AUTOFS_INF_EXPIRING; |
| 325 | init_completion(&ino->expire_complete); | 327 | init_completion(&ino->expire_complete); |
| 326 | spin_unlock(&sbi->fs_lock); | 328 | spin_unlock(&sbi->fs_lock); |
| 327 | return root; | 329 | return root; |
| 328 | } | 330 | } |
| 331 | spin_lock(&sbi->fs_lock); | ||
| 329 | ino->flags &= ~AUTOFS_INF_WANT_EXPIRE; | 332 | ino->flags &= ~AUTOFS_INF_WANT_EXPIRE; |
| 333 | spin_unlock(&sbi->fs_lock); | ||
| 330 | } | 334 | } |
| 331 | out: | 335 | out: |
| 332 | spin_unlock(&sbi->fs_lock); | ||
| 333 | dput(root); | 336 | dput(root); |
| 334 | 337 | ||
| 335 | return NULL; | 338 | return NULL; |
| @@ -495,8 +498,9 @@ found: · 159 unmodified lines | |||
| 495 | return expired; | 498 | return expired; |
| 496 | } | 499 | } |
| 497 | 500 | ||
| 498 | int autofs4_expire_wait(struct dentry *dentry, int rcu_walk) | 501 | int autofs4_expire_wait(const struct path *path, int rcu_walk) |
| 499 | { | 502 | { |
| 503 | struct dentry *dentry = path->dentry; | ||
| 500 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | 504 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); |
| 501 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | 505 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
| 502 | int status; | 506 | int status; |
| @@ -525,7 +529,7 @@ retry: · 22 unmodified lines | |||
| 525 | 529 | ||
| 526 | pr_debug("waiting for expire %p name=%pd\n", dentry, dentry); | 530 | pr_debug("waiting for expire %p name=%pd\n", dentry, dentry); |
| 527 | 531 | ||
| 528 | status = autofs4_wait(sbi, dentry, NFY_NONE); | 532 | status = autofs4_wait(sbi, path, NFY_NONE); |
| 529 | wait_for_completion(&ino->expire_complete); | 533 | wait_for_completion(&ino->expire_complete); |
| 530 | 534 | ||
| 531 | pr_debug("expire done status=%d\n", status); | 535 | pr_debug("expire done status=%d\n", status); |
| @@ -592,11 +596,12 @@ int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt, · 60 unmodified lines | |||
| 592 | 596 | ||
| 593 | if (dentry) { | 597 | if (dentry) { |
| 594 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | 598 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
| 599 | const struct path path = { .mnt = mnt, .dentry = dentry }; | ||
| 595 | 600 | ||
| 596 | /* This is synchronous because it makes the daemon a | 601 | /* This is synchronous because it makes the daemon a |
| 597 | * little easier | 602 | * little easier |
| 598 | */ | 603 | */ |
| 599 | ret = autofs4_wait(sbi, dentry, NFY_EXPIRE); | 604 | ret = autofs4_wait(sbi, &path, NFY_EXPIRE); |
| 600 | 605 | ||
| 601 | spin_lock(&sbi->fs_lock); | 606 | spin_lock(&sbi->fs_lock); |
| 602 | /* avoid rapid-fire expire attempts if expiry fails */ | 607 | /* avoid rapid-fire expire attempts if expiry fails */ |
| @@ -32,7 +32,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file); · 31 unmodified lines | |||
| 32 | static struct dentry *autofs4_lookup(struct inode *, | 32 | static struct dentry *autofs4_lookup(struct inode *, |
| 33 | struct dentry *, unsigned int); | 33 | struct dentry *, unsigned int); |
| 34 | static struct vfsmount *autofs4_d_automount(struct path *); | 34 | static struct vfsmount *autofs4_d_automount(struct path *); |
| 35 | static int autofs4_d_manage(struct dentry *, bool); | 35 | static int autofs4_d_manage(const struct path *, bool); |
| 36 | static void autofs4_dentry_release(struct dentry *); | 36 | static void autofs4_dentry_release(struct dentry *); |
| 37 | 37 | ||
| 38 | const struct file_operations autofs4_root_operations = { | 38 | const struct file_operations autofs4_root_operations = { |
| @@ -123,7 +123,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file) · 84 unmodified lines | |||
| 123 | * it. | 123 | * it. |
| 124 | */ | 124 | */ |
| 125 | spin_lock(&sbi->lookup_lock); | 125 | spin_lock(&sbi->lookup_lock); |
| 126 | if (!d_mountpoint(dentry) && simple_empty(dentry)) { | 126 | if (!path_is_mountpoint(&file->f_path) && simple_empty(dentry)) { |
| 127 | spin_unlock(&sbi->lookup_lock); | 127 | spin_unlock(&sbi->lookup_lock); |
| 128 | return -ENOENT; | 128 | return -ENOENT; |
| 129 | } | 129 | } |
| @@ -269,39 +269,41 @@ next: · 139 unmodified lines | |||
| 269 | return NULL; | 269 | return NULL; |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | static int autofs4_mount_wait(struct dentry *dentry, bool rcu_walk) | 272 | static int autofs4_mount_wait(const struct path *path, bool rcu_walk) |
| 273 | { | 273 | { |
| 274 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | 274 | struct autofs_sb_info *sbi = autofs4_sbi(path->dentry->d_sb); |
| 275 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | 275 | struct autofs_info *ino = autofs4_dentry_ino(path->dentry); |
| 276 | int status = 0; | 276 | int status = 0; |
| 277 | 277 | ||
| 278 | if (ino->flags & AUTOFS_INF_PENDING) { | 278 | if (ino->flags & AUTOFS_INF_PENDING) { |
| 279 | if (rcu_walk) | 279 | if (rcu_walk) |
| 280 | return -ECHILD; | 280 | return -ECHILD; |
| 281 | pr_debug("waiting for mount name=%pd\n", dentry); | 281 | pr_debug("waiting for mount name=%pd\n", path->dentry); |
| 282 | status = autofs4_wait(sbi, dentry, NFY_MOUNT); | 282 | status = autofs4_wait(sbi, path, NFY_MOUNT); |
| 283 | pr_debug("mount wait done status=%d\n", status); | 283 | pr_debug("mount wait done status=%d\n", status); |
| 284 | } | 284 | } |
| 285 | ino->last_used = jiffies; | 285 | ino->last_used = jiffies; |
| 286 | return status; | 286 | return status; |
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | static int do_expire_wait(struct dentry *dentry, bool rcu_walk) | 289 | static int do_expire_wait(const struct path *path, bool rcu_walk) |
| 290 | { | 290 | { |
| 291 | struct dentry *dentry = path->dentry; | ||
| 291 | struct dentry *expiring; | 292 | struct dentry *expiring; |
| 292 | 293 | ||
| 293 | expiring = autofs4_lookup_expiring(dentry, rcu_walk); | 294 | expiring = autofs4_lookup_expiring(dentry, rcu_walk); |
| 294 | if (IS_ERR(expiring)) | 295 | if (IS_ERR(expiring)) |
| 295 | return PTR_ERR(expiring); | 296 | return PTR_ERR(expiring); |
| 296 | if (!expiring) | 297 | if (!expiring) |
| 297 | return autofs4_expire_wait(dentry, rcu_walk); | 298 | return autofs4_expire_wait(path, rcu_walk); |
| 298 | else { | 299 | else { |
| 300 | const struct path this = { .mnt = path->mnt, .dentry = expiring }; | ||
| 299 | /* | 301 | /* |
| 300 | * If we are racing with expire the request might not | 302 | * If we are racing with expire the request might not |
| 301 | * be quite complete, but the directory has been removed | 303 | * be quite complete, but the directory has been removed |
| 302 | * so it must have been successful, just wait for it. | 304 | * so it must have been successful, just wait for it. |
| 303 | */ | 305 | */ |
| 304 | autofs4_expire_wait(expiring, 0); | 306 | autofs4_expire_wait(&this, 0); |
| 305 | autofs4_del_expiring(expiring); | 307 | autofs4_del_expiring(expiring); |
| 306 | dput(expiring); | 308 | dput(expiring); |
| 307 | } | 309 | } |
| @@ -354,7 +356,7 @@ static struct vfsmount *autofs4_d_automount(struct path *path) · 46 unmodified lines | |||
| 354 | * and the directory was removed, so just go ahead and try | 356 | * and the directory was removed, so just go ahead and try |
| 355 | * the mount. | 357 | * the mount. |
| 356 | */ | 358 | */ |
| 357 | status = do_expire_wait(dentry, 0); | 359 | status = do_expire_wait(path, 0); |
| 358 | if (status && status != -EAGAIN) | 360 | if (status && status != -EAGAIN) |
| 359 | return NULL; | 361 | return NULL; |
| 360 | 362 | ||
| @@ -362,7 +364,7 @@ static struct vfsmount *autofs4_d_automount(struct path *path) · 1 unmodified line | |||
| 362 | spin_lock(&sbi->fs_lock); | 364 | spin_lock(&sbi->fs_lock); |
| 363 | if (ino->flags & AUTOFS_INF_PENDING) { | 365 | if (ino->flags & AUTOFS_INF_PENDING) { |
| 364 | spin_unlock(&sbi->fs_lock); | 366 | spin_unlock(&sbi->fs_lock); |
| 365 | status = autofs4_mount_wait(dentry, 0); | 367 | status = autofs4_mount_wait(path, 0); |
| 366 | if (status) | 368 | if (status) |
| 367 | return ERR_PTR(status); | 369 | return ERR_PTR(status); |
| 368 | goto done; | 370 | goto done; |
| @@ -370,28 +372,28 @@ static struct vfsmount *autofs4_d_automount(struct path *path) · 1 unmodified line | |||
| 370 | 372 | ||
| 371 | /* | 373 | /* |
| 372 | * If the dentry is a symlink it's equivalent to a directory | 374 | * If the dentry is a symlink it's equivalent to a directory |
| 373 | * having d_mountpoint() true, so there's no need to call back | 375 | * having path_is_mountpoint() true, so there's no need to call |
| 374 | * to the daemon. | 376 | * back to the daemon. |
| 375 | */ | 377 | */ |
| 376 | if (d_really_is_positive(dentry) && d_is_symlink(dentry)) { | 378 | if (d_really_is_positive(dentry) && d_is_symlink(dentry)) { |
| 377 | spin_unlock(&sbi->fs_lock); | 379 | spin_unlock(&sbi->fs_lock); |
| 378 | goto done; | 380 | goto done; |
| 379 | } | 381 | } |
| 380 | 382 | ||
| 381 | if (!d_mountpoint(dentry)) { | 383 | if (!path_is_mountpoint(path)) { |
| 382 | /* | 384 | /* |
| 383 | * It's possible that user space hasn't removed directories | 385 | * It's possible that user space hasn't removed directories |
| 384 | * after umounting a rootless multi-mount, although it | 386 | * after umounting a rootless multi-mount, although it |
| 385 | * should. For v5 have_submounts() is sufficient to handle | 387 | * should. For v5 path_has_submounts() is sufficient to |
| 386 | * this because the leaves of the directory tree under the | 388 | * handle this because the leaves of the directory tree under |
| 387 | * mount never trigger mounts themselves (they have an autofs | 389 | * the mount never trigger mounts themselves (they have an |
| 388 | * trigger mount mounted on them). But v4 pseudo direct mounts | 390 | * autofs trigger mount mounted on them). But v4 pseudo direct |
| 389 | * do need the leaves to trigger mounts. In this case we | 391 | * mounts do need the leaves to trigger mounts. In this case |
| 390 | * have no choice but to use the list_empty() check and | 392 | * we have no choice but to use the list_empty() check and |
| 391 | * require user space behave. | 393 | * require user space behave. |
| 392 | */ | 394 | */ |
| 393 | if (sbi->version > 4) { | 395 | if (sbi->version > 4) { |
| 394 | if (have_submounts(dentry)) { | 396 | if (path_has_submounts(path)) { |
| 395 | spin_unlock(&sbi->fs_lock); | 397 | spin_unlock(&sbi->fs_lock); |
| 396 | goto done; | 398 | goto done; |
| 397 | } | 399 | } |
| @@ -403,7 +405,7 @@ static struct vfsmount *autofs4_d_automount(struct path *path) · 5 unmodified lines | |||
| 403 | } | 405 | } |
| 404 | ino->flags |= AUTOFS_INF_PENDING; | 406 | ino->flags |= AUTOFS_INF_PENDING; |
| 405 | spin_unlock(&sbi->fs_lock); | 407 | spin_unlock(&sbi->fs_lock); |
| 406 | status = autofs4_mount_wait(dentry, 0); | 408 | status = autofs4_mount_wait(path, 0); |
| 407 | spin_lock(&sbi->fs_lock); | 409 | spin_lock(&sbi->fs_lock); |
| 408 | ino->flags &= ~AUTOFS_INF_PENDING; | 410 | ino->flags &= ~AUTOFS_INF_PENDING; |
| 409 | if (status) { | 411 | if (status) { |
| @@ -421,8 +423,9 @@ done: · 11 unmodified lines | |||
| 421 | return NULL; | 423 | return NULL; |
| 422 | } | 424 | } |
| 423 | 425 | ||
| 424 | static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk) | 426 | static int autofs4_d_manage(const struct path *path, bool rcu_walk) |
| 425 | { | 427 | { |
| 428 | struct dentry *dentry = path->dentry; | ||
| 426 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | 429 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); |
| 427 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | 430 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
| 428 | int status; | 431 | int status; |
| @@ -431,20 +434,20 @@ static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk) · 2 unmodified lines | |||
| 431 | 434 | ||
| 432 | /* The daemon never waits. */ | 435 | /* The daemon never waits. */ |
| 433 | if (autofs4_oz_mode(sbi)) { | 436 | if (autofs4_oz_mode(sbi)) { |
| 434 | if (!d_mountpoint(dentry)) | 437 | if (!path_is_mountpoint(path)) |
| 435 | return -EISDIR; | 438 | return -EISDIR; |
| 436 | return 0; | 439 | return 0; |
| 437 | } | 440 | } |
| 438 | 441 | ||
| 439 | /* Wait for pending expires */ | 442 | /* Wait for pending expires */ |
| 440 | if (do_expire_wait(dentry, rcu_walk) == -ECHILD) | 443 | if (do_expire_wait(path, rcu_walk) == -ECHILD) |
| 441 | return -ECHILD; | 444 | return -ECHILD; |
| 442 | 445 | ||
| 443 | /* | 446 | /* |
| 444 | * This dentry may be under construction so wait on mount | 447 | * This dentry may be under construction so wait on mount |
| 445 | * completion. | 448 | * completion. |
| 446 | */ | 449 | */ |
| 447 | status = autofs4_mount_wait(dentry, rcu_walk); | 450 | status = autofs4_mount_wait(path, rcu_walk); |
| 448 | if (status) | 451 | if (status) |
| 449 | return status; | 452 | return status; |
| 450 | 453 | ||
| @@ -460,7 +463,7 @@ static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk) · 9 unmodified lines | |||
| 460 | 463 | ||
| 461 | if (ino->flags & AUTOFS_INF_WANT_EXPIRE) | 464 | if (ino->flags & AUTOFS_INF_WANT_EXPIRE) |
| 462 | return 0; | 465 | return 0; |
| 463 | if (d_mountpoint(dentry)) | 466 | if (path_is_mountpoint(path)) |
| 464 | return 0; | 467 | return 0; |
| 465 | inode = d_inode_rcu(dentry); | 468 | inode = d_inode_rcu(dentry); |
| 466 | if (inode && S_ISLNK(inode->i_mode)) | 469 | if (inode && S_ISLNK(inode->i_mode)) |
| @@ -487,7 +490,7 @@ static int autofs4_d_manage(struct dentry *dentry, bool rcu_walk) · 20 unmodified lines | |||
| 487 | * we can avoid needless calls ->d_automount() and avoid | 490 | * we can avoid needless calls ->d_automount() and avoid |
| 488 | * an incorrect ELOOP error return. | 491 | * an incorrect ELOOP error return. |
| 489 | */ | 492 | */ |
| 490 | if ((!d_mountpoint(dentry) && !simple_empty(dentry)) || | 493 | if ((!path_is_mountpoint(path) && !simple_empty(dentry)) || |
| 491 | (d_really_is_positive(dentry) && d_is_symlink(dentry))) | 494 | (d_really_is_positive(dentry) && d_is_symlink(dentry))) |
| 492 | status = -EISDIR; | 495 | status = -EISDIR; |
| 493 | } | 496 | } |
| @@ -250,8 +250,9 @@ autofs4_find_wait(struct autofs_sb_info *sbi, const struct qstr *qstr) · 249 unmodified lines | |||
| 250 | static int validate_request(struct autofs_wait_queue **wait, | 250 | static int validate_request(struct autofs_wait_queue **wait, |
| 251 | struct autofs_sb_info *sbi, | 251 | struct autofs_sb_info *sbi, |
| 252 | const struct qstr *qstr, | 252 | const struct qstr *qstr, |
| 253 | struct dentry *dentry, enum autofs_notify notify) | 253 | const struct path *path, enum autofs_notify notify) |
| 254 | { | 254 | { |
| 255 | struct dentry *dentry = path->dentry; | ||
| 255 | struct autofs_wait_queue *wq; | 256 | struct autofs_wait_queue *wq; |
| 256 | struct autofs_info *ino; | 257 | struct autofs_info *ino; |
| 257 | 258 | ||
| @@ -314,6 +315,7 @@ static int validate_request(struct autofs_wait_queue **wait, · 56 unmodified lines | |||
| 314 | */ | 315 | */ |
| 315 | if (notify == NFY_MOUNT) { | 316 | if (notify == NFY_MOUNT) { |
| 316 | struct dentry *new = NULL; | 317 | struct dentry *new = NULL; |
| 318 | struct path this; | ||
| 317 | int valid = 1; | 319 | int valid = 1; |
| 318 | 320 | ||
| 319 | /* | 321 | /* |
| @@ -333,7 +335,9 @@ static int validate_request(struct autofs_wait_queue **wait, · 13 unmodified lines | |||
| 333 | dentry = new; | 335 | dentry = new; |
| 334 | } | 336 | } |
| 335 | } | 337 | } |
| 336 | if (have_submounts(dentry)) | 338 | this.mnt = path->mnt; |
| 339 | this.dentry = dentry; | ||
| 340 | if (path_has_submounts(&this)) | ||
| 337 | valid = 0; | 341 | valid = 0; |
| 338 | 342 | ||
| 339 | if (new) | 343 | if (new) |
| @@ -345,8 +349,9 @@ static int validate_request(struct autofs_wait_queue **wait, · 5 unmodified lines | |||
| 345 | } | 349 | } |
| 346 | 350 | ||
| 347 | int autofs4_wait(struct autofs_sb_info *sbi, | 351 | int autofs4_wait(struct autofs_sb_info *sbi, |
| 348 | struct dentry *dentry, enum autofs_notify notify) | 352 | const struct path *path, enum autofs_notify notify) |
| 349 | { | 353 | { |
| 354 | struct dentry *dentry = path->dentry; | ||
| 350 | struct autofs_wait_queue *wq; | 355 | struct autofs_wait_queue *wq; |
| 351 | struct qstr qstr; | 356 | struct qstr qstr; |
| 352 | char *name; | 357 | char *name; |
| @@ -405,7 +410,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, · 52 unmodified lines | |||
| 405 | return -EINTR; | 410 | return -EINTR; |
| 406 | } | 411 | } |
| 407 | 412 | ||
| 408 | ret = validate_request(&wq, sbi, &qstr, dentry, notify); | 413 | ret = validate_request(&wq, sbi, &qstr, path, notify); |
| 409 | if (ret <= 0) { | 414 | if (ret <= 0) { |
| 410 | if (ret != -EINTR) | 415 | if (ret != -EINTR) |
| 411 | mutex_unlock(&sbi->wq_mutex); | 416 | mutex_unlock(&sbi->wq_mutex); |
| @@ -3232,9 +3232,6 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages, · 3231 unmodified lines | |||
| 3232 | size_t num_pages, loff_t pos, size_t write_bytes, | 3232 | size_t num_pages, loff_t pos, size_t write_bytes, |
| 3233 | struct extent_state **cached); | 3233 | struct extent_state **cached); |
| 3234 | int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end); | 3234 | int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end); |
| 3235 | ssize_t btrfs_copy_file_range(struct file *file_in, loff_t pos_in, | ||
| 3236 | struct file *file_out, loff_t pos_out, | ||
| 3237 | size_t len, unsigned int flags); | ||
| 3238 | int btrfs_clone_file_range(struct file *file_in, loff_t pos_in, | 3235 | int btrfs_clone_file_range(struct file *file_in, loff_t pos_in, |
| 3239 | struct file *file_out, loff_t pos_out, u64 len); | 3236 | struct file *file_out, loff_t pos_out, u64 len); |
| 3240 | 3237 | ||
| @@ -3033,7 +3033,6 @@ const struct file_operations btrfs_file_operations = { · 3032 unmodified lines | |||
| 3033 | #ifdef CONFIG_COMPAT | 3033 | #ifdef CONFIG_COMPAT |
| 3034 | .compat_ioctl = btrfs_compat_ioctl, | 3034 | .compat_ioctl = btrfs_compat_ioctl, |
| 3035 | #endif | 3035 | #endif |
| 3036 | .copy_file_range = btrfs_copy_file_range, | ||
| 3037 | .clone_file_range = btrfs_clone_file_range, | 3036 | .clone_file_range = btrfs_clone_file_range, |
| 3038 | .dedupe_file_range = btrfs_dedupe_file_range, | 3037 | .dedupe_file_range = btrfs_dedupe_file_range, |
| 3039 | }; | 3038 | }; |
| @@ -834,7 +834,7 @@ static inline int btrfs_may_create(struct inode *dir, struct dentry *child) · 833 unmodified lines | |||
| 834 | * sys_mkdirat and vfs_mkdir, but we only do a single component lookup | 834 | * sys_mkdirat and vfs_mkdir, but we only do a single component lookup |
| 835 | * inside this filesystem so it's quite a bit simpler. | 835 | * inside this filesystem so it's quite a bit simpler. |
| 836 | */ | 836 | */ |
| 837 | static noinline int btrfs_mksubvol(struct path *parent, | 837 | static noinline int btrfs_mksubvol(const struct path *parent, |
| 838 | char *name, int namelen, | 838 | char *name, int namelen, |
| 839 | struct btrfs_root *snap_src, | 839 | struct btrfs_root *snap_src, |
| 840 | u64 *async_transid, bool readonly, | 840 | u64 *async_transid, bool readonly, |
| @@ -3987,18 +3987,6 @@ out_unlock: · 3146 unmodified lines | |||
| 3987 | return ret; | 3987 | return ret; |
| 3988 | } | 3988 | } |
| 3989 | 3989 | ||
| 3990 | ssize_t btrfs_copy_file_range(struct file *file_in, loff_t pos_in, | ||
| 3991 | struct file *file_out, loff_t pos_out, | ||
| 3992 | size_t len, unsigned int flags) | ||
| 3993 | { | ||
| 3994 | ssize_t ret; | ||
| 3995 | |||
| 3996 | ret = btrfs_clone_files(file_out, file_in, pos_in, len, pos_out); | ||
| 3997 | if (ret == 0) | ||
| 3998 | ret = len; | ||
| 3999 | return ret; | ||
| 4000 | } | ||
| 4001 | |||
| 4002 | int btrfs_clone_file_range(struct file *src_file, loff_t off, | 3990 | int btrfs_clone_file_range(struct file *src_file, loff_t off, |
| 4003 | struct file *dst_file, loff_t destoff, u64 len) | 3991 | struct file *dst_file, loff_t destoff, u64 len) |
| 4004 | { | 3992 | { |
| @@ -1317,25 +1317,27 @@ static int ceph_write_end(struct file *file, struct address_space *mapping, · 1316 unmodified lines | |||
| 1317 | struct page *page, void *fsdata) | 1317 | struct page *page, void *fsdata) |
| 1318 | { | 1318 | { |
| 1319 | struct inode *inode = file_inode(file); | 1319 | struct inode *inode = file_inode(file); |
| 1320 | unsigned from = pos & (PAGE_SIZE - 1); | ||
| 1321 | int check_cap = 0; | 1320 | int check_cap = 0; |
| 1322 | 1321 | ||
| 1323 | dout("write_end file %p inode %p page %p %d~%d (%d)\n", file, | 1322 | dout("write_end file %p inode %p page %p %d~%d (%d)\n", file, |
| 1324 | inode, page, (int)pos, (int)copied, (int)len); | 1323 | inode, page, (int)pos, (int)copied, (int)len); |
| 1325 | 1324 | ||
| 1326 | /* zero the stale part of the page if we did a short copy */ | 1325 | /* zero the stale part of the page if we did a short copy */ |
| 1327 | if (copied < len) | 1326 | if (!PageUptodate(page)) { |
| 1328 | zero_user_segment(page, from+copied, len); | 1327 | if (copied < len) { |
| 1328 | copied = 0; | ||
| 1329 | goto out; | ||
| 1330 | } | ||
| 1331 | SetPageUptodate(page); | ||
| 1332 | } | ||
| 1329 | 1333 | ||
| 1330 | /* did file size increase? */ | 1334 | /* did file size increase? */ |
| 1331 | if (pos+copied > i_size_read(inode)) | 1335 | if (pos+copied > i_size_read(inode)) |
| 1332 | check_cap = ceph_inode_set_size(inode, pos+copied); | 1336 | check_cap = ceph_inode_set_size(inode, pos+copied); |
| 1333 | 1337 | ||
| 1334 | if (!PageUptodate(page)) | ||
| 1335 | SetPageUptodate(page); | ||
| 1336 | |||
| 1337 | set_page_dirty(page); | 1338 | set_page_dirty(page); |
| 1338 | 1339 | ||
| 1340 | out: | ||
| 1339 | unlock_page(page); | 1341 | unlock_page(page); |
| 1340 | put_page(page); | 1342 | put_page(page); |
| 1341 | 1343 | ||
| @@ -1273,38 +1273,44 @@ rename_retry: · 1272 unmodified lines | |||
| 1273 | goto again; | 1273 | goto again; |
| 1274 | } | 1274 | } |
| 1275 | 1275 | ||
| 1276 | /* | 1276 | struct check_mount { |
| 1277 | * Search for at least 1 mount point in the dentry's subdirs. | 1277 | struct vfsmount *mnt; |
| 1278 | * We descend to the next level whenever the d_subdirs | 1278 | unsigned int mounted; |
| 1279 | * list is non-empty and continue searching. | 1279 | }; |
| 1280 | */ | ||
| 1281 | 1280 | ||
| 1282 | static enum d_walk_ret check_mount(void *data, struct dentry *dentry) | 1281 | static enum d_walk_ret path_check_mount(void *data, struct dentry *dentry) |
| 1283 | { | 1282 | { |
| 1284 | int *ret = data; | 1283 | struct check_mount *info = data; |
| 1285 | if (d_mountpoint(dentry)) { | 1284 | struct path path = { .mnt = info->mnt, .dentry = dentry }; |
| 1286 | *ret = 1; | 1285 | |
| 1286 | if (likely(!d_mountpoint(dentry))) | ||
| 1287 | return D_WALK_CONTINUE; | ||
| 1288 | if (__path_is_mountpoint(&path)) { | ||
| 1289 | info->mounted = 1; | ||
| 1287 | return D_WALK_QUIT; | 1290 | return D_WALK_QUIT; |
| 1288 | } | 1291 | } |
| 1289 | return D_WALK_CONTINUE; | 1292 | return D_WALK_CONTINUE; |
| 1290 | } | 1293 | } |
| 1291 | 1294 | ||
| 1292 | /** | 1295 | /** |
| 1293 | * have_submounts - check for mounts over a dentry | 1296 | * path_has_submounts - check for mounts over a dentry in the |
| 1294 | * @parent: dentry to check. | 1297 | * current namespace. |
| 1298 | * @parent: path to check. | ||
| 1295 | * | 1299 | * |
| 1296 | * Return true if the parent or its subdirectories contain | 1300 | * Return true if the parent or its subdirectories contain |
| 1297 | * a mount point | 1301 | * a mount point in the current namespace. |
| 1298 | */ | 1302 | */ |
| 1299 | int have_submounts(struct dentry *parent) | 1303 | int path_has_submounts(const struct path *parent) |
| 1300 | { | 1304 | { |
| 1301 | int ret = 0; | 1305 | struct check_mount data = { .mnt = parent->mnt, .mounted = 0 }; |
| 1302 | 1306 | ||
| 1303 | d_walk(parent, &ret, check_mount, NULL); | 1307 | read_seqlock_excl(&mount_lock); |
| 1308 | d_walk(parent->dentry, &data, path_check_mount, NULL); | ||
| 1309 | read_sequnlock_excl(&mount_lock); | ||
| 1304 | 1310 | ||
| 1305 | return ret; | 1311 | return data.mounted; |
| 1306 | } | 1312 | } |
| 1307 | EXPORT_SYMBOL(have_submounts); | 1313 | EXPORT_SYMBOL(path_has_submounts); |
| 1308 | 1314 | ||
| 1309 | /* | 1315 | /* |
| 1310 | * Called by mount code to set a mountpoint and check if the mountpoint is | 1316 | * Called by mount code to set a mountpoint and check if the mountpoint is |
| @@ -90,7 +90,7 @@ static void hash_dcookie(struct dcookie_struct * dcs) · 89 unmodified lines | |||
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | 92 | ||
| 93 | static struct dcookie_struct *alloc_dcookie(struct path *path) | 93 | static struct dcookie_struct *alloc_dcookie(const struct path *path) |
| 94 | { | 94 | { |
| 95 | struct dcookie_struct *dcs = kmem_cache_alloc(dcookie_cache, | 95 | struct dcookie_struct *dcs = kmem_cache_alloc(dcookie_cache, |
| 96 | GFP_KERNEL); | 96 | GFP_KERNEL); |
| @@ -113,7 +113,7 @@ static struct dcookie_struct *alloc_dcookie(struct path *path) · 16 unmodified lines | |||
| 113 | /* This is the main kernel-side routine that retrieves the cookie | 113 | /* This is the main kernel-side routine that retrieves the cookie |
| 114 | * value for a dentry/vfsmnt pair. | 114 | * value for a dentry/vfsmnt pair. |
| 115 | */ | 115 | */ |
| 116 | int get_dcookie(struct path *path, unsigned long *cookie) | 116 | int get_dcookie(const struct path *path, unsigned long *cookie) |
| 117 | { | 117 | { |
| 118 | int err = 0; | 118 | int err = 0; |
| 119 | struct dcookie_struct * dcs; | 119 | struct dcookie_struct * dcs; |
| @@ -870,46 +870,31 @@ int exofs_write_begin(struct file *file, struct address_space *mapping, · 869 unmodified lines | |||
| 870 | 870 | ||
| 871 | page = *pagep; | 871 | page = *pagep; |
| 872 | if (page == NULL) { | 872 | if (page == NULL) { |
| 873 | ret = simple_write_begin(file, mapping, pos, len, flags, pagep, | 873 | page = grab_cache_page_write_begin(mapping, pos >> PAGE_SHIFT, |
| 874 | fsdata); | 874 | flags); |
| 875 | if (ret) { | 875 | if (!page) { |
| 876 | EXOFS_DBGMSG("simple_write_begin failed\n"); | 876 | EXOFS_DBGMSG("grab_cache_page_write_begin failed\n"); |
| 877 | goto out; | 877 | return -ENOMEM; |
| 878 | } | 878 | } |
| 879 | 879 | *pagep = page; | |
| 880 | page = *pagep; | ||
| 881 | } | 880 | } |
| 882 | 881 | ||
| 883 | /* read modify write */ | 882 | /* read modify write */ |
| 884 | if (!PageUptodate(page) && (len != PAGE_SIZE)) { | 883 | if (!PageUptodate(page) && (len != PAGE_SIZE)) { |
| 885 | loff_t i_size = i_size_read(mapping->host); | 884 | loff_t i_size = i_size_read(mapping->host); |
| 886 | pgoff_t end_index = i_size >> PAGE_SHIFT; | 885 | pgoff_t end_index = i_size >> PAGE_SHIFT; |
| 887 | size_t rlen; | ||
| 888 | 886 | ||
| 889 | if (page->index < end_index) | 887 | if (page->index > end_index) { |
| 890 | rlen = PAGE_SIZE; | ||
| 891 | else if (page->index == end_index) | ||
| 892 | rlen = i_size & ~PAGE_MASK; | ||
| 893 | else | ||
| 894 | rlen = 0; | ||
| 895 | |||
| 896 | if (!rlen) { | ||
| 897 | clear_highpage(page); | 888 | clear_highpage(page); |
| 898 | SetPageUptodate(page); | 889 | SetPageUptodate(page); |
| 899 | goto out; | 890 | } else { |
| 900 | } | 891 | ret = _readpage(page, true); |
| 901 | 892 | if (ret) { | |
| 902 | ret = _readpage(page, true); | 893 | unlock_page(page); |
| 903 | if (ret) { | 894 | EXOFS_DBGMSG("__readpage failed\n"); |
| 904 | /*SetPageError was done by _readpage. Is it ok?*/ | 895 | } |
| 905 | unlock_page(page); | ||
| 906 | EXOFS_DBGMSG("__readpage failed\n"); | ||
| 907 | } | 896 | } |
| 908 | } | 897 | } |
| 909 | out: | ||
| 910 | if (unlikely(ret)) | ||
| 911 | _write_failed(mapping->host, pos + len); | ||
| 912 | |||
| 913 | return ret; | 898 | return ret; |
| 914 | } | 899 | } |
| 915 | 900 | ||
| @@ -929,18 +914,25 @@ static int exofs_write_end(struct file *file, struct address_space *mapping, · 13 unmodified lines | |||
| 929 | struct page *page, void *fsdata) | 914 | struct page *page, void *fsdata) |
| 930 | { | 915 | { |
| 931 | struct inode *inode = mapping->host; | 916 | struct inode *inode = mapping->host; |
| 932 | /* According to comment in simple_write_end i_mutex is held */ | 917 | loff_t last_pos = pos + copied; |
| 933 | loff_t i_size = inode->i_size; | ||
| 934 | int ret; | ||
| 935 | |||
| 936 | ret = simple_write_end(file, mapping,pos, len, copied, page, fsdata); | ||
| 937 | if (unlikely(ret)) | ||
| 938 | _write_failed(inode, pos + len); | ||
| 939 | 918 | ||
| 940 | /* TODO: once simple_write_end marks inode dirty remove */ | 919 | if (!PageUptodate(page)) { |
| 941 | if (i_size != inode->i_size) | 920 | if (copied < len) { |
| 921 | _write_failed(inode, pos + len); | ||
| 922 | copied = 0; | ||
| 923 | goto out; | ||
| 924 | } | ||
| 925 | SetPageUptodate(page); | ||
| 926 | } | ||
| 927 | if (last_pos > inode->i_size) { | ||
| 928 | i_size_write(inode, last_pos); | ||
| 942 | mark_inode_dirty(inode); | 929 | mark_inode_dirty(inode); |
| 943 | return ret; | 930 | } |
| 931 | set_page_dirty(page); | ||
| 932 | out: | ||
| 933 | unlock_page(page); | ||
| 934 | put_page(page); | ||
| 935 | return copied; | ||
| 944 | } | 936 | } |
| 945 | 937 | ||
| 946 | static int exofs_releasepage(struct page *page, gfp_t gfp) | 938 | static int exofs_releasepage(struct page *page, gfp_t gfp) |
| @@ -1205,7 +1205,7 @@ static int ext4_release_dquot(struct dquot *dquot); · 1204 unmodified lines | |||
| 1205 | static int ext4_mark_dquot_dirty(struct dquot *dquot); | 1205 | static int ext4_mark_dquot_dirty(struct dquot *dquot); |
| 1206 | static int ext4_write_info(struct super_block *sb, int type); | 1206 | static int ext4_write_info(struct super_block *sb, int type); |
| 1207 | static int ext4_quota_on(struct super_block *sb, int type, int format_id, | 1207 | static int ext4_quota_on(struct super_block *sb, int type, int format_id, |
| 1208 | struct path *path); | 1208 | const struct path *path); |
| 1209 | static int ext4_quota_off(struct super_block *sb, int type); | 1209 | static int ext4_quota_off(struct super_block *sb, int type); |
| 1210 | static int ext4_quota_on_mount(struct super_block *sb, int type); | 1210 | static int ext4_quota_on_mount(struct super_block *sb, int type); |
| 1211 | static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data, | 1211 | static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data, |
| @@ -5293,7 +5293,7 @@ static void lockdep_set_quota_inode(struct inode *inode, int subclass) · 4081 unmodified lines | |||
| 5293 | * Standard function to be called on quota_on | 5293 | * Standard function to be called on quota_on |
| 5294 | */ | 5294 | */ |
| 5295 | static int ext4_quota_on(struct super_block *sb, int type, int format_id, | 5295 | static int ext4_quota_on(struct super_block *sb, int type, int format_id, |
| 5296 | struct path *path) | 5296 | const struct path *path) |
| 5297 | { | 5297 | { |
| 5298 | int err; | 5298 | int err; |
| 5299 | 5299 | ||
| @@ -155,7 +155,7 @@ over: · 154 unmodified lines | |||
| 155 | * @mode: the mode with which the new file will be opened | 155 | * @mode: the mode with which the new file will be opened |
| 156 | * @fop: the 'struct file_operations' for the new file | 156 | * @fop: the 'struct file_operations' for the new file |
| 157 | */ | 157 | */ |
| 158 | struct file *alloc_file(struct path *path, fmode_t mode, | 158 | struct file *alloc_file(const struct path *path, fmode_t mode, |
| 159 | const struct file_operations *fop) | 159 | const struct file_operations *fop) |
| 160 | { | 160 | { |
| 161 | struct file *file; | 161 | struct file *file; |
| @@ -839,12 +839,10 @@ static int gfs2_stuffed_write_end(struct inode *inode, struct buffer_head *dibh, · 838 unmodified lines | |||
| 839 | BUG_ON((pos + len) > (dibh->b_size - sizeof(struct gfs2_dinode))); | 839 | BUG_ON((pos + len) > (dibh->b_size - sizeof(struct gfs2_dinode))); |
| 840 | kaddr = kmap_atomic(page); | 840 | kaddr = kmap_atomic(page); |
| 841 | memcpy(buf + pos, kaddr + pos, copied); | 841 | memcpy(buf + pos, kaddr + pos, copied); |
| 842 | memset(kaddr + pos + copied, 0, len - copied); | ||
| 843 | flush_dcache_page(page); | 842 | flush_dcache_page(page); |
| 844 | kunmap_atomic(kaddr); | 843 | kunmap_atomic(kaddr); |
| 845 | 844 | ||
| 846 | if (!PageUptodate(page)) | 845 | WARN_ON(!PageUptodate(page)); |
| 847 | SetPageUptodate(page); | ||
| 848 | unlock_page(page); | 846 | unlock_page(page); |
| 849 | put_page(page); | 847 | put_page(page); |
| 850 | 848 | ||
| @@ -62,7 +62,7 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *, · 61 unmodified lines | |||
| 62 | extern void *copy_mount_options(const void __user *); | 62 | extern void *copy_mount_options(const void __user *); |
| 63 | extern char *copy_mount_string(const void __user *); | 63 | extern char *copy_mount_string(const void __user *); |
| 64 | 64 | ||
| 65 | extern struct vfsmount *lookup_mnt(struct path *); | 65 | extern struct vfsmount *lookup_mnt(const struct path *); |
| 66 | extern int finish_automount(struct vfsmount *, struct path *); | 66 | extern int finish_automount(struct vfsmount *, struct path *); |
| 67 | 67 | ||
| 68 | extern int sb_prepare_remount_readonly(struct super_block *); | 68 | extern int sb_prepare_remount_readonly(struct super_block *); |
| @@ -465,6 +465,8 @@ EXPORT_SYMBOL(simple_write_begin); · 464 unmodified lines | |||
| 465 | * is not called, so a filesystem that actually does store data in .write_inode | 465 | * is not called, so a filesystem that actually does store data in .write_inode |
| 466 | * should extend on what's done here with a call to mark_inode_dirty() in the | 466 | * should extend on what's done here with a call to mark_inode_dirty() in the |
| 467 | * case that i_size has changed. | 467 | * case that i_size has changed. |
| 468 | * | ||
| 469 | * Use *ONLY* with simple_readpage() | ||
| 468 | */ | 470 | */ |
| 469 | int simple_write_end(struct file *file, struct address_space *mapping, | 471 | int simple_write_end(struct file *file, struct address_space *mapping, |
| 470 | loff_t pos, unsigned len, unsigned copied, | 472 | loff_t pos, unsigned len, unsigned copied, |
| @@ -474,14 +476,14 @@ int simple_write_end(struct file *file, struct address_space *mapping, · 3 unmodified lines | |||
| 474 | loff_t last_pos = pos + copied; | 476 | loff_t last_pos = pos + copied; |
| 475 | 477 | ||
| 476 | /* zero the stale part of the page if we did a short copy */ | 478 | /* zero the stale part of the page if we did a short copy */ |
| 477 | if (copied < len) { | 479 | if (!PageUptodate(page)) { |
| 478 | unsigned from = pos & (PAGE_SIZE - 1); | 480 | if (copied < len) { |
| 479 | 481 | unsigned from = pos & (PAGE_SIZE - 1); | |
| 480 | zero_user(page, from + copied, len - copied); | ||
| 481 | } | ||
| 482 | 482 | ||
| 483 | if (!PageUptodate(page)) | 483 | zero_user(page, from + copied, len - copied); |
| 484 | } | ||
| 484 | SetPageUptodate(page); | 485 | SetPageUptodate(page); |
| 486 | } | ||
| 485 | /* | 487 | /* |
| 486 | * No need to use i_size_read() here, the i_size | 488 | * No need to use i_size_read() here, the i_size |
| 487 | * cannot change under us because we hold the i_mutex. | 489 | * cannot change under us because we hold the i_mutex. |
| @@ -94,6 +94,12 @@ extern struct mount *__lookup_mnt_last(struct vfsmount *, struct dentry *); · 93 unmodified lines | |||
| 94 | extern int __legitimize_mnt(struct vfsmount *, unsigned); | 94 | extern int __legitimize_mnt(struct vfsmount *, unsigned); |
| 95 | extern bool legitimize_mnt(struct vfsmount *, unsigned); | 95 | extern bool legitimize_mnt(struct vfsmount *, unsigned); |
| 96 | 96 | ||
| 97 | static inline bool __path_is_mountpoint(const struct path *path) | ||
| 98 | { | ||
| 99 | struct mount *m = __lookup_mnt(path->mnt, path->dentry); | ||
| 100 | return m && likely(!(m->mnt.mnt_flags & MNT_SYNC_UMOUNT)); | ||
| 101 | } | ||
| 102 | |||
| 97 | extern void __detach_mounts(struct dentry *dentry); | 103 | extern void __detach_mounts(struct dentry *dentry); |
| 98 | 104 | ||
| 99 | static inline void detach_mounts(struct dentry *dentry) | 105 | static inline void detach_mounts(struct dentry *dentry) |
| @@ -1200,7 +1200,7 @@ static int follow_managed(struct path *path, struct nameidata *nd) · 1199 unmodified lines | |||
| 1200 | if (managed & DCACHE_MANAGE_TRANSIT) { | 1200 | if (managed & DCACHE_MANAGE_TRANSIT) { |
| 1201 | BUG_ON(!path->dentry->d_op); | 1201 | BUG_ON(!path->dentry->d_op); |
| 1202 | BUG_ON(!path->dentry->d_op->d_manage); | 1202 | BUG_ON(!path->dentry->d_op->d_manage); |
| 1203 | ret = path->dentry->d_op->d_manage(path->dentry, false); | 1203 | ret = path->dentry->d_op->d_manage(path, false); |
| 1204 | if (ret < 0) | 1204 | if (ret < 0) |
| 1205 | break; | 1205 | break; |
| 1206 | } | 1206 | } |
| @@ -1263,10 +1263,10 @@ int follow_down_one(struct path *path) · 56 unmodified lines | |||
| 1263 | } | 1263 | } |
| 1264 | EXPORT_SYMBOL(follow_down_one); | 1264 | EXPORT_SYMBOL(follow_down_one); |
| 1265 | 1265 | ||
| 1266 | static inline int managed_dentry_rcu(struct dentry *dentry) | 1266 | static inline int managed_dentry_rcu(const struct path *path) |
| 1267 | { | 1267 | { |
| 1268 | return (dentry->d_flags & DCACHE_MANAGE_TRANSIT) ? | 1268 | return (path->dentry->d_flags & DCACHE_MANAGE_TRANSIT) ? |
| 1269 | dentry->d_op->d_manage(dentry, true) : 0; | 1269 | path->dentry->d_op->d_manage(path, true) : 0; |
| 1270 | } | 1270 | } |
| 1271 | 1271 | ||
| 1272 | /* | 1272 | /* |
| @@ -1282,7 +1282,7 @@ static bool __follow_mount_rcu(struct nameidata *nd, struct path *path, · 9 unmodified lines | |||
| 1282 | * Don't forget we might have a non-mountpoint managed dentry | 1282 | * Don't forget we might have a non-mountpoint managed dentry |
| 1283 | * that wants to block transit. | 1283 | * that wants to block transit. |
| 1284 | */ | 1284 | */ |
| 1285 | switch (managed_dentry_rcu(path->dentry)) { | 1285 | switch (managed_dentry_rcu(path)) { |
| 1286 | case -ECHILD: | 1286 | case -ECHILD: |
| 1287 | default: | 1287 | default: |
| 1288 | return false; | 1288 | return false; |
| @@ -1392,8 +1392,7 @@ int follow_down(struct path *path) · 103 unmodified lines | |||
| 1392 | if (managed & DCACHE_MANAGE_TRANSIT) { | 1392 | if (managed & DCACHE_MANAGE_TRANSIT) { |
| 1393 | BUG_ON(!path->dentry->d_op); | 1393 | BUG_ON(!path->dentry->d_op); |
| 1394 | BUG_ON(!path->dentry->d_op->d_manage); | 1394 | BUG_ON(!path->dentry->d_op->d_manage); |
| 1395 | ret = path->dentry->d_op->d_manage( | 1395 | ret = path->dentry->d_op->d_manage(path, false); |
| 1396 | path->dentry, false); | ||
| 1397 | if (ret < 0) | 1396 | if (ret < 0) |
| 1398 | return ret == -EISDIR ? 0 : ret; | 1397 | return ret == -EISDIR ? 0 : ret; |
| 1399 | } | 1398 | } |
| @@ -2863,7 +2862,7 @@ bool may_open_dev(const struct path *path) · 1463 unmodified lines | |||
| 2863 | !(path->mnt->mnt_sb->s_iflags & SB_I_NODEV); | 2862 | !(path->mnt->mnt_sb->s_iflags & SB_I_NODEV); |
| 2864 | } | 2863 | } |
| 2865 | 2864 | ||
| 2866 | static int may_open(struct path *path, int acc_mode, int flag) | 2865 | static int may_open(const struct path *path, int acc_mode, int flag) |
| 2867 | { | 2866 | { |
| 2868 | struct dentry *dentry = path->dentry; | 2867 | struct dentry *dentry = path->dentry; |
| 2869 | struct inode *inode = dentry->d_inode; | 2868 | struct inode *inode = dentry->d_inode; |
| @@ -2913,7 +2912,7 @@ static int may_open(struct path *path, int acc_mode, int flag) · 43 unmodified lines | |||
| 2913 | 2912 | ||
| 2914 | static int handle_truncate(struct file *filp) | 2913 | static int handle_truncate(struct file *filp) |
| 2915 | { | 2914 | { |
| 2916 | struct path *path = &filp->f_path; | 2915 | const struct path *path = &filp->f_path; |
| 2917 | struct inode *inode = path->dentry->d_inode; | 2916 | struct inode *inode = path->dentry->d_inode; |
| 2918 | int error = get_write_access(inode); | 2917 | int error = get_write_access(inode); |
| 2919 | if (error) | 2918 | if (error) |
| @@ -678,7 +678,7 @@ out: · 677 unmodified lines | |||
| 678 | * | 678 | * |
| 679 | * lookup_mnt takes a reference to the found vfsmount. | 679 | * lookup_mnt takes a reference to the found vfsmount. |
| 680 | */ | 680 | */ |
| 681 | struct vfsmount *lookup_mnt(struct path *path) | 681 | struct vfsmount *lookup_mnt(const struct path *path) |
| 682 | { | 682 | { |
| 683 | struct mount *child_mnt; | 683 | struct mount *child_mnt; |
| 684 | struct vfsmount *m; | 684 | struct vfsmount *m; |
| @@ -1159,7 +1159,36 @@ struct vfsmount *mntget(struct vfsmount *mnt) · 474 unmodified lines | |||
| 1159 | } | 1159 | } |
| 1160 | EXPORT_SYMBOL(mntget); | 1160 | EXPORT_SYMBOL(mntget); |
| 1161 | 1161 | ||
| 1162 | struct vfsmount *mnt_clone_internal(struct path *path) | 1162 | /* path_is_mountpoint() - Check if path is a mount in the current |
| 1163 | * namespace. | ||
| 1164 | * | ||
| 1165 | * d_mountpoint() can only be used reliably to establish if a dentry is | ||
| 1166 | * not mounted in any namespace and that common case is handled inline. | ||
| 1167 | * d_mountpoint() isn't aware of the possibility there may be multiple | ||
| 1168 | * mounts using a given dentry in a different namespace. This function | ||
| 1169 | * checks if the passed in path is a mountpoint rather than the dentry | ||
| 1170 | * alone. | ||
| 1171 | */ | ||
| 1172 | bool path_is_mountpoint(const struct path *path) | ||
| 1173 | { | ||
| 1174 | unsigned seq; | ||
| 1175 | bool res; | ||
| 1176 | |||
| 1177 | if (!d_mountpoint(path->dentry)) | ||
| 1178 | return false; | ||
| 1179 | |||
| 1180 | rcu_read_lock(); | ||
| 1181 | do { | ||
| 1182 | seq = read_seqbegin(&mount_lock); | ||
| 1183 | res = __path_is_mountpoint(path); | ||
| 1184 | } while (read_seqretry(&mount_lock, seq)); | ||
| 1185 | rcu_read_unlock(); | ||
| 1186 | |||
| 1187 | return res; | ||
| 1188 | } | ||
| 1189 | EXPORT_SYMBOL(path_is_mountpoint); | ||
| 1190 | |||
| 1191 | struct vfsmount *mnt_clone_internal(const struct path *path) | ||
| 1163 | { | 1192 | { |
| 1164 | struct mount *p; | 1193 | struct mount *p; |
| 1165 | p = clone_mnt(real_mount(path->mnt), path->dentry, CL_PRIVATE); | 1194 | p = clone_mnt(real_mount(path->mnt), path->dentry, CL_PRIVATE); |
| @@ -1758,7 +1787,7 @@ out: · 592 unmodified lines | |||
| 1758 | 1787 | ||
| 1759 | /* Caller should check returned pointer for errors */ | 1788 | /* Caller should check returned pointer for errors */ |
| 1760 | 1789 | ||
| 1761 | struct vfsmount *collect_mounts(struct path *path) | 1790 | struct vfsmount *collect_mounts(const struct path *path) |
| 1762 | { | 1791 | { |
| 1763 | struct mount *tree; | 1792 | struct mount *tree; |
| 1764 | namespace_lock(); | 1793 | namespace_lock(); |
| @@ -1791,7 +1820,7 @@ void drop_collected_mounts(struct vfsmount *mnt) · 26 unmodified lines | |||
| 1791 | * | 1820 | * |
| 1792 | * Release with mntput(). | 1821 | * Release with mntput(). |
| 1793 | */ | 1822 | */ |
| 1794 | struct vfsmount *clone_private_mount(struct path *path) | 1823 | struct vfsmount *clone_private_mount(const struct path *path) |
| 1795 | { | 1824 | { |
| 1796 | struct mount *old_mnt = real_mount(path->mnt); | 1825 | struct mount *old_mnt = real_mount(path->mnt); |
| 1797 | struct mount *new_mnt; | 1826 | struct mount *new_mnt; |
| @@ -2997,7 +3026,7 @@ bool is_path_reachable(struct mount *mnt, struct dentry *dentry, · 1199 unmodified lines | |||
| 2997 | return &mnt->mnt == root->mnt && is_subdir(dentry, root->dentry); | 3026 | return &mnt->mnt == root->mnt && is_subdir(dentry, root->dentry); |
| 2998 | } | 3027 | } |
| 2999 | 3028 | ||
| 3000 | bool path_is_under(struct path *path1, struct path *path2) | 3029 | bool path_is_under(const struct path *path1, const struct path *path2) |
| 3001 | { | 3030 | { |
| 3002 | bool res; | 3031 | bool res; |
| 3003 | read_seqlock_excl(&mount_lock); | 3032 | read_seqlock_excl(&mount_lock); |
| @@ -377,7 +377,7 @@ static int nfs_write_end(struct file *file, struct address_space *mapping, · 376 unmodified lines | |||
| 377 | */ | 377 | */ |
| 378 | if (!PageUptodate(page)) { | 378 | if (!PageUptodate(page)) { |
| 379 | unsigned pglen = nfs_page_length(page); | 379 | unsigned pglen = nfs_page_length(page); |
| 380 | unsigned end = offset + len; | 380 | unsigned end = offset + copied; |
| 381 | 381 | ||
| 382 | if (pglen == 0) { | 382 | if (pglen == 0) { |
| 383 | zero_user_segments(page, 0, offset, | 383 | zero_user_segments(page, 0, offset, |
| @@ -85,7 +85,7 @@ static int dnotify_handle_event(struct fsnotify_group *group, · 84 unmodified lines | |||
| 85 | struct inode *inode, | 85 | struct inode *inode, |
| 86 | struct fsnotify_mark *inode_mark, | 86 | struct fsnotify_mark *inode_mark, |
| 87 | struct fsnotify_mark *vfsmount_mark, | 87 | struct fsnotify_mark *vfsmount_mark, |
| 88 | u32 mask, void *data, int data_type, | 88 | u32 mask, const void *data, int data_type, |
| 89 | const unsigned char *file_name, u32 cookie) | 89 | const unsigned char *file_name, u32 cookie) |
| 90 | { | 90 | { |
| 91 | struct dnotify_mark *dn_mark; | 91 | struct dnotify_mark *dn_mark; |
| @@ -90,10 +90,10 @@ static int fanotify_get_response(struct fsnotify_group *group, · 89 unmodified lines | |||
| 90 | static bool fanotify_should_send_event(struct fsnotify_mark *inode_mark, | 90 | static bool fanotify_should_send_event(struct fsnotify_mark *inode_mark, |
| 91 | struct fsnotify_mark *vfsmnt_mark, | 91 | struct fsnotify_mark *vfsmnt_mark, |
| 92 | u32 event_mask, | 92 | u32 event_mask, |
| 93 | void *data, int data_type) | 93 | const void *data, int data_type) |
| 94 | { | 94 | { |
| 95 | __u32 marks_mask, marks_ignored_mask; | 95 | __u32 marks_mask, marks_ignored_mask; |
| 96 | struct path *path = data; | 96 | const struct path *path = data; |
| 97 | 97 | ||
| 98 | pr_debug("%s: inode_mark=%p vfsmnt_mark=%p mask=%x data=%p" | 98 | pr_debug("%s: inode_mark=%p vfsmnt_mark=%p mask=%x data=%p" |
| 99 | " data_type=%d\n", __func__, inode_mark, vfsmnt_mark, | 99 | " data_type=%d\n", __func__, inode_mark, vfsmnt_mark, |
| @@ -140,7 +140,7 @@ static bool fanotify_should_send_event(struct fsnotify_mark *inode_mark, · 40 unmodified lines | |||
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | struct fanotify_event_info *fanotify_alloc_event(struct inode *inode, u32 mask, | 142 | struct fanotify_event_info *fanotify_alloc_event(struct inode *inode, u32 mask, |
| 143 | struct path *path) | 143 | const struct path *path) |
| 144 | { | 144 | { |
| 145 | struct fanotify_event_info *event; | 145 | struct fanotify_event_info *event; |
| 146 | 146 | ||
| @@ -177,7 +177,7 @@ static int fanotify_handle_event(struct fsnotify_group *group, · 30 unmodified lines | |||
| 177 | struct inode *inode, | 177 | struct inode *inode, |
| 178 | struct fsnotify_mark *inode_mark, | 178 | struct fsnotify_mark *inode_mark, |
| 179 | struct fsnotify_mark *fanotify_mark, | 179 | struct fsnotify_mark *fanotify_mark, |
| 180 | u32 mask, void *data, int data_type, | 180 | u32 mask, const void *data, int data_type, |
| 181 | const unsigned char *file_name, u32 cookie) | 181 | const unsigned char *file_name, u32 cookie) |
| 182 | { | 182 | { |
| 183 | int ret = 0; | 183 | int ret = 0; |
| @@ -47,4 +47,4 @@ static inline struct fanotify_event_info *FANOTIFY_E(struct fsnotify_event *fse) · 46 unmodified lines | |||
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | struct fanotify_event_info *fanotify_alloc_event(struct inode *inode, u32 mask, | 49 | struct fanotify_event_info *fanotify_alloc_event(struct inode *inode, u32 mask, |
| 50 | struct path *path); | 50 | const struct path *path); |
| @@ -86,7 +86,7 @@ void __fsnotify_update_child_dentry_flags(struct inode *inode) · 85 unmodified lines | |||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | /* Notify this dentry's parent about a child's events. */ | 88 | /* Notify this dentry's parent about a child's events. */ |
| 89 | int __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) | 89 | int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask) |
| 90 | { | 90 | { |
| 91 | struct dentry *parent; | 91 | struct dentry *parent; |
| 92 | struct inode *p_inode; | 92 | struct inode *p_inode; |
| @@ -125,7 +125,7 @@ EXPORT_SYMBOL_GPL(__fsnotify_parent); · 32 unmodified lines | |||
| 125 | static int send_to_group(struct inode *to_tell, | 125 | static int send_to_group(struct inode *to_tell, |
| 126 | struct fsnotify_mark *inode_mark, | 126 | struct fsnotify_mark *inode_mark, |
| 127 | struct fsnotify_mark *vfsmount_mark, | 127 | struct fsnotify_mark *vfsmount_mark, |
| 128 | __u32 mask, void *data, | 128 | __u32 mask, const void *data, |
| 129 | int data_is, u32 cookie, | 129 | int data_is, u32 cookie, |
| 130 | const unsigned char *file_name) | 130 | const unsigned char *file_name) |
| 131 | { | 131 | { |
| @@ -187,7 +187,7 @@ static int send_to_group(struct inode *to_tell, · 55 unmodified lines | |||
| 187 | * out to all of the registered fsnotify_group. Those groups can then use the | 187 | * out to all of the registered fsnotify_group. Those groups can then use the |
| 188 | * notification event in whatever means they feel necessary. | 188 | * notification event in whatever means they feel necessary. |
| 189 | */ | 189 | */ |
| 190 | int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, | 190 | int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, |
| 191 | const unsigned char *file_name, u32 cookie) | 191 | const unsigned char *file_name, u32 cookie) |
| 192 | { | 192 | { |
| 193 | struct hlist_node *inode_node = NULL, *vfsmount_node = NULL; | 193 | struct hlist_node *inode_node = NULL, *vfsmount_node = NULL; |
| @@ -199,7 +199,7 @@ int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, · 5 unmodified lines | |||
| 199 | __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); | 199 | __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); |
| 200 | 200 | ||
| 201 | if (data_is == FSNOTIFY_EVENT_PATH) | 201 | if (data_is == FSNOTIFY_EVENT_PATH) |
| 202 | mnt = real_mount(((struct path *)data)->mnt); | 202 | mnt = real_mount(((const struct path *)data)->mnt); |
| 203 | else | 203 | else |
| 204 | mnt = NULL; | 204 | mnt = NULL; |
| 205 | 205 | ||
| @@ -26,7 +26,7 @@ extern int inotify_handle_event(struct fsnotify_group *group, · 25 unmodified lines | |||
| 26 | struct inode *inode, | 26 | struct inode *inode, |
| 27 | struct fsnotify_mark *inode_mark, | 27 | struct fsnotify_mark *inode_mark, |
| 28 | struct fsnotify_mark *vfsmount_mark, | 28 | struct fsnotify_mark *vfsmount_mark, |
| 29 | u32 mask, void *data, int data_type, | 29 | u32 mask, const void *data, int data_type, |
| 30 | const unsigned char *file_name, u32 cookie); | 30 | const unsigned char *file_name, u32 cookie); |
| 31 | 31 | ||
| 32 | extern const struct fsnotify_ops inotify_fsnotify_ops; | 32 | extern const struct fsnotify_ops inotify_fsnotify_ops; |
| @@ -66,7 +66,7 @@ int inotify_handle_event(struct fsnotify_group *group, · 65 unmodified lines | |||
| 66 | struct inode *inode, | 66 | struct inode *inode, |
| 67 | struct fsnotify_mark *inode_mark, | 67 | struct fsnotify_mark *inode_mark, |
| 68 | struct fsnotify_mark *vfsmount_mark, | 68 | struct fsnotify_mark *vfsmount_mark, |
| 69 | u32 mask, void *data, int data_type, | 69 | u32 mask, const void *data, int data_type, |
| 70 | const unsigned char *file_name, u32 cookie) | 70 | const unsigned char *file_name, u32 cookie) |
| 71 | { | 71 | { |
| 72 | struct inotify_inode_mark *i_mark; | 72 | struct inotify_inode_mark *i_mark; |
| @@ -80,7 +80,7 @@ int inotify_handle_event(struct fsnotify_group *group, · 7 unmodified lines | |||
| 80 | 80 | ||
| 81 | if ((inode_mark->mask & FS_EXCL_UNLINK) && | 81 | if ((inode_mark->mask & FS_EXCL_UNLINK) && |
| 82 | (data_type == FSNOTIFY_EVENT_PATH)) { | 82 | (data_type == FSNOTIFY_EVENT_PATH)) { |
| 83 | struct path *path = data; | 83 | const struct path *path = data; |
| 84 | 84 | ||
| 85 | if (d_unlinked(path->dentry)) | 85 | if (d_unlinked(path->dentry)) |
| 86 | return 0; | 86 | return 0; |
| @@ -5194,7 +5194,7 @@ int ocfs2_change_extent_flag(handle_t *handle, · 5193 unmodified lines | |||
| 5194 | rec = &el->l_recs[index]; | 5194 | rec = &el->l_recs[index]; |
| 5195 | if (new_flags && (rec->e_flags & new_flags)) { | 5195 | if (new_flags && (rec->e_flags & new_flags)) { |
| 5196 | mlog(ML_ERROR, "Owner %llu tried to set %d flags on an " | 5196 | mlog(ML_ERROR, "Owner %llu tried to set %d flags on an " |
| 5197 | "extent that already had them", | 5197 | "extent that already had them\n", |
| 5198 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), | 5198 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), |
| 5199 | new_flags); | 5199 | new_flags); |
| 5200 | goto out; | 5200 | goto out; |
| @@ -5202,7 +5202,7 @@ int ocfs2_change_extent_flag(handle_t *handle, · 1 unmodified line | |||
| 5202 | 5202 | ||
| 5203 | if (clear_flags && !(rec->e_flags & clear_flags)) { | 5203 | if (clear_flags && !(rec->e_flags & clear_flags)) { |
| 5204 | mlog(ML_ERROR, "Owner %llu tried to clear %d flags on an " | 5204 | mlog(ML_ERROR, "Owner %llu tried to clear %d flags on an " |
| 5205 | "extent that didn't have them", | 5205 | "extent that didn't have them\n", |
| 5206 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), | 5206 | (unsigned long long)ocfs2_metadata_cache_owner(et->et_ci), |
| 5207 | clear_flags); | 5207 | clear_flags); |
| 5208 | goto out; | 5208 | goto out; |
| @@ -5713,8 +5713,7 @@ int ocfs2_remove_btree_range(struct inode *inode, · 504 unmodified lines | |||
| 5713 | struct ocfs2_refcount_tree *ref_tree = NULL; | 5713 | struct ocfs2_refcount_tree *ref_tree = NULL; |
| 5714 | 5714 | ||
| 5715 | if ((flags & OCFS2_EXT_REFCOUNTED) && len) { | 5715 | if ((flags & OCFS2_EXT_REFCOUNTED) && len) { |
| 5716 | BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & | 5716 | BUG_ON(!ocfs2_is_refcount_inode(inode)); |
| 5717 | OCFS2_HAS_REFCOUNT_FL)); | ||
| 5718 | 5717 | ||
| 5719 | if (!refcount_tree_locked) { | 5718 | if (!refcount_tree_locked) { |
| 5720 | ret = ocfs2_lock_refcount_tree(osb, refcount_loc, 1, | 5719 | ret = ocfs2_lock_refcount_tree(osb, refcount_loc, 1, |
| @@ -464,6 +464,15 @@ static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block) · 463 unmodified lines | |||
| 464 | trace_ocfs2_bmap((unsigned long long)OCFS2_I(inode)->ip_blkno, | 464 | trace_ocfs2_bmap((unsigned long long)OCFS2_I(inode)->ip_blkno, |
| 465 | (unsigned long long)block); | 465 | (unsigned long long)block); |
| 466 | 466 | ||
| 467 | /* | ||
| 468 | * The swap code (ab-)uses ->bmap to get a block mapping and then | ||
| 469 | * bypasseѕ the file system for actual I/O. We really can't allow | ||
| 470 | * that on refcounted inodes, so we have to skip out here. And yes, | ||
| 471 | * 0 is the magic code for a bmap error.. | ||
| 472 | */ | ||
| 473 | if (ocfs2_is_refcount_inode(inode)) | ||
| 474 | return 0; | ||
| 475 | |||
| 467 | /* We don't need to lock journal system files, since they aren't | 476 | /* We don't need to lock journal system files, since they aren't |
| 468 | * accessed concurrently from multiple nodes. | 477 | * accessed concurrently from multiple nodes. |
| 469 | */ | 478 | */ |
| @@ -2253,10 +2262,10 @@ out: · 1783 unmodified lines | |||
| 2253 | return ret; | 2262 | return ret; |
| 2254 | } | 2263 | } |
| 2255 | 2264 | ||
| 2256 | static void ocfs2_dio_end_io_write(struct inode *inode, | 2265 | static int ocfs2_dio_end_io_write(struct inode *inode, |
| 2257 | struct ocfs2_dio_write_ctxt *dwc, | 2266 | struct ocfs2_dio_write_ctxt *dwc, |
| 2258 | loff_t offset, | 2267 | loff_t offset, |
| 2259 | ssize_t bytes) | 2268 | ssize_t bytes) |
| 2260 | { | 2269 | { |
| 2261 | struct ocfs2_cached_dealloc_ctxt dealloc; | 2270 | struct ocfs2_cached_dealloc_ctxt dealloc; |
| 2262 | struct ocfs2_extent_tree et; | 2271 | struct ocfs2_extent_tree et; |
| @@ -2307,7 +2316,7 @@ static void ocfs2_dio_end_io_write(struct inode *inode, · 44 unmodified lines | |||
| 2307 | mlog_errno(ret); | 2316 | mlog_errno(ret); |
| 2308 | } | 2317 | } |
| 2309 | 2318 | ||
| 2310 | di = (struct ocfs2_dinode *)di_bh; | 2319 | di = (struct ocfs2_dinode *)di_bh->b_data; |
| 2311 | 2320 | ||
| 2312 | ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh); | 2321 | ocfs2_init_dinode_extent_tree(&et, INODE_CACHE(inode), di_bh); |
| 2313 | 2322 | ||
| @@ -2364,6 +2373,8 @@ out: · 50 unmodified lines | |||
| 2364 | if (locked) | 2373 | if (locked) |
| 2365 | inode_unlock(inode); | 2374 | inode_unlock(inode); |
| 2366 | ocfs2_dio_free_write_ctx(inode, dwc); | 2375 | ocfs2_dio_free_write_ctx(inode, dwc); |
| 2376 | |||
| 2377 | return ret; | ||
| 2367 | } | 2378 | } |
| 2368 | 2379 | ||
| 2369 | /* | 2380 | /* |
| @@ -2378,21 +2389,19 @@ static int ocfs2_dio_end_io(struct kiocb *iocb, · 8 unmodified lines | |||
| 2378 | { | 2389 | { |
| 2379 | struct inode *inode = file_inode(iocb->ki_filp); | 2390 | struct inode *inode = file_inode(iocb->ki_filp); |
| 2380 | int level; | 2391 | int level; |
| 2381 | 2392 | int ret = 0; | |
| 2382 | if (bytes <= 0) | ||
| 2383 | return 0; | ||
| 2384 | 2393 | ||
| 2385 | /* this io's submitter should not have unlocked this before we could */ | 2394 | /* this io's submitter should not have unlocked this before we could */ |
| 2386 | BUG_ON(!ocfs2_iocb_is_rw_locked(iocb)); | 2395 | BUG_ON(!ocfs2_iocb_is_rw_locked(iocb)); |
| 2387 | 2396 | ||
| 2388 | if (private) | 2397 | if (bytes > 0 && private) |
| 2389 | ocfs2_dio_end_io_write(inode, private, offset, bytes); | 2398 | ret = ocfs2_dio_end_io_write(inode, private, offset, bytes); |
| 2390 | 2399 | ||
| 2391 | ocfs2_iocb_clear_rw_locked(iocb); | 2400 | ocfs2_iocb_clear_rw_locked(iocb); |
| 2392 | 2401 | ||
| 2393 | level = ocfs2_iocb_rw_locked_level(iocb); | 2402 | level = ocfs2_iocb_rw_locked_level(iocb); |
| 2394 | ocfs2_rw_unlock(inode, level); | 2403 | ocfs2_rw_unlock(inode, level); |
| 2395 | return 0; | 2404 | return ret; |
| 2396 | } | 2405 | } |
| 2397 | 2406 | ||
| 2398 | static ssize_t ocfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter) | 2407 | static ssize_t ocfs2_direct_IO(struct kiocb *iocb, struct iov_iter *iter) |
| @@ -1030,7 +1030,7 @@ int ocfs2_extend_no_holes(struct inode *inode, struct buffer_head *di_bh, · 1029 unmodified lines | |||
| 1030 | * Only quota files call this without a bh, and they can't be | 1030 | * Only quota files call this without a bh, and they can't be |
| 1031 | * refcounted. | 1031 | * refcounted. |
| 1032 | */ | 1032 | */ |
| 1033 | BUG_ON(!di_bh && (oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)); | 1033 | BUG_ON(!di_bh && ocfs2_is_refcount_inode(inode)); |
| 1034 | BUG_ON(!di_bh && !(oi->ip_flags & OCFS2_INODE_SYSTEM_FILE)); | 1034 | BUG_ON(!di_bh && !(oi->ip_flags & OCFS2_INODE_SYSTEM_FILE)); |
| 1035 | 1035 | ||
| 1036 | clusters_to_add = ocfs2_clusters_for_bytes(inode->i_sb, new_i_size); | 1036 | clusters_to_add = ocfs2_clusters_for_bytes(inode->i_sb, new_i_size); |
| @@ -1667,9 +1667,9 @@ static void ocfs2_calc_trunc_pos(struct inode *inode, · 630 unmodified lines | |||
| 1667 | *done = ret; | 1667 | *done = ret; |
| 1668 | } | 1668 | } |
| 1669 | 1669 | ||
| 1670 | static int ocfs2_remove_inode_range(struct inode *inode, | 1670 | int ocfs2_remove_inode_range(struct inode *inode, |
| 1671 | struct buffer_head *di_bh, u64 byte_start, | 1671 | struct buffer_head *di_bh, u64 byte_start, |
| 1672 | u64 byte_len) | 1672 | u64 byte_len) |
| 1673 | { | 1673 | { |
| 1674 | int ret = 0, flags = 0, done = 0, i; | 1674 | int ret = 0, flags = 0, done = 0, i; |
| 1675 | u32 trunc_start, trunc_len, trunc_end, trunc_cpos, phys_cpos; | 1675 | u32 trunc_start, trunc_len, trunc_end, trunc_cpos, phys_cpos; |
| @@ -1719,8 +1719,7 @@ static int ocfs2_remove_inode_range(struct inode *inode, · 43 unmodified lines | |||
| 1719 | * within one cluster(means is not exactly aligned to clustersize). | 1719 | * within one cluster(means is not exactly aligned to clustersize). |
| 1720 | */ | 1720 | */ |
| 1721 | 1721 | ||
| 1722 | if (OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL) { | 1722 | if (ocfs2_is_refcount_inode(inode)) { |
| 1723 | |||
| 1724 | ret = ocfs2_cow_file_pos(inode, di_bh, byte_start); | 1723 | ret = ocfs2_cow_file_pos(inode, di_bh, byte_start); |
| 1725 | if (ret) { | 1724 | if (ret) { |
| 1726 | mlog_errno(ret); | 1725 | mlog_errno(ret); |
| @@ -2036,7 +2035,7 @@ int ocfs2_check_range_for_refcount(struct inode *inode, loff_t pos, · 309 unmodified lines | |||
| 2036 | struct super_block *sb = inode->i_sb; | 2035 | struct super_block *sb = inode->i_sb; |
| 2037 | 2036 | ||
| 2038 | if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb)) || | 2037 | if (!ocfs2_refcount_tree(OCFS2_SB(inode->i_sb)) || |
| 2039 | !(OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL) || | 2038 | !ocfs2_is_refcount_inode(inode) || |
| 2040 | OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) | 2039 | OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) |
| 2041 | return 0; | 2040 | return 0; |
| 2042 | 2041 | ||
| @@ -2440,6 +2439,31 @@ out: · 397 unmodified lines | |||
| 2440 | return offset; | 2439 | return offset; |
| 2441 | } | 2440 | } |
| 2442 | 2441 | ||
| 2442 | static int ocfs2_file_clone_range(struct file *file_in, | ||
| 2443 | loff_t pos_in, | ||
| 2444 | struct file *file_out, | ||
| 2445 | loff_t pos_out, | ||
| 2446 | u64 len) | ||
| 2447 | { | ||
| 2448 | return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, | ||
| 2449 | len, false); | ||
| 2450 | } | ||
| 2451 | |||
| 2452 | static ssize_t ocfs2_file_dedupe_range(struct file *src_file, | ||
| 2453 | u64 loff, | ||
| 2454 | u64 len, | ||
| 2455 | struct file *dst_file, | ||
| 2456 | u64 dst_loff) | ||
| 2457 | { | ||
| 2458 | int error; | ||
| 2459 | |||
| 2460 | error = ocfs2_reflink_remap_range(src_file, loff, dst_file, dst_loff, | ||
| 2461 | len, true); | ||
| 2462 | if (error) | ||
| 2463 | return error; | ||
| 2464 | return len; | ||
| 2465 | } | ||
| 2466 | |||
| 2443 | const struct inode_operations ocfs2_file_iops = { | 2467 | const struct inode_operations ocfs2_file_iops = { |
| 2444 | .setattr = ocfs2_setattr, | 2468 | .setattr = ocfs2_setattr, |
| 2445 | .getattr = ocfs2_getattr, | 2469 | .getattr = ocfs2_getattr, |
| @@ -2479,6 +2503,8 @@ const struct file_operations ocfs2_fops = { · 33 unmodified lines | |||
| 2479 | .splice_read = generic_file_splice_read, | 2503 | .splice_read = generic_file_splice_read, |
| 2480 | .splice_write = iter_file_splice_write, | 2504 | .splice_write = iter_file_splice_write, |
| 2481 | .fallocate = ocfs2_fallocate, | 2505 | .fallocate = ocfs2_fallocate, |
| 2506 | .clone_file_range = ocfs2_file_clone_range, | ||
| 2507 | .dedupe_file_range = ocfs2_file_dedupe_range, | ||
| 2482 | }; | 2508 | }; |
| 2483 | 2509 | ||
| 2484 | const struct file_operations ocfs2_dops = { | 2510 | const struct file_operations ocfs2_dops = { |
| @@ -2524,6 +2550,8 @@ const struct file_operations ocfs2_fops_no_plocks = { · 39 unmodified lines | |||
| 2524 | .splice_read = generic_file_splice_read, | 2550 | .splice_read = generic_file_splice_read, |
| 2525 | .splice_write = iter_file_splice_write, | 2551 | .splice_write = iter_file_splice_write, |
| 2526 | .fallocate = ocfs2_fallocate, | 2552 | .fallocate = ocfs2_fallocate, |
| 2553 | .clone_file_range = ocfs2_file_clone_range, | ||
| 2554 | .dedupe_file_range = ocfs2_file_dedupe_range, | ||
| 2527 | }; | 2555 | }; |
| 2528 | 2556 | ||
| 2529 | const struct file_operations ocfs2_dops_no_plocks = { | 2557 | const struct file_operations ocfs2_dops_no_plocks = { |
| @@ -82,4 +82,7 @@ int ocfs2_change_file_space(struct file *file, unsigned int cmd, · 81 unmodified lines | |||
| 82 | 82 | ||
| 83 | int ocfs2_check_range_for_refcount(struct inode *inode, loff_t pos, | 83 | int ocfs2_check_range_for_refcount(struct inode *inode, loff_t pos, |
| 84 | size_t count); | 84 | size_t count); |
| 85 | int ocfs2_remove_inode_range(struct inode *inode, | ||
| 86 | struct buffer_head *di_bh, u64 byte_start, | ||
| 87 | u64 byte_len); | ||
| 85 | #endif /* OCFS2_FILE_H */ | 88 | #endif /* OCFS2_FILE_H */ |
| @@ -181,4 +181,10 @@ static inline struct ocfs2_inode_info *cache_info_to_inode(struct ocfs2_caching_ · 180 unmodified lines | |||
| 181 | return container_of(ci, struct ocfs2_inode_info, ip_metadata_cache); | 181 | return container_of(ci, struct ocfs2_inode_info, ip_metadata_cache); |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | /* Does this inode have the reflink flag set? */ | ||
| 185 | static inline bool ocfs2_is_refcount_inode(struct inode *inode) | ||
| 186 | { | ||
| 187 | return (OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL); | ||
| 188 | } | ||
| 189 | |||
| 184 | #endif /* OCFS2_INODE_H */ | 190 | #endif /* OCFS2_INODE_H */ |
| @@ -235,10 +235,7 @@ static int ocfs2_defrag_extent(struct ocfs2_move_extents_context *context, · 234 unmodified lines | |||
| 235 | u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); | 235 | u64 phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); |
| 236 | 236 | ||
| 237 | if ((ext_flags & OCFS2_EXT_REFCOUNTED) && *len) { | 237 | if ((ext_flags & OCFS2_EXT_REFCOUNTED) && *len) { |
| 238 | 238 | BUG_ON(!ocfs2_is_refcount_inode(inode)); | |
| 239 | BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & | ||
| 240 | OCFS2_HAS_REFCOUNT_FL)); | ||
| 241 | |||
| 242 | BUG_ON(!context->refcount_loc); | 239 | BUG_ON(!context->refcount_loc); |
| 243 | 240 | ||
| 244 | ret = ocfs2_lock_refcount_tree(osb, context->refcount_loc, 1, | 241 | ret = ocfs2_lock_refcount_tree(osb, context->refcount_loc, 1, |
| @@ -581,10 +578,7 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_context *context, · 336 unmodified lines | |||
| 581 | phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); | 578 | phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, phys_cpos); |
| 582 | 579 | ||
| 583 | if ((ext_flags & OCFS2_EXT_REFCOUNTED) && len) { | 580 | if ((ext_flags & OCFS2_EXT_REFCOUNTED) && len) { |
| 584 | 581 | BUG_ON(!ocfs2_is_refcount_inode(inode)); | |
| 585 | BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & | ||
| 586 | OCFS2_HAS_REFCOUNT_FL)); | ||
| 587 | |||
| 588 | BUG_ON(!context->refcount_loc); | 582 | BUG_ON(!context->refcount_loc); |
| 589 | 583 | ||
| 590 | ret = ocfs2_lock_refcount_tree(osb, context->refcount_loc, 1, | 584 | ret = ocfs2_lock_refcount_tree(osb, context->refcount_loc, 1, |
| @@ -34,6 +34,7 @@ · 33 unmodified lines | |||
| 34 | #include "xattr.h" | 34 | #include "xattr.h" |
| 35 | #include "namei.h" | 35 | #include "namei.h" |
| 36 | #include "ocfs2_trace.h" | 36 | #include "ocfs2_trace.h" |
| 37 | #include "file.h" | ||
| 37 | 38 | ||
| 38 | #include <linux/bio.h> | 39 | #include <linux/bio.h> |
| 39 | #include <linux/blkdev.h> | 40 | #include <linux/blkdev.h> |
| @@ -410,7 +411,7 @@ static int ocfs2_get_refcount_block(struct inode *inode, u64 *ref_blkno) · 370 unmodified lines | |||
| 410 | goto out; | 411 | goto out; |
| 411 | } | 412 | } |
| 412 | 413 | ||
| 413 | BUG_ON(!(OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)); | 414 | BUG_ON(!ocfs2_is_refcount_inode(inode)); |
| 414 | 415 | ||
| 415 | di = (struct ocfs2_dinode *)di_bh->b_data; | 416 | di = (struct ocfs2_dinode *)di_bh->b_data; |
| 416 | *ref_blkno = le64_to_cpu(di->i_refcount_loc); | 417 | *ref_blkno = le64_to_cpu(di->i_refcount_loc); |
| @@ -569,7 +570,7 @@ static int ocfs2_create_refcount_tree(struct inode *inode, · 152 unmodified lines | |||
| 569 | u32 num_got; | 570 | u32 num_got; |
| 570 | u64 suballoc_loc, first_blkno; | 571 | u64 suballoc_loc, first_blkno; |
| 571 | 572 | ||
| 572 | BUG_ON(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL); | 573 | BUG_ON(ocfs2_is_refcount_inode(inode)); |
| 573 | 574 | ||
| 574 | trace_ocfs2_create_refcount_tree( | 575 | trace_ocfs2_create_refcount_tree( |
| 575 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | 576 | (unsigned long long)OCFS2_I(inode)->ip_blkno); |
| @@ -707,7 +708,7 @@ static int ocfs2_set_refcount_tree(struct inode *inode, · 131 unmodified lines | |||
| 707 | struct ocfs2_refcount_block *rb; | 708 | struct ocfs2_refcount_block *rb; |
| 708 | struct ocfs2_refcount_tree *ref_tree; | 709 | struct ocfs2_refcount_tree *ref_tree; |
| 709 | 710 | ||
| 710 | BUG_ON(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL); | 711 | BUG_ON(ocfs2_is_refcount_inode(inode)); |
| 711 | 712 | ||
| 712 | ret = ocfs2_lock_refcount_tree(osb, refcount_loc, 1, | 713 | ret = ocfs2_lock_refcount_tree(osb, refcount_loc, 1, |
| 713 | &ref_tree, &ref_root_bh); | 714 | &ref_tree, &ref_root_bh); |
| @@ -774,7 +775,7 @@ int ocfs2_remove_refcount_tree(struct inode *inode, struct buffer_head *di_bh) · 60 unmodified lines | |||
| 774 | u64 blk = 0, bg_blkno = 0, ref_blkno = le64_to_cpu(di->i_refcount_loc); | 775 | u64 blk = 0, bg_blkno = 0, ref_blkno = le64_to_cpu(di->i_refcount_loc); |
| 775 | u16 bit = 0; | 776 | u16 bit = 0; |
| 776 | 777 | ||
| 777 | if (!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)) | 778 | if (!ocfs2_is_refcount_inode(inode)) |
| 778 | return 0; | 779 | return 0; |
| 779 | 780 | ||
| 780 | BUG_ON(!ref_blkno); | 781 | BUG_ON(!ref_blkno); |
| @@ -2298,11 +2299,10 @@ int ocfs2_decrease_refcount(struct inode *inode, · 1517 unmodified lines | |||
| 2298 | { | 2299 | { |
| 2299 | int ret; | 2300 | int ret; |
| 2300 | u64 ref_blkno; | 2301 | u64 ref_blkno; |
| 2301 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | ||
| 2302 | struct buffer_head *ref_root_bh = NULL; | 2302 | struct buffer_head *ref_root_bh = NULL; |
| 2303 | struct ocfs2_refcount_tree *tree; | 2303 | struct ocfs2_refcount_tree *tree; |
| 2304 | 2304 | ||
| 2305 | BUG_ON(!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)); | 2305 | BUG_ON(!ocfs2_is_refcount_inode(inode)); |
| 2306 | 2306 | ||
| 2307 | ret = ocfs2_get_refcount_block(inode, &ref_blkno); | 2307 | ret = ocfs2_get_refcount_block(inode, &ref_blkno); |
| 2308 | if (ret) { | 2308 | if (ret) { |
| @@ -2532,7 +2532,6 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode, · 223 unmodified lines | |||
| 2532 | int *ref_blocks) | 2532 | int *ref_blocks) |
| 2533 | { | 2533 | { |
| 2534 | int ret; | 2534 | int ret; |
| 2535 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | ||
| 2536 | struct buffer_head *ref_root_bh = NULL; | 2535 | struct buffer_head *ref_root_bh = NULL; |
| 2537 | struct ocfs2_refcount_tree *tree; | 2536 | struct ocfs2_refcount_tree *tree; |
| 2538 | u64 start_cpos = ocfs2_blocks_to_clusters(inode->i_sb, phys_blkno); | 2537 | u64 start_cpos = ocfs2_blocks_to_clusters(inode->i_sb, phys_blkno); |
| @@ -2543,7 +2542,7 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode, · 4 unmodified lines | |||
| 2543 | goto out; | 2542 | goto out; |
| 2544 | } | 2543 | } |
| 2545 | 2544 | ||
| 2546 | BUG_ON(!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)); | 2545 | BUG_ON(!ocfs2_is_refcount_inode(inode)); |
| 2547 | 2546 | ||
| 2548 | ret = ocfs2_get_refcount_tree(OCFS2_SB(inode->i_sb), | 2547 | ret = ocfs2_get_refcount_tree(OCFS2_SB(inode->i_sb), |
| 2549 | refcount_loc, &tree); | 2548 | refcount_loc, &tree); |
| @@ -3411,14 +3410,13 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode, · 861 unmodified lines | |||
| 3411 | { | 3410 | { |
| 3412 | int ret; | 3411 | int ret; |
| 3413 | u32 cow_start = 0, cow_len = 0; | 3412 | u32 cow_start = 0, cow_len = 0; |
| 3414 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | ||
| 3415 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 3413 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 3416 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; | 3414 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; |
| 3417 | struct buffer_head *ref_root_bh = NULL; | 3415 | struct buffer_head *ref_root_bh = NULL; |
| 3418 | struct ocfs2_refcount_tree *ref_tree; | 3416 | struct ocfs2_refcount_tree *ref_tree; |
| 3419 | struct ocfs2_cow_context *context = NULL; | 3417 | struct ocfs2_cow_context *context = NULL; |
| 3420 | 3418 | ||
| 3421 | BUG_ON(!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)); | 3419 | BUG_ON(!ocfs2_is_refcount_inode(inode)); |
| 3422 | 3420 | ||
| 3423 | ret = ocfs2_refcount_cal_cow_clusters(inode, &di->id2.i_list, | 3421 | ret = ocfs2_refcount_cal_cow_clusters(inode, &di->id2.i_list, |
| 3424 | cpos, write_len, max_cpos, | 3422 | cpos, write_len, max_cpos, |
| @@ -3628,11 +3626,10 @@ int ocfs2_refcount_cow_xattr(struct inode *inode, · 203 unmodified lines | |||
| 3628 | { | 3626 | { |
| 3629 | int ret; | 3627 | int ret; |
| 3630 | struct ocfs2_xattr_value_root *xv = vb->vb_xv; | 3628 | struct ocfs2_xattr_value_root *xv = vb->vb_xv; |
| 3631 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | ||
| 3632 | struct ocfs2_cow_context *context = NULL; | 3629 | struct ocfs2_cow_context *context = NULL; |
| 3633 | u32 cow_start, cow_len; | 3630 | u32 cow_start, cow_len; |
| 3634 | 3631 | ||
| 3635 | BUG_ON(!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)); | 3632 | BUG_ON(!ocfs2_is_refcount_inode(inode)); |
| 3636 | 3633 | ||
| 3637 | ret = ocfs2_refcount_cal_cow_clusters(inode, &xv->xr_list, | 3634 | ret = ocfs2_refcount_cal_cow_clusters(inode, &xv->xr_list, |
| 3638 | cpos, write_len, UINT_MAX, | 3635 | cpos, write_len, UINT_MAX, |
| @@ -3695,6 +3692,9 @@ int ocfs2_add_refcount_flag(struct inode *inode, · 56 unmodified lines | |||
| 3695 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 3692 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 3696 | struct ocfs2_alloc_context *meta_ac = NULL; | 3693 | struct ocfs2_alloc_context *meta_ac = NULL; |
| 3697 | 3694 | ||
| 3695 | /* We need to be able to handle at least an extent tree split. */ | ||
| 3696 | ref_blocks = ocfs2_extend_meta_needed(data_et->et_root_el); | ||
| 3697 | |||
| 3698 | ret = ocfs2_calc_refcount_meta_credits(inode->i_sb, | 3698 | ret = ocfs2_calc_refcount_meta_credits(inode->i_sb, |
| 3699 | ref_ci, ref_root_bh, | 3699 | ref_ci, ref_root_bh, |
| 3700 | p_cluster, num_clusters, | 3700 | p_cluster, num_clusters, |
| @@ -3806,7 +3806,7 @@ static int ocfs2_attach_refcount_tree(struct inode *inode, · 105 unmodified lines | |||
| 3806 | 3806 | ||
| 3807 | ocfs2_init_dealloc_ctxt(&dealloc); | 3807 | ocfs2_init_dealloc_ctxt(&dealloc); |
| 3808 | 3808 | ||
| 3809 | if (!(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL)) { | 3809 | if (!ocfs2_is_refcount_inode(inode)) { |
| 3810 | ret = ocfs2_create_refcount_tree(inode, di_bh); | 3810 | ret = ocfs2_create_refcount_tree(inode, di_bh); |
| 3811 | if (ret) { | 3811 | if (ret) { |
| 3812 | mlog_errno(ret); | 3812 | mlog_errno(ret); |
| @@ -3933,6 +3933,13 @@ static int ocfs2_add_refcounted_extent(struct inode *inode, · 120 unmodified lines | |||
| 3933 | ret = ocfs2_increase_refcount(handle, ref_ci, ref_root_bh, | 3933 | ret = ocfs2_increase_refcount(handle, ref_ci, ref_root_bh, |
| 3934 | p_cluster, num_clusters, | 3934 | p_cluster, num_clusters, |
| 3935 | meta_ac, dealloc); | 3935 | meta_ac, dealloc); |
| 3936 | if (ret) { | ||
| 3937 | mlog_errno(ret); | ||
| 3938 | goto out_commit; | ||
| 3939 | } | ||
| 3940 | |||
| 3941 | ret = dquot_alloc_space_nodirty(inode, | ||
| 3942 | ocfs2_clusters_to_bytes(osb->sb, num_clusters)); | ||
| 3936 | if (ret) | 3943 | if (ret) |
| 3937 | mlog_errno(ret); | 3944 | mlog_errno(ret); |
| 3938 | 3945 | ||
| @@ -4441,3 +4448,434 @@ out: · 502 unmodified lines | |||
| 4441 | 4448 | ||
| 4442 | return error; | 4449 | return error; |
| 4443 | } | 4450 | } |
| 4451 | |||
| 4452 | /* Update destination inode size, if necessary. */ | ||
| 4453 | static int ocfs2_reflink_update_dest(struct inode *dest, | ||
| 4454 | struct buffer_head *d_bh, | ||
| 4455 | loff_t newlen) | ||
| 4456 | { | ||
| 4457 | handle_t *handle; | ||
| 4458 | int ret; | ||
| 4459 | |||
| 4460 | dest->i_blocks = ocfs2_inode_sector_count(dest); | ||
| 4461 | |||
| 4462 | if (newlen <= i_size_read(dest)) | ||
| 4463 | return 0; | ||
| 4464 | |||
| 4465 | handle = ocfs2_start_trans(OCFS2_SB(dest->i_sb), | ||
| 4466 | OCFS2_INODE_UPDATE_CREDITS); | ||
| 4467 | if (IS_ERR(handle)) { | ||
| 4468 | ret = PTR_ERR(handle); | ||
| 4469 | mlog_errno(ret); | ||
| 4470 | return ret; | ||
| 4471 | } | ||
| 4472 | |||
| 4473 | /* Extend i_size if needed. */ | ||
| 4474 | spin_lock(&OCFS2_I(dest)->ip_lock); | ||
| 4475 | if (newlen > i_size_read(dest)) | ||
| 4476 | i_size_write(dest, newlen); | ||
| 4477 | spin_unlock(&OCFS2_I(dest)->ip_lock); | ||
| 4478 | dest->i_ctime = dest->i_mtime = current_time(dest); | ||
| 4479 | |||
| 4480 | ret = ocfs2_mark_inode_dirty(handle, dest, d_bh); | ||
| 4481 | if (ret) { | ||
| 4482 | mlog_errno(ret); | ||
| 4483 | goto out_commit; | ||
| 4484 | } | ||
| 4485 | |||
| 4486 | out_commit: | ||
| 4487 | ocfs2_commit_trans(OCFS2_SB(dest->i_sb), handle); | ||
| 4488 | return ret; | ||
| 4489 | } | ||
| 4490 | |||
| 4491 | /* Remap the range pos_in:len in s_inode to pos_out:len in t_inode. */ | ||
| 4492 | static int ocfs2_reflink_remap_extent(struct inode *s_inode, | ||
| 4493 | struct buffer_head *s_bh, | ||
| 4494 | loff_t pos_in, | ||
| 4495 | struct inode *t_inode, | ||
| 4496 | struct buffer_head *t_bh, | ||
| 4497 | loff_t pos_out, | ||
| 4498 | loff_t len, | ||
| 4499 | struct ocfs2_cached_dealloc_ctxt *dealloc) | ||
| 4500 | { | ||
| 4501 | struct ocfs2_extent_tree s_et; | ||
| 4502 | struct ocfs2_extent_tree t_et; | ||
| 4503 | struct ocfs2_dinode *dis; | ||
| 4504 | struct buffer_head *ref_root_bh = NULL; | ||
| 4505 | struct ocfs2_refcount_tree *ref_tree; | ||
| 4506 | struct ocfs2_super *osb; | ||
| 4507 | loff_t pstart, plen; | ||
| 4508 | u32 p_cluster, num_clusters, slast, spos, tpos; | ||
| 4509 | unsigned int ext_flags; | ||
| 4510 | int ret = 0; | ||
| 4511 | |||
| 4512 | osb = OCFS2_SB(s_inode->i_sb); | ||
| 4513 | dis = (struct ocfs2_dinode *)s_bh->b_data; | ||
| 4514 | ocfs2_init_dinode_extent_tree(&s_et, INODE_CACHE(s_inode), s_bh); | ||
| 4515 | ocfs2_init_dinode_extent_tree(&t_et, INODE_CACHE(t_inode), t_bh); | ||
| 4516 | |||
| 4517 | spos = ocfs2_bytes_to_clusters(s_inode->i_sb, pos_in); | ||
| 4518 | tpos = ocfs2_bytes_to_clusters(t_inode->i_sb, pos_out); | ||
| 4519 | slast = ocfs2_clusters_for_bytes(s_inode->i_sb, pos_in + len); | ||
| 4520 | |||
| 4521 | while (spos < slast) { | ||
| 4522 | if (fatal_signal_pending(current)) { | ||
| 4523 | ret = -EINTR; | ||
| 4524 | goto out; | ||
| 4525 | } | ||
| 4526 | |||
| 4527 | /* Look up the extent. */ | ||
| 4528 | ret = ocfs2_get_clusters(s_inode, spos, &p_cluster, | ||
| 4529 | &num_clusters, &ext_flags); | ||
| 4530 | if (ret) { | ||
| 4531 | mlog_errno(ret); | ||
| 4532 | goto out; | ||
| 4533 | } | ||
| 4534 | |||
| 4535 | num_clusters = min_t(u32, num_clusters, slast - spos); | ||
| 4536 | |||
| 4537 | /* Punch out the dest range. */ | ||
| 4538 | pstart = ocfs2_clusters_to_bytes(t_inode->i_sb, tpos); | ||
| 4539 | plen = ocfs2_clusters_to_bytes(t_inode->i_sb, num_clusters); | ||
| 4540 | ret = ocfs2_remove_inode_range(t_inode, t_bh, pstart, plen); | ||
| 4541 | if (ret) { | ||
| 4542 | mlog_errno(ret); | ||
| 4543 | goto out; | ||
| 4544 | } | ||
| 4545 | |||
| 4546 | if (p_cluster == 0) | ||
| 4547 | goto next_loop; | ||
| 4548 | |||
| 4549 | /* Lock the refcount btree... */ | ||
| 4550 | ret = ocfs2_lock_refcount_tree(osb, | ||
| 4551 | le64_to_cpu(dis->i_refcount_loc), | ||
| 4552 | 1, &ref_tree, &ref_root_bh); | ||
| 4553 | if (ret) { | ||
| 4554 | mlog_errno(ret); | ||
| 4555 | goto out; | ||
| 4556 | } | ||
| 4557 | |||
| 4558 | /* Mark s_inode's extent as refcounted. */ | ||
| 4559 | if (!(ext_flags & OCFS2_EXT_REFCOUNTED)) { | ||
| 4560 | ret = ocfs2_add_refcount_flag(s_inode, &s_et, | ||
| 4561 | &ref_tree->rf_ci, | ||
| 4562 | ref_root_bh, spos, | ||
| 4563 | p_cluster, num_clusters, | ||
| 4564 | dealloc, NULL); | ||
| 4565 | if (ret) { | ||
| 4566 | mlog_errno(ret); | ||
| 4567 | goto out_unlock_refcount; | ||
| 4568 | } | ||
| 4569 | } | ||
| 4570 | |||
| 4571 | /* Map in the new extent. */ | ||
| 4572 | ext_flags |= OCFS2_EXT_REFCOUNTED; | ||
| 4573 | ret = ocfs2_add_refcounted_extent(t_inode, &t_et, | ||
| 4574 | &ref_tree->rf_ci, | ||
| 4575 | ref_root_bh, | ||
| 4576 | tpos, p_cluster, | ||
| 4577 | num_clusters, | ||
| 4578 | ext_flags, | ||
| 4579 | dealloc); | ||
| 4580 | if (ret) { | ||
| 4581 | mlog_errno(ret); | ||
| 4582 | goto out_unlock_refcount; | ||
| 4583 | } | ||
| 4584 | |||
| 4585 | ocfs2_unlock_refcount_tree(osb, ref_tree, 1); | ||
| 4586 | brelse(ref_root_bh); | ||
| 4587 | next_loop: | ||
| 4588 | spos += num_clusters; | ||
| 4589 | tpos += num_clusters; | ||
| 4590 | } | ||
| 4591 | |||
| 4592 | out: | ||
| 4593 | return ret; | ||
| 4594 | out_unlock_refcount: | ||
| 4595 | ocfs2_unlock_refcount_tree(osb, ref_tree, 1); | ||
| 4596 | brelse(ref_root_bh); | ||
| 4597 | return ret; | ||
| 4598 | } | ||
| 4599 | |||
| 4600 | /* Set up refcount tree and remap s_inode to t_inode. */ | ||
| 4601 | static int ocfs2_reflink_remap_blocks(struct inode *s_inode, | ||
| 4602 | struct buffer_head *s_bh, | ||
| 4603 | loff_t pos_in, | ||
| 4604 | struct inode *t_inode, | ||
| 4605 | struct buffer_head *t_bh, | ||
| 4606 | loff_t pos_out, | ||
| 4607 | loff_t len) | ||
| 4608 | { | ||
| 4609 | struct ocfs2_cached_dealloc_ctxt dealloc; | ||
| 4610 | struct ocfs2_super *osb; | ||
| 4611 | struct ocfs2_dinode *dis; | ||
| 4612 | struct ocfs2_dinode *dit; | ||
| 4613 | int ret; | ||
| 4614 | |||
| 4615 | osb = OCFS2_SB(s_inode->i_sb); | ||
| 4616 | dis = (struct ocfs2_dinode *)s_bh->b_data; | ||
| 4617 | dit = (struct ocfs2_dinode *)t_bh->b_data; | ||
| 4618 | ocfs2_init_dealloc_ctxt(&dealloc); | ||
| 4619 | |||
| 4620 | /* | ||
| 4621 | * If we're reflinking the entire file and the source is inline | ||
| 4622 | * data, just copy the contents. | ||
| 4623 | */ | ||
| 4624 | if (pos_in == pos_out && pos_in == 0 && len == i_size_read(s_inode) && | ||
| 4625 | i_size_read(t_inode) <= len && | ||
| 4626 | (OCFS2_I(s_inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL)) { | ||
| 4627 | ret = ocfs2_duplicate_inline_data(s_inode, s_bh, t_inode, t_bh); | ||
| 4628 | if (ret) | ||
| 4629 | mlog_errno(ret); | ||
| 4630 | goto out; | ||
| 4631 | } | ||
| 4632 | |||
| 4633 | /* | ||
| 4634 | * If both inodes belong to two different refcount groups then | ||
| 4635 | * forget it because we don't know how (or want) to go merging | ||
| 4636 | * refcount trees. | ||
| 4637 | */ | ||
| 4638 | ret = -EOPNOTSUPP; | ||
| 4639 | if (ocfs2_is_refcount_inode(s_inode) && | ||
| 4640 | ocfs2_is_refcount_inode(t_inode) && | ||
| 4641 | le64_to_cpu(dis->i_refcount_loc) != | ||
| 4642 | le64_to_cpu(dit->i_refcount_loc)) | ||
| 4643 | goto out; | ||
| 4644 | |||
| 4645 | /* Neither inode has a refcount tree. Add one to s_inode. */ | ||
| 4646 | if (!ocfs2_is_refcount_inode(s_inode) && | ||
| 4647 | !ocfs2_is_refcount_inode(t_inode)) { | ||
| 4648 | ret = ocfs2_create_refcount_tree(s_inode, s_bh); | ||
| 4649 | if (ret) { | ||
| 4650 | mlog_errno(ret); | ||
| 4651 | goto out; | ||
| 4652 | } | ||
| 4653 | } | ||
| 4654 | |||
| 4655 | /* Ensure that both inodes end up with the same refcount tree. */ | ||
| 4656 | if (!ocfs2_is_refcount_inode(s_inode)) { | ||
| 4657 | ret = ocfs2_set_refcount_tree(s_inode, s_bh, | ||
| 4658 | le64_to_cpu(dit->i_refcount_loc)); | ||
| 4659 | if (ret) { | ||
| 4660 | mlog_errno(ret); | ||
| 4661 | goto out; | ||
| 4662 | } | ||
| 4663 | } | ||
| 4664 | if (!ocfs2_is_refcount_inode(t_inode)) { | ||
| 4665 | ret = ocfs2_set_refcount_tree(t_inode, t_bh, | ||
| 4666 | le64_to_cpu(dis->i_refcount_loc)); | ||
| 4667 | if (ret) { | ||
| 4668 | mlog_errno(ret); | ||
| 4669 | goto out; | ||
| 4670 | } | ||
| 4671 | } | ||
| 4672 | |||
| 4673 | /* Turn off inline data in the dest file. */ | ||
| 4674 | if (OCFS2_I(t_inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) { | ||
| 4675 | ret = ocfs2_convert_inline_data_to_extents(t_inode, t_bh); | ||
| 4676 | if (ret) { | ||
| 4677 | mlog_errno(ret); | ||
| 4678 | goto out; | ||
| 4679 | } | ||
| 4680 | } | ||
| 4681 | |||
| 4682 | /* Actually remap extents now. */ | ||
| 4683 | ret = ocfs2_reflink_remap_extent(s_inode, s_bh, pos_in, t_inode, t_bh, | ||
| 4684 | pos_out, len, &dealloc); | ||
| 4685 | if (ret) { | ||
| 4686 | mlog_errno(ret); | ||
| 4687 | goto out; | ||
| 4688 | } | ||
| 4689 | |||
| 4690 | out: | ||
| 4691 | if (ocfs2_dealloc_has_cluster(&dealloc)) { | ||
| 4692 | ocfs2_schedule_truncate_log_flush(osb, 1); | ||
| 4693 | ocfs2_run_deallocs(osb, &dealloc); | ||
| 4694 | } | ||
| 4695 | |||
| 4696 | return ret; | ||
| 4697 | } | ||
| 4698 | |||
| 4699 | /* Lock an inode and grab a bh pointing to the inode. */ | ||
| 4700 | static int ocfs2_reflink_inodes_lock(struct inode *s_inode, | ||
| 4701 | struct buffer_head **bh1, | ||
| 4702 | struct inode *t_inode, | ||
| 4703 | struct buffer_head **bh2) | ||
| 4704 | { | ||
| 4705 | struct inode *inode1; | ||
| 4706 | struct inode *inode2; | ||
| 4707 | struct ocfs2_inode_info *oi1; | ||
| 4708 | struct ocfs2_inode_info *oi2; | ||
| 4709 | bool same_inode = (s_inode == t_inode); | ||
| 4710 | int status; | ||
| 4711 | |||
| 4712 | /* First grab the VFS and rw locks. */ | ||
| 4713 | lock_two_nondirectories(s_inode, t_inode); | ||
| 4714 | inode1 = s_inode; | ||
| 4715 | inode2 = t_inode; | ||
| 4716 | if (inode1->i_ino > inode2->i_ino) | ||
| 4717 | swap(inode1, inode2); | ||
| 4718 | |||
| 4719 | status = ocfs2_rw_lock(inode1, 1); | ||
| 4720 | if (status) { | ||
| 4721 | mlog_errno(status); | ||
| 4722 | goto out_i1; | ||
| 4723 | } | ||
| 4724 | if (!same_inode) { | ||
| 4725 | status = ocfs2_rw_lock(inode2, 1); | ||
| 4726 | if (status) { | ||
| 4727 | mlog_errno(status); | ||
| 4728 | goto out_i2; | ||
| 4729 | } | ||
| 4730 | } | ||
| 4731 | |||
| 4732 | /* Now go for the cluster locks */ | ||
| 4733 | oi1 = OCFS2_I(inode1); | ||
| 4734 | oi2 = OCFS2_I(inode2); | ||
| 4735 | |||
| 4736 | trace_ocfs2_double_lock((unsigned long long)oi1->ip_blkno, | ||
| 4737 | (unsigned long long)oi2->ip_blkno); | ||
| 4738 | |||
| 4739 | if (*bh1) | ||
| 4740 | *bh1 = NULL; | ||
| 4741 | if (*bh2) | ||
| 4742 | *bh2 = NULL; | ||
| 4743 | |||
| 4744 | /* We always want to lock the one with the lower lockid first. */ | ||
| 4745 | if (oi1->ip_blkno > oi2->ip_blkno) | ||
| 4746 | mlog_errno(-ENOLCK); | ||
| 4747 | |||
| 4748 | /* lock id1 */ | ||
| 4749 | status = ocfs2_inode_lock_nested(inode1, bh1, 1, OI_LS_REFLINK_TARGET); | ||
| 4750 | if (status < 0) { | ||
| 4751 | if (status != -ENOENT) | ||
| 4752 | mlog_errno(status); | ||
| 4753 | goto out_rw2; | ||
| 4754 | } | ||
| 4755 | |||
| 4756 | /* lock id2 */ | ||
| 4757 | if (!same_inode) { | ||
| 4758 | status = ocfs2_inode_lock_nested(inode2, bh2, 1, | ||
| 4759 | OI_LS_REFLINK_TARGET); | ||
| 4760 | if (status < 0) { | ||
| 4761 | if (status != -ENOENT) | ||
| 4762 | mlog_errno(status); | ||
| 4763 | goto out_cl1; | ||
| 4764 | } | ||
| 4765 | } else | ||
| 4766 | *bh2 = *bh1; | ||
| 4767 | |||
| 4768 | trace_ocfs2_double_lock_end( | ||
| 4769 | (unsigned long long)OCFS2_I(inode1)->ip_blkno, | ||
| 4770 | (unsigned long long)OCFS2_I(inode2)->ip_blkno); | ||
| 4771 | |||
| 4772 | return 0; | ||
| 4773 | |||
| 4774 | out_cl1: | ||
| 4775 | ocfs2_inode_unlock(inode1, 1); | ||
| 4776 | brelse(*bh1); | ||
| 4777 | *bh1 = NULL; | ||
| 4778 | out_rw2: | ||
| 4779 | ocfs2_rw_unlock(inode2, 1); | ||
| 4780 | out_i2: | ||
| 4781 | ocfs2_rw_unlock(inode1, 1); | ||
| 4782 | out_i1: | ||
| 4783 | unlock_two_nondirectories(s_inode, t_inode); | ||
| 4784 | return status; | ||
| 4785 | } | ||
| 4786 | |||
| 4787 | /* Unlock both inodes and release buffers. */ | ||
| 4788 | static void ocfs2_reflink_inodes_unlock(struct inode *s_inode, | ||
| 4789 | struct buffer_head *s_bh, | ||
| 4790 | struct inode *t_inode, | ||
| 4791 | struct buffer_head *t_bh) | ||
| 4792 | { | ||
| 4793 | ocfs2_inode_unlock(s_inode, 1); | ||
| 4794 | ocfs2_rw_unlock(s_inode, 1); | ||
| 4795 | brelse(s_bh); | ||
| 4796 | if (s_inode != t_inode) { | ||
| 4797 | ocfs2_inode_unlock(t_inode, 1); | ||
| 4798 | ocfs2_rw_unlock(t_inode, 1); | ||
| 4799 | brelse(t_bh); | ||
| 4800 | } | ||
| 4801 | unlock_two_nondirectories(s_inode, t_inode); | ||
| 4802 | } | ||
| 4803 | |||
| 4804 | /* Link a range of blocks from one file to another. */ | ||
| 4805 | int ocfs2_reflink_remap_range(struct file *file_in, | ||
| 4806 | loff_t pos_in, | ||
| 4807 | struct file *file_out, | ||
| 4808 | loff_t pos_out, | ||
| 4809 | u64 len, | ||
| 4810 | bool is_dedupe) | ||
| 4811 | { | ||
| 4812 | struct inode *inode_in = file_inode(file_in); | ||
| 4813 | struct inode *inode_out = file_inode(file_out); | ||
| 4814 | struct ocfs2_super *osb = OCFS2_SB(inode_in->i_sb); | ||
| 4815 | struct buffer_head *in_bh = NULL, *out_bh = NULL; | ||
| 4816 | bool same_inode = (inode_in == inode_out); | ||
| 4817 | ssize_t ret; | ||
| 4818 | |||
| 4819 | if (!ocfs2_refcount_tree(osb)) | ||
| 4820 | return -EOPNOTSUPP; | ||
| 4821 | if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) | ||
| 4822 | return -EROFS; | ||
| 4823 | |||
| 4824 | /* Lock both files against IO */ | ||
| 4825 | ret = ocfs2_reflink_inodes_lock(inode_in, &in_bh, inode_out, &out_bh); | ||
| 4826 | if (ret) | ||
| 4827 | return ret; | ||
| 4828 | |||
| 4829 | /* Check file eligibility and prepare for block sharing. */ | ||
| 4830 | ret = -EINVAL; | ||
| 4831 | if ((OCFS2_I(inode_in)->ip_flags & OCFS2_INODE_SYSTEM_FILE) || | ||
| 4832 | (OCFS2_I(inode_out)->ip_flags & OCFS2_INODE_SYSTEM_FILE)) | ||
| 4833 | goto out_unlock; | ||
| 4834 | |||
| 4835 | ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out, | ||
| 4836 | &len, is_dedupe); | ||
| 4837 | if (ret || len == 0) | ||
| 4838 | goto out_unlock; | ||
| 4839 | |||
| 4840 | /* Lock out changes to the allocation maps and remap. */ | ||
| 4841 | down_write(&OCFS2_I(inode_in)->ip_alloc_sem); | ||
| 4842 | if (!same_inode) | ||
| 4843 | down_write_nested(&OCFS2_I(inode_out)->ip_alloc_sem, | ||
| 4844 | SINGLE_DEPTH_NESTING); | ||
| 4845 | |||
| 4846 | ret = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, inode_out, | ||
| 4847 | out_bh, pos_out, len); | ||
| 4848 | |||
| 4849 | /* Zap any page cache for the destination file's range. */ | ||
| 4850 | if (!ret) | ||
| 4851 | truncate_inode_pages_range(&inode_out->i_data, pos_out, | ||
| 4852 | PAGE_ALIGN(pos_out + len) - 1); | ||
| 4853 | |||
| 4854 | up_write(&OCFS2_I(inode_in)->ip_alloc_sem); | ||
| 4855 | if (!same_inode) | ||
| 4856 | up_write(&OCFS2_I(inode_out)->ip_alloc_sem); | ||
| 4857 | if (ret) { | ||
| 4858 | mlog_errno(ret); | ||
| 4859 | goto out_unlock; | ||
| 4860 | } | ||
| 4861 | |||
| 4862 | /* | ||
| 4863 | * Empty the extent map so that we may get the right extent | ||
| 4864 | * record from the disk. | ||
| 4865 | */ | ||
| 4866 | ocfs2_extent_map_trunc(inode_in, 0); | ||
| 4867 | ocfs2_extent_map_trunc(inode_out, 0); | ||
| 4868 | |||
| 4869 | ret = ocfs2_reflink_update_dest(inode_out, out_bh, pos_out + len); | ||
| 4870 | if (ret) { | ||
| 4871 | mlog_errno(ret); | ||
| 4872 | goto out_unlock; | ||
| 4873 | } | ||
| 4874 | |||
| 4875 | ocfs2_reflink_inodes_unlock(inode_in, in_bh, inode_out, out_bh); | ||
| 4876 | return 0; | ||
| 4877 | |||
| 4878 | out_unlock: | ||
| 4879 | ocfs2_reflink_inodes_unlock(inode_in, in_bh, inode_out, out_bh); | ||
| 4880 | return ret; | ||
| 4881 | } | ||
| @@ -115,4 +115,11 @@ int ocfs2_reflink_ioctl(struct inode *inode, · 114 unmodified lines | |||
| 115 | const char __user *oldname, | 115 | const char __user *oldname, |
| 116 | const char __user *newname, | 116 | const char __user *newname, |
| 117 | bool preserve); | 117 | bool preserve); |
| 118 | int ocfs2_reflink_remap_range(struct file *file_in, | ||
| 119 | loff_t pos_in, | ||
| 120 | struct file *file_out, | ||
| 121 | loff_t pos_out, | ||
| 122 | u64 len, | ||
| 123 | bool is_dedupe); | ||
| 124 | |||
| 118 | #endif /* OCFS2_REFCOUNTTREE_H */ | 125 | #endif /* OCFS2_REFCOUNTTREE_H */ |
| @@ -2577,7 +2577,7 @@ int ocfs2_xattr_remove(struct inode *inode, struct buffer_head *di_bh) · 2576 unmodified lines | |||
| 2577 | if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL)) | 2577 | if (!(oi->ip_dyn_features & OCFS2_HAS_XATTR_FL)) |
| 2578 | return 0; | 2578 | return 0; |
| 2579 | 2579 | ||
| 2580 | if (OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL) { | 2580 | if (ocfs2_is_refcount_inode(inode)) { |
| 2581 | ret = ocfs2_lock_refcount_tree(OCFS2_SB(inode->i_sb), | 2581 | ret = ocfs2_lock_refcount_tree(OCFS2_SB(inode->i_sb), |
| 2582 | le64_to_cpu(di->i_refcount_loc), | 2582 | le64_to_cpu(di->i_refcount_loc), |
| 2583 | 1, &ref_tree, &ref_root_bh); | 2583 | 1, &ref_tree, &ref_root_bh); |
| @@ -3608,7 +3608,7 @@ int ocfs2_xattr_set(struct inode *inode, · 1024 unmodified lines | |||
| 3608 | } | 3608 | } |
| 3609 | 3609 | ||
| 3610 | /* Check whether the value is refcounted and do some preparation. */ | 3610 | /* Check whether the value is refcounted and do some preparation. */ |
| 3611 | if (OCFS2_I(inode)->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL && | 3611 | if (ocfs2_is_refcount_inode(inode) && |
| 3612 | (!xis.not_found || !xbs.not_found)) { | 3612 | (!xis.not_found || !xbs.not_found)) { |
| 3613 | ret = ocfs2_prepare_refcount_xattr(inode, di, &xi, | 3613 | ret = ocfs2_prepare_refcount_xattr(inode, di, &xi, |
| 3614 | &xis, &xbs, &ref_tree, | 3614 | &xis, &xbs, &ref_tree, |
| @@ -2401,7 +2401,7 @@ int dquot_resume(struct super_block *sb, int type) · 2400 unmodified lines | |||
| 2401 | EXPORT_SYMBOL(dquot_resume); | 2401 | EXPORT_SYMBOL(dquot_resume); |
| 2402 | 2402 | ||
| 2403 | int dquot_quota_on(struct super_block *sb, int type, int format_id, | 2403 | int dquot_quota_on(struct super_block *sb, int type, int format_id, |
| 2404 | struct path *path) | 2404 | const struct path *path) |
| 2405 | { | 2405 | { |
| 2406 | int error = security_quota_on(path->dentry); | 2406 | int error = security_quota_on(path->dentry); |
| 2407 | if (error) | 2407 | if (error) |
| @@ -80,7 +80,7 @@ unsigned int qtype_enforce_flag(int type) · 79 unmodified lines | |||
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | static int quota_quotaon(struct super_block *sb, int type, qid_t id, | 82 | static int quota_quotaon(struct super_block *sb, int type, qid_t id, |
| 83 | struct path *path) | 83 | const struct path *path) |
| 84 | { | 84 | { |
| 85 | if (!sb->s_qcop->quota_on && !sb->s_qcop->quota_enable) | 85 | if (!sb->s_qcop->quota_on && !sb->s_qcop->quota_enable) |
| 86 | return -ENOSYS; | 86 | return -ENOSYS; |
| @@ -700,7 +700,7 @@ static int quota_rmxquota(struct super_block *sb, void __user *addr) · 613 unmodified lines | |||
| 700 | 700 | ||
| 701 | /* Copy parameters and call proper function */ | 701 | /* Copy parameters and call proper function */ |
| 702 | static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, | 702 | static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, |
| 703 | void __user *addr, struct path *path) | 703 | void __user *addr, const struct path *path) |
| 704 | { | 704 | { |
| 705 | int ret; | 705 | int ret; |
| 706 | 706 | ||
| @@ -1540,20 +1540,37 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, · 1539 unmodified lines | |||
| 1540 | 1540 | ||
| 1541 | sb_start_write(inode_out->i_sb); | 1541 | sb_start_write(inode_out->i_sb); |
| 1542 | 1542 | ||
| 1543 | ret = -EOPNOTSUPP; | 1543 | /* |
| 1544 | if (file_out->f_op->copy_file_range) | 1544 | * Try cloning first, this is supported by more file systems, and |
| 1545 | * more efficient if both clone and copy are supported (e.g. NFS). | ||
| 1546 | */ | ||
| 1547 | if (file_in->f_op->clone_file_range) { | ||
| 1548 | ret = file_in->f_op->clone_file_range(file_in, pos_in, | ||
| 1549 | file_out, pos_out, len); | ||
| 1550 | if (ret == 0) { | ||
| 1551 | ret = len; | ||
| 1552 | goto done; | ||
| 1553 | } | ||
| 1554 | } | ||
| 1555 | |||
| 1556 | if (file_out->f_op->copy_file_range) { | ||
| 1545 | ret = file_out->f_op->copy_file_range(file_in, pos_in, file_out, | 1557 | ret = file_out->f_op->copy_file_range(file_in, pos_in, file_out, |
| 1546 | pos_out, len, flags); | 1558 | pos_out, len, flags); |
| 1547 | if (ret == -EOPNOTSUPP) | 1559 | if (ret != -EOPNOTSUPP) |
| 1548 | ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out, | 1560 | goto done; |
| 1549 | len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0); | 1561 | } |
| 1562 | |||
| 1563 | ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out, | ||
| 1564 | len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0); | ||
| 1550 | 1565 | ||
| 1566 | done: | ||
| 1551 | if (ret > 0) { | 1567 | if (ret > 0) { |
| 1552 | fsnotify_access(file_in); | 1568 | fsnotify_access(file_in); |
| 1553 | add_rchar(current, ret); | 1569 | add_rchar(current, ret); |
| 1554 | fsnotify_modify(file_out); | 1570 | fsnotify_modify(file_out); |
| 1555 | add_wchar(current, ret); | 1571 | add_wchar(current, ret); |
| 1556 | } | 1572 | } |
| 1573 | |||
| 1557 | inc_syscr(current); | 1574 | inc_syscr(current); |
| 1558 | inc_syscw(current); | 1575 | inc_syscw(current); |
| 1559 | 1576 | ||
| @@ -1648,6 +1665,114 @@ static int clone_verify_area(struct file *file, loff_t pos, u64 len, bool write) · 88 unmodified lines | |||
| 1648 | return security_file_permission(file, write ? MAY_WRITE : MAY_READ); | 1665 | return security_file_permission(file, write ? MAY_WRITE : MAY_READ); |
| 1649 | } | 1666 | } |
| 1650 | 1667 | ||
| 1668 | /* | ||
| 1669 | * Check that the two inodes are eligible for cloning, the ranges make | ||
| 1670 | * sense, and then flush all dirty data. Caller must ensure that the | ||
| 1671 | * inodes have been locked against any other modifications. | ||
| 1672 | */ | ||
| 1673 | int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, | ||
| 1674 | struct inode *inode_out, loff_t pos_out, | ||
| 1675 | u64 *len, bool is_dedupe) | ||
| 1676 | { | ||
| 1677 | loff_t bs = inode_out->i_sb->s_blocksize; | ||
| 1678 | loff_t blen; | ||
| 1679 | loff_t isize; | ||
| 1680 | bool same_inode = (inode_in == inode_out); | ||
| 1681 | int ret; | ||
| 1682 | |||
| 1683 | /* Don't touch certain kinds of inodes */ | ||
| 1684 | if (IS_IMMUTABLE(inode_out)) | ||
| 1685 | return -EPERM; | ||
| 1686 | |||
| 1687 | if (IS_SWAPFILE(inode_in) || IS_SWAPFILE(inode_out)) | ||
| 1688 | return -ETXTBSY; | ||
| 1689 | |||
| 1690 | /* Don't reflink dirs, pipes, sockets... */ | ||
| 1691 | if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode)) | ||
| 1692 | return -EISDIR; | ||
| 1693 | if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) | ||
| 1694 | return -EINVAL; | ||
| 1695 | |||
| 1696 | /* Are we going all the way to the end? */ | ||
| 1697 | isize = i_size_read(inode_in); | ||
| 1698 | if (isize == 0) { | ||
| 1699 | *len = 0; | ||
| 1700 | return 0; | ||
| 1701 | } | ||
| 1702 | |||
| 1703 | /* Zero length dedupe exits immediately; reflink goes to EOF. */ | ||
| 1704 | if (*len == 0) { | ||
| 1705 | if (is_dedupe) { | ||
| 1706 | *len = 0; | ||
| 1707 | return 0; | ||
| 1708 | } | ||
| 1709 | *len = isize - pos_in; | ||
| 1710 | } | ||
| 1711 | |||
| 1712 | /* Ensure offsets don't wrap and the input is inside i_size */ | ||
| 1713 | if (pos_in + *len < pos_in || pos_out + *len < pos_out || | ||
| 1714 | pos_in + *len > isize) | ||
| 1715 | return -EINVAL; | ||
| 1716 | |||
| 1717 | /* Don't allow dedupe past EOF in the dest file */ | ||
| 1718 | if (is_dedupe) { | ||
| 1719 | loff_t disize; | ||
| 1720 | |||
| 1721 | disize = i_size_read(inode_out); | ||
| 1722 | if (pos_out >= disize || pos_out + *len > disize) | ||
| 1723 | return -EINVAL; | ||
| 1724 | } | ||
| 1725 | |||
| 1726 | /* If we're linking to EOF, continue to the block boundary. */ | ||
| 1727 | if (pos_in + *len == isize) | ||
| 1728 | blen = ALIGN(isize, bs) - pos_in; | ||
| 1729 | else | ||
| 1730 | blen = *len; | ||
| 1731 | |||
| 1732 | /* Only reflink if we're aligned to block boundaries */ | ||
| 1733 | if (!IS_ALIGNED(pos_in, bs) || !IS_ALIGNED(pos_in + blen, bs) || | ||
| 1734 | !IS_ALIGNED(pos_out, bs) || !IS_ALIGNED(pos_out + blen, bs)) | ||
| 1735 | return -EINVAL; | ||
| 1736 | |||
| 1737 | /* Don't allow overlapped reflink within the same file */ | ||
| 1738 | if (same_inode) { | ||
| 1739 | if (pos_out + blen > pos_in && pos_out < pos_in + blen) | ||
| 1740 | return -EINVAL; | ||
| 1741 | } | ||
| 1742 | |||
| 1743 | /* Wait for the completion of any pending IOs on both files */ | ||
| 1744 | inode_dio_wait(inode_in); | ||
| 1745 | if (!same_inode) | ||
| 1746 | inode_dio_wait(inode_out); | ||
| 1747 | |||
| 1748 | ret = filemap_write_and_wait_range(inode_in->i_mapping, | ||
| 1749 | pos_in, pos_in + *len - 1); | ||
| 1750 | if (ret) | ||
| 1751 | return ret; | ||
| 1752 | |||
| 1753 | ret = filemap_write_and_wait_range(inode_out->i_mapping, | ||
| 1754 | pos_out, pos_out + *len - 1); | ||
| 1755 | if (ret) | ||
| 1756 | return ret; | ||
| 1757 | |||
| 1758 | /* | ||
| 1759 | * Check that the extents are the same. | ||
| 1760 | */ | ||
| 1761 | if (is_dedupe) { | ||
| 1762 | bool is_same = false; | ||
| 1763 | |||
| 1764 | ret = vfs_dedupe_file_range_compare(inode_in, pos_in, | ||
| 1765 | inode_out, pos_out, *len, &is_same); | ||
| 1766 | if (ret) | ||
| 1767 | return ret; | ||
| 1768 | if (!is_same) | ||
| 1769 | return -EBADE; | ||
| 1770 | } | ||
| 1771 | |||
| 1772 | return 0; | ||
| 1773 | } | ||
| 1774 | EXPORT_SYMBOL(vfs_clone_file_prep_inodes); | ||
| 1775 | |||
| 1651 | int vfs_clone_file_range(struct file *file_in, loff_t pos_in, | 1776 | int vfs_clone_file_range(struct file *file_in, loff_t pos_in, |
| 1652 | struct file *file_out, loff_t pos_out, u64 len) | 1777 | struct file *file_out, loff_t pos_out, u64 len) |
| 1653 | { | 1778 | { |
| @@ -1698,6 +1823,102 @@ int vfs_clone_file_range(struct file *file_in, loff_t pos_in, · 44 unmodified lines | |||
| 1698 | } | 1823 | } |
| 1699 | EXPORT_SYMBOL(vfs_clone_file_range); | 1824 | EXPORT_SYMBOL(vfs_clone_file_range); |
| 1700 | 1825 | ||
| 1826 | /* | ||
| 1827 | * Read a page's worth of file data into the page cache. Return the page | ||
| 1828 | * locked. | ||
| 1829 | */ | ||
| 1830 | static struct page *vfs_dedupe_get_page(struct inode *inode, loff_t offset) | ||
| 1831 | { | ||
| 1832 | struct address_space *mapping; | ||
| 1833 | struct page *page; | ||
| 1834 | pgoff_t n; | ||
| 1835 | |||
| 1836 | n = offset >> PAGE_SHIFT; | ||
| 1837 | mapping = inode->i_mapping; | ||
| 1838 | page = read_mapping_page(mapping, n, NULL); | ||
| 1839 | if (IS_ERR(page)) | ||
| 1840 | return page; | ||
| 1841 | if (!PageUptodate(page)) { | ||
| 1842 | put_page(page); | ||
| 1843 | return ERR_PTR(-EIO); | ||
| 1844 | } | ||
| 1845 | lock_page(page); | ||
| 1846 | return page; | ||
| 1847 | } | ||
| 1848 | |||
| 1849 | /* | ||
| 1850 | * Compare extents of two files to see if they are the same. | ||
| 1851 | * Caller must have locked both inodes to prevent write races. | ||
| 1852 | */ | ||
| 1853 | int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, | ||
| 1854 | struct inode *dest, loff_t destoff, | ||
| 1855 | loff_t len, bool *is_same) | ||
| 1856 | { | ||
| 1857 | loff_t src_poff; | ||
| 1858 | loff_t dest_poff; | ||
| 1859 | void *src_addr; | ||
| 1860 | void *dest_addr; | ||
| 1861 | struct page *src_page; | ||
| 1862 | struct page *dest_page; | ||
| 1863 | loff_t cmp_len; | ||
| 1864 | bool same; | ||
| 1865 | int error; | ||
| 1866 | |||
| 1867 | error = -EINVAL; | ||
| 1868 | same = true; | ||
| 1869 | while (len) { | ||
| 1870 | src_poff = srcoff & (PAGE_SIZE - 1); | ||
| 1871 | dest_poff = destoff & (PAGE_SIZE - 1); | ||
| 1872 | cmp_len = min(PAGE_SIZE - src_poff, | ||
| 1873 | PAGE_SIZE - dest_poff); | ||
| 1874 | cmp_len = min(cmp_len, len); | ||
| 1875 | if (cmp_len <= 0) | ||
| 1876 | goto out_error; | ||
| 1877 | |||
| 1878 | src_page = vfs_dedupe_get_page(src, srcoff); | ||
| 1879 | if (IS_ERR(src_page)) { | ||
| 1880 | error = PTR_ERR(src_page); | ||
| 1881 | goto out_error; | ||
| 1882 | } | ||
| 1883 | dest_page = vfs_dedupe_get_page(dest, destoff); | ||
| 1884 | if (IS_ERR(dest_page)) { | ||
| 1885 | error = PTR_ERR(dest_page); | ||
| 1886 | unlock_page(src_page); | ||
| 1887 | put_page(src_page); | ||
| 1888 | goto out_error; | ||
| 1889 | } | ||
| 1890 | src_addr = kmap_atomic(src_page); | ||
| 1891 | dest_addr = kmap_atomic(dest_page); | ||
| 1892 | |||
| 1893 | flush_dcache_page(src_page); | ||
| 1894 | flush_dcache_page(dest_page); | ||
| 1895 | |||
| 1896 | if (memcmp(src_addr + src_poff, dest_addr + dest_poff, cmp_len)) | ||
| 1897 | same = false; | ||
| 1898 | |||
| 1899 | kunmap_atomic(dest_addr); | ||
| 1900 | kunmap_atomic(src_addr); | ||
| 1901 | unlock_page(dest_page); | ||
| 1902 | unlock_page(src_page); | ||
| 1903 | put_page(dest_page); | ||
| 1904 | put_page(src_page); | ||
| 1905 | |||
| 1906 | if (!same) | ||
| 1907 | break; | ||
| 1908 | |||
| 1909 | srcoff += cmp_len; | ||
| 1910 | destoff += cmp_len; | ||
| 1911 | len -= cmp_len; | ||
| 1912 | } | ||
| 1913 | |||
| 1914 | *is_same = same; | ||
| 1915 | return 0; | ||
| 1916 | |||
| 1917 | out_error: | ||
| 1918 | return error; | ||
| 1919 | } | ||
| 1920 | EXPORT_SYMBOL(vfs_dedupe_file_range_compare); | ||
| 1921 | |||
| 1701 | int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) | 1922 | int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) |
| 1702 | { | 1923 | { |
| 1703 | struct file_dedupe_range_info *info; | 1924 | struct file_dedupe_range_info *info; |
| @@ -802,7 +802,7 @@ static int reiserfs_acquire_dquot(struct dquot *); · 801 unmodified lines | |||
| 802 | static int reiserfs_release_dquot(struct dquot *); | 802 | static int reiserfs_release_dquot(struct dquot *); |
| 803 | static int reiserfs_mark_dquot_dirty(struct dquot *); | 803 | static int reiserfs_mark_dquot_dirty(struct dquot *); |
| 804 | static int reiserfs_write_info(struct super_block *, int); | 804 | static int reiserfs_write_info(struct super_block *, int); |
| 805 | static int reiserfs_quota_on(struct super_block *, int, int, struct path *); | 805 | static int reiserfs_quota_on(struct super_block *, int, int, const struct path *); |
| 806 | 806 | ||
| 807 | static const struct dquot_operations reiserfs_quota_operations = { | 807 | static const struct dquot_operations reiserfs_quota_operations = { |
| 808 | .write_dquot = reiserfs_write_dquot, | 808 | .write_dquot = reiserfs_write_dquot, |
| @@ -2348,7 +2348,7 @@ static int reiserfs_quota_on_mount(struct super_block *sb, int type) · 1539 unmodified lines | |||
| 2348 | * Standard function to be called on quota_on | 2348 | * Standard function to be called on quota_on |
| 2349 | */ | 2349 | */ |
| 2350 | static int reiserfs_quota_on(struct super_block *sb, int type, int format_id, | 2350 | static int reiserfs_quota_on(struct super_block *sb, int type, int format_id, |
| 2351 | struct path *path) | 2351 | const struct path *path) |
| 2352 | { | 2352 | { |
| 2353 | int err; | 2353 | int err; |
| 2354 | struct inode *inode; | 2354 | struct inode *inode; |
| @@ -63,7 +63,7 @@ static int statfs_by_dentry(struct dentry *dentry, struct kstatfs *buf) · 62 unmodified lines | |||
| 63 | return retval; | 63 | return retval; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | int vfs_statfs(struct path *path, struct kstatfs *buf) | 66 | int vfs_statfs(const struct path *path, struct kstatfs *buf) |
| 67 | { | 67 | { |
| 68 | int error; | 68 | int error; |
| 69 | 69 | ||
| @@ -48,7 +48,7 @@ static bool nsec_valid(long nsec) · 47 unmodified lines | |||
| 48 | return nsec >= 0 && nsec <= 999999999; | 48 | return nsec >= 0 && nsec <= 999999999; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | static int utimes_common(struct path *path, struct timespec *times) | 51 | static int utimes_common(const struct path *path, struct timespec *times) |
| 52 | { | 52 | { |
| 53 | int error; | 53 | int error; |
| 54 | struct iattr newattrs; | 54 | struct iattr newattrs; |
| @@ -848,24 +848,6 @@ out_unlock: · 847 unmodified lines | |||
| 848 | return error; | 848 | return error; |
| 849 | } | 849 | } |
| 850 | 850 | ||
| 851 | STATIC ssize_t | ||
| 852 | xfs_file_copy_range( | ||
| 853 | struct file *file_in, | ||
| 854 | loff_t pos_in, | ||
| 855 | struct file *file_out, | ||
| 856 | loff_t pos_out, | ||
| 857 | size_t len, | ||
| 858 | unsigned int flags) | ||
| 859 | { | ||
| 860 | int error; | ||
| 861 | |||
| 862 | error = xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, | ||
| 863 | len, false); | ||
| 864 | if (error) | ||
| 865 | return error; | ||
| 866 | return len; | ||
| 867 | } | ||
| 868 | |||
| 869 | STATIC int | 851 | STATIC int |
| 870 | xfs_file_clone_range( | 852 | xfs_file_clone_range( |
| 871 | struct file *file_in, | 853 | struct file *file_in, |
| @@ -1549,7 +1531,6 @@ const struct file_operations xfs_file_operations = { · 677 unmodified lines | |||
| 1549 | .fsync = xfs_file_fsync, | 1531 | .fsync = xfs_file_fsync, |
| 1550 | .get_unmapped_area = thp_get_unmapped_area, | 1532 | .get_unmapped_area = thp_get_unmapped_area, |
| 1551 | .fallocate = xfs_file_fallocate, | 1533 | .fallocate = xfs_file_fallocate, |
| 1552 | .copy_file_range = xfs_file_copy_range, | ||
| 1553 | .clone_file_range = xfs_file_clone_range, | 1534 | .clone_file_range = xfs_file_clone_range, |
| 1554 | .dedupe_file_range = xfs_file_dedupe_range, | 1535 | .dedupe_file_range = xfs_file_dedupe_range, |
| 1555 | }; | 1536 | }; |
| @@ -1113,111 +1113,6 @@ err: · 1112 unmodified lines | |||
| 1113 | return error; | 1113 | return error; |
| 1114 | } | 1114 | } |
| 1115 | 1115 | ||
| 1116 | /* | ||
| 1117 | * Read a page's worth of file data into the page cache. Return the page | ||
| 1118 | * locked. | ||
| 1119 | */ | ||
| 1120 | static struct page * | ||
| 1121 | xfs_get_page( | ||
| 1122 | struct inode *inode, | ||
| 1123 | xfs_off_t offset) | ||
| 1124 | { | ||
| 1125 | struct address_space *mapping; | ||
| 1126 | struct page *page; | ||
| 1127 | pgoff_t n; | ||
| 1128 | |||
| 1129 | n = offset >> PAGE_SHIFT; | ||
| 1130 | mapping = inode->i_mapping; | ||
| 1131 | page = read_mapping_page(mapping, n, NULL); | ||
| 1132 | if (IS_ERR(page)) | ||
| 1133 | return page; | ||
| 1134 | if (!PageUptodate(page)) { | ||
| 1135 | put_page(page); | ||
| 1136 | return ERR_PTR(-EIO); | ||
| 1137 | } | ||
| 1138 | lock_page(page); | ||
| 1139 | return page; | ||
| 1140 | } | ||
| 1141 | |||
| 1142 | /* | ||
| 1143 | * Compare extents of two files to see if they are the same. | ||
| 1144 | */ | ||
| 1145 | static int | ||
| 1146 | xfs_compare_extents( | ||
| 1147 | struct inode *src, | ||
| 1148 | xfs_off_t srcoff, | ||
| 1149 | struct inode *dest, | ||
| 1150 | xfs_off_t destoff, | ||
| 1151 | xfs_off_t len, | ||
| 1152 | bool *is_same) | ||
| 1153 | { | ||
| 1154 | xfs_off_t src_poff; | ||
| 1155 | xfs_off_t dest_poff; | ||
| 1156 | void *src_addr; | ||
| 1157 | void *dest_addr; | ||
| 1158 | struct page *src_page; | ||
| 1159 | struct page *dest_page; | ||
| 1160 | xfs_off_t cmp_len; | ||
| 1161 | bool same; | ||
| 1162 | int error; | ||
| 1163 | |||
| 1164 | error = -EINVAL; | ||
| 1165 | same = true; | ||
| 1166 | while (len) { | ||
| 1167 | src_poff = srcoff & (PAGE_SIZE - 1); | ||
| 1168 | dest_poff = destoff & (PAGE_SIZE - 1); | ||
| 1169 | cmp_len = min(PAGE_SIZE - src_poff, | ||
| 1170 | PAGE_SIZE - dest_poff); | ||
| 1171 | cmp_len = min(cmp_len, len); | ||
| 1172 | ASSERT(cmp_len > 0); | ||
| 1173 | |||
| 1174 | trace_xfs_reflink_compare_extents(XFS_I(src), srcoff, cmp_len, | ||
| 1175 | XFS_I(dest), destoff); | ||
| 1176 | |||
| 1177 | src_page = xfs_get_page(src, srcoff); | ||
| 1178 | if (IS_ERR(src_page)) { | ||
| 1179 | error = PTR_ERR(src_page); | ||
| 1180 | goto out_error; | ||
| 1181 | } | ||
| 1182 | dest_page = xfs_get_page(dest, destoff); | ||
| 1183 | if (IS_ERR(dest_page)) { | ||
| 1184 | error = PTR_ERR(dest_page); | ||
| 1185 | unlock_page(src_page); | ||
| 1186 | put_page(src_page); | ||
| 1187 | goto out_error; | ||
| 1188 | } | ||
| 1189 | src_addr = kmap_atomic(src_page); | ||
| 1190 | dest_addr = kmap_atomic(dest_page); | ||
| 1191 | |||
| 1192 | flush_dcache_page(src_page); | ||
| 1193 | flush_dcache_page(dest_page); | ||
| 1194 | |||
| 1195 | if (memcmp(src_addr + src_poff, dest_addr + dest_poff, cmp_len)) | ||
| 1196 | same = false; | ||
| 1197 | |||
| 1198 | kunmap_atomic(dest_addr); | ||
| 1199 | kunmap_atomic(src_addr); | ||
| 1200 | unlock_page(dest_page); | ||
| 1201 | unlock_page(src_page); | ||
| 1202 | put_page(dest_page); | ||
| 1203 | put_page(src_page); | ||
| 1204 | |||
| 1205 | if (!same) | ||
| 1206 | break; | ||
| 1207 | |||
| 1208 | srcoff += cmp_len; | ||
| 1209 | destoff += cmp_len; | ||
| 1210 | len -= cmp_len; | ||
| 1211 | } | ||
| 1212 | |||
| 1213 | *is_same = same; | ||
| 1214 | return 0; | ||
| 1215 | |||
| 1216 | out_error: | ||
| 1217 | trace_xfs_reflink_compare_extents_error(XFS_I(dest), error, _RET_IP_); | ||
| 1218 | return error; | ||
| 1219 | } | ||
| 1220 | |||
| 1221 | /* | 1116 | /* |
| 1222 | * Link a range of blocks from one file to another. | 1117 | * Link a range of blocks from one file to another. |
| 1223 | */ | 1118 | */ |
| @@ -1235,14 +1130,11 @@ xfs_reflink_remap_range( · 11 unmodified lines | |||
| 1235 | struct inode *inode_out = file_inode(file_out); | 1130 | struct inode *inode_out = file_inode(file_out); |
| 1236 | struct xfs_inode *dest = XFS_I(inode_out); | 1131 | struct xfs_inode *dest = XFS_I(inode_out); |
| 1237 | struct xfs_mount *mp = src->i_mount; | 1132 | struct xfs_mount *mp = src->i_mount; |
| 1238 | loff_t bs = inode_out->i_sb->s_blocksize; | ||
| 1239 | bool same_inode = (inode_in == inode_out); | 1133 | bool same_inode = (inode_in == inode_out); |
| 1240 | xfs_fileoff_t sfsbno, dfsbno; | 1134 | xfs_fileoff_t sfsbno, dfsbno; |
| 1241 | xfs_filblks_t fsblen; | 1135 | xfs_filblks_t fsblen; |
| 1242 | xfs_extlen_t cowextsize; | 1136 | xfs_extlen_t cowextsize; |
| 1243 | loff_t isize; | ||
| 1244 | ssize_t ret; | 1137 | ssize_t ret; |
| 1245 | loff_t blen; | ||
| 1246 | 1138 | ||
| 1247 | if (!xfs_sb_version_hasreflink(&mp->m_sb)) | 1139 | if (!xfs_sb_version_hasreflink(&mp->m_sb)) |
| 1248 | return -EOPNOTSUPP; | 1140 | return -EOPNOTSUPP; |
| @@ -1257,26 +1149,8 @@ xfs_reflink_remap_range( · 8 unmodified lines | |||
| 1257 | else | 1149 | else |
| 1258 | xfs_lock_two_inodes(src, dest, XFS_MMAPLOCK_EXCL); | 1150 | xfs_lock_two_inodes(src, dest, XFS_MMAPLOCK_EXCL); |
| 1259 | 1151 | ||
| 1260 | /* Don't touch certain kinds of inodes */ | 1152 | /* Check file eligibility and prepare for block sharing. */ |
| 1261 | ret = -EPERM; | ||
| 1262 | if (IS_IMMUTABLE(inode_out)) | ||
| 1263 | goto out_unlock; | ||
| 1264 | |||
| 1265 | ret = -ETXTBSY; | ||
| 1266 | if (IS_SWAPFILE(inode_in) || IS_SWAPFILE(inode_out)) | ||
| 1267 | goto out_unlock; | ||
| 1268 | |||
| 1269 | |||
| 1270 | /* Don't reflink dirs, pipes, sockets... */ | ||
| 1271 | ret = -EISDIR; | ||
| 1272 | if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode)) | ||
| 1273 | goto out_unlock; | ||
| 1274 | ret = -EINVAL; | 1153 | ret = -EINVAL; |
| 1275 | if (S_ISFIFO(inode_in->i_mode) || S_ISFIFO(inode_out->i_mode)) | ||
| 1276 | goto out_unlock; | ||
| 1277 | if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) | ||
| 1278 | goto out_unlock; | ||
| 1279 | |||
| 1280 | /* Don't reflink realtime inodes */ | 1154 | /* Don't reflink realtime inodes */ |
| 1281 | if (XFS_IS_REALTIME_INODE(src) || XFS_IS_REALTIME_INODE(dest)) | 1155 | if (XFS_IS_REALTIME_INODE(src) || XFS_IS_REALTIME_INODE(dest)) |
| 1282 | goto out_unlock; | 1156 | goto out_unlock; |
| @@ -1285,97 +1159,18 @@ xfs_reflink_remap_range( · 2 unmodified lines | |||
| 1285 | if (IS_DAX(inode_in) || IS_DAX(inode_out)) | 1159 | if (IS_DAX(inode_in) || IS_DAX(inode_out)) |
| 1286 | goto out_unlock; | 1160 | goto out_unlock; |
| 1287 | 1161 | ||
| 1288 | /* Are we going all the way to the end? */ | 1162 | ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out, |
| 1289 | isize = i_size_read(inode_in); | 1163 | &len, is_dedupe); |
| 1290 | if (isize == 0) { | 1164 | if (ret || len == 0) |
| 1291 | ret = 0; | ||
| 1292 | goto out_unlock; | ||
| 1293 | } | ||
| 1294 | |||
| 1295 | /* Zero length dedupe exits immediately; reflink goes to EOF. */ | ||
| 1296 | if (len == 0) { | ||
| 1297 | if (is_dedupe) { | ||
| 1298 | ret = 0; | ||
| 1299 | goto out_unlock; | ||
| 1300 | } | ||
| 1301 | len = isize - pos_in; | ||
| 1302 | } | ||
| 1303 | |||
| 1304 | /* Ensure offsets don't wrap and the input is inside i_size */ | ||
| 1305 | if (pos_in + len < pos_in || pos_out + len < pos_out || | ||
| 1306 | pos_in + len > isize) | ||
| 1307 | goto out_unlock; | ||
| 1308 | |||
| 1309 | /* Don't allow dedupe past EOF in the dest file */ | ||
| 1310 | if (is_dedupe) { | ||
| 1311 | loff_t disize; | ||
| 1312 | |||
| 1313 | disize = i_size_read(inode_out); | ||
| 1314 | if (pos_out >= disize || pos_out + len > disize) | ||
| 1315 | goto out_unlock; | ||
| 1316 | } | ||
| 1317 | |||
| 1318 | /* If we're linking to EOF, continue to the block boundary. */ | ||
| 1319 | if (pos_in + len == isize) | ||
| 1320 | blen = ALIGN(isize, bs) - pos_in; | ||
| 1321 | else | ||
| 1322 | blen = len; | ||
| 1323 | |||
| 1324 | /* Only reflink if we're aligned to block boundaries */ | ||
| 1325 | if (!IS_ALIGNED(pos_in, bs) || !IS_ALIGNED(pos_in + blen, bs) || | ||
| 1326 | !IS_ALIGNED(pos_out, bs) || !IS_ALIGNED(pos_out + blen, bs)) | ||
| 1327 | goto out_unlock; | ||
| 1328 | |||
| 1329 | /* Don't allow overlapped reflink within the same file */ | ||
| 1330 | if (same_inode) { | ||
| 1331 | if (pos_out + blen > pos_in && pos_out < pos_in + blen) | ||
| 1332 | goto out_unlock; | ||
| 1333 | } | ||
| 1334 | |||
| 1335 | /* Wait for the completion of any pending IOs on both files */ | ||
| 1336 | inode_dio_wait(inode_in); | ||
| 1337 | if (!same_inode) | ||
| 1338 | inode_dio_wait(inode_out); | ||
| 1339 | |||
| 1340 | ret = filemap_write_and_wait_range(inode_in->i_mapping, | ||
| 1341 | pos_in, pos_in + len - 1); | ||
| 1342 | if (ret) | ||
| 1343 | goto out_unlock; | ||
| 1344 | |||
| 1345 | ret = filemap_write_and_wait_range(inode_out->i_mapping, | ||
| 1346 | pos_out, pos_out + len - 1); | ||
| 1347 | if (ret) | ||
| 1348 | goto out_unlock; | 1165 | goto out_unlock; |
| 1349 | 1166 | ||
| 1350 | trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); | 1167 | trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); |
| 1351 | 1168 | ||
| 1352 | /* | 1169 | /* Set flags and remap blocks. */ |
| 1353 | * Check that the extents are the same. | ||
| 1354 | */ | ||
| 1355 | if (is_dedupe) { | ||
| 1356 | bool is_same = false; | ||
| 1357 | |||
| 1358 | ret = xfs_compare_extents(inode_in, pos_in, inode_out, pos_out, | ||
| 1359 | len, &is_same); | ||
| 1360 | if (ret) | ||
| 1361 | goto out_unlock; | ||
| 1362 | if (!is_same) { | ||
| 1363 | ret = -EBADE; | ||
| 1364 | goto out_unlock; | ||
| 1365 | } | ||
| 1366 | } | ||
| 1367 | |||
| 1368 | ret = xfs_reflink_set_inode_flag(src, dest); | 1170 | ret = xfs_reflink_set_inode_flag(src, dest); |
| 1369 | if (ret) | 1171 | if (ret) |
| 1370 | goto out_unlock; | 1172 | goto out_unlock; |
| 1371 | 1173 | ||
| 1372 | /* | ||
| 1373 | * Invalidate the page cache so that we can clear any CoW mappings | ||
| 1374 | * in the destination file. | ||
| 1375 | */ | ||
| 1376 | truncate_inode_pages_range(&inode_out->i_data, pos_out, | ||
| 1377 | PAGE_ALIGN(pos_out + len) - 1); | ||
| 1378 | |||
| 1379 | dfsbno = XFS_B_TO_FSBT(mp, pos_out); | 1174 | dfsbno = XFS_B_TO_FSBT(mp, pos_out); |
| 1380 | sfsbno = XFS_B_TO_FSBT(mp, pos_in); | 1175 | sfsbno = XFS_B_TO_FSBT(mp, pos_in); |
| 1381 | fsblen = XFS_B_TO_FSB(mp, len); | 1176 | fsblen = XFS_B_TO_FSB(mp, len); |
| @@ -1384,6 +1179,10 @@ xfs_reflink_remap_range( · 2 unmodified lines | |||
| 1384 | if (ret) | 1179 | if (ret) |
| 1385 | goto out_unlock; | 1180 | goto out_unlock; |
| 1386 | 1181 | ||
| 1182 | /* Zap any page cache for the destination file's range. */ | ||
| 1183 | truncate_inode_pages_range(&inode_out->i_data, pos_out, | ||
| 1184 | PAGE_ALIGN(pos_out + len) - 1); | ||
| 1185 | |||
| 1387 | /* | 1186 | /* |
| 1388 | * Carry the cowextsize hint from src to dest if we're sharing the | 1187 | * Carry the cowextsize hint from src to dest if we're sharing the |
| 1389 | * entire source file to the entire destination file, the source file | 1188 | * entire source file to the entire destination file, the source file |
| @@ -147,7 +147,7 @@ extern void audit_log_d_path(struct audit_buffer *ab, · 146 unmodified lines | |||
| 147 | extern void audit_log_key(struct audit_buffer *ab, | 147 | extern void audit_log_key(struct audit_buffer *ab, |
| 148 | char *key); | 148 | char *key); |
| 149 | extern void audit_log_link_denied(const char *operation, | 149 | extern void audit_log_link_denied(const char *operation, |
| 150 | struct path *link); | 150 | const struct path *link); |
| 151 | extern void audit_log_lost(const char *message); | 151 | extern void audit_log_lost(const char *message); |
| 152 | #ifdef CONFIG_SECURITY | 152 | #ifdef CONFIG_SECURITY |
| 153 | extern void audit_log_secctx(struct audit_buffer *ab, u32 secid); | 153 | extern void audit_log_secctx(struct audit_buffer *ab, u32 secid); |
| @@ -139,7 +139,7 @@ struct dentry_operations { · 138 unmodified lines | |||
| 139 | void (*d_iput)(struct dentry *, struct inode *); | 139 | void (*d_iput)(struct dentry *, struct inode *); |
| 140 | char *(*d_dname)(struct dentry *, char *, int); | 140 | char *(*d_dname)(struct dentry *, char *, int); |
| 141 | struct vfsmount *(*d_automount)(struct path *); | 141 | struct vfsmount *(*d_automount)(struct path *); |
| 142 | int (*d_manage)(struct dentry *, bool); | 142 | int (*d_manage)(const struct path *, bool); |
| 143 | struct dentry *(*d_real)(struct dentry *, const struct inode *, | 143 | struct dentry *(*d_real)(struct dentry *, const struct inode *, |
| 144 | unsigned int); | 144 | unsigned int); |
| 145 | } ____cacheline_aligned; | 145 | } ____cacheline_aligned; |
| @@ -254,7 +254,7 @@ extern struct dentry *d_find_alias(struct inode *); · 108 unmodified lines | |||
| 254 | extern void d_prune_aliases(struct inode *); | 254 | extern void d_prune_aliases(struct inode *); |
| 255 | 255 | ||
| 256 | /* test whether we have any submounts in a subdir tree */ | 256 | /* test whether we have any submounts in a subdir tree */ |
| 257 | extern int have_submounts(struct dentry *); | 257 | extern int path_has_submounts(const struct path *); |
| 258 | 258 | ||
| 259 | /* | 259 | /* |
| 260 | * This adds the entry to the hash queues. | 260 | * This adds the entry to the hash queues. |
| @@ -44,7 +44,7 @@ void dcookie_unregister(struct dcookie_user * user); · 43 unmodified lines | |||
| 44 | * | 44 | * |
| 45 | * Returns 0 on success, with *cookie filled in | 45 | * Returns 0 on success, with *cookie filled in |
| 46 | */ | 46 | */ |
| 47 | int get_dcookie(struct path *path, unsigned long *cookie); | 47 | int get_dcookie(const struct path *path, unsigned long *cookie); |
| 48 | 48 | ||
| 49 | #else | 49 | #else |
| 50 | 50 | ||
| @@ -58,7 +58,7 @@ static inline void dcookie_unregister(struct dcookie_user * user) · 7 unmodified lines | |||
| 58 | return; | 58 | return; |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | static inline int get_dcookie(struct path *path, unsigned long *cookie) | 61 | static inline int get_dcookie(const struct path *path, unsigned long *cookie) |
| 62 | { | 62 | { |
| 63 | return -ENOSYS; | 63 | return -ENOSYS; |
| 64 | } | 64 | } |
| @@ -17,7 +17,7 @@ struct file_operations; · 16 unmodified lines | |||
| 17 | struct vfsmount; | 17 | struct vfsmount; |
| 18 | struct dentry; | 18 | struct dentry; |
| 19 | struct path; | 19 | struct path; |
| 20 | extern struct file *alloc_file(struct path *, fmode_t mode, | 20 | extern struct file *alloc_file(const struct path *, fmode_t mode, |
| 21 | const struct file_operations *fop); | 21 | const struct file_operations *fop); |
| 22 | 22 | ||
| 23 | static inline void fput_light(struct file *file, int fput_needed) | 23 | static inline void fput_light(struct file *file, int fput_needed) |
| @@ -1726,8 +1726,14 @@ extern ssize_t vfs_writev(struct file *, const struct iovec __user *, · 1725 unmodified lines | |||
| 1726 | unsigned long, loff_t *, int); | 1726 | unsigned long, loff_t *, int); |
| 1727 | extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, | 1727 | extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, |
| 1728 | loff_t, size_t, unsigned int); | 1728 | loff_t, size_t, unsigned int); |
| 1729 | extern int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, | ||
| 1730 | struct inode *inode_out, loff_t pos_out, | ||
| 1731 | u64 *len, bool is_dedupe); | ||
| 1729 | extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in, | 1732 | extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in, |
| 1730 | struct file *file_out, loff_t pos_out, u64 len); | 1733 | struct file *file_out, loff_t pos_out, u64 len); |
| 1734 | extern int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, | ||
| 1735 | struct inode *dest, loff_t destoff, | ||
| 1736 | loff_t len, bool *is_same); | ||
| 1731 | extern int vfs_dedupe_file_range(struct file *file, | 1737 | extern int vfs_dedupe_file_range(struct file *file, |
| 1732 | struct file_dedupe_range *same); | 1738 | struct file_dedupe_range *same); |
| 1733 | 1739 | ||
| @@ -2084,11 +2090,11 @@ extern int may_umount_tree(struct vfsmount *); · 350 unmodified lines | |||
| 2084 | extern int may_umount(struct vfsmount *); | 2090 | extern int may_umount(struct vfsmount *); |
| 2085 | extern long do_mount(const char *, const char __user *, | 2091 | extern long do_mount(const char *, const char __user *, |
| 2086 | const char *, unsigned long, void *); | 2092 | const char *, unsigned long, void *); |
| 2087 | extern struct vfsmount *collect_mounts(struct path *); | 2093 | extern struct vfsmount *collect_mounts(const struct path *); |
| 2088 | extern void drop_collected_mounts(struct vfsmount *); | 2094 | extern void drop_collected_mounts(struct vfsmount *); |
| 2089 | extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *, | 2095 | extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *, |
| 2090 | struct vfsmount *); | 2096 | struct vfsmount *); |
| 2091 | extern int vfs_statfs(struct path *, struct kstatfs *); | 2097 | extern int vfs_statfs(const struct path *, struct kstatfs *); |
| 2092 | extern int user_statfs(const char __user *, struct kstatfs *); | 2098 | extern int user_statfs(const char __user *, struct kstatfs *); |
| 2093 | extern int fd_statfs(int, struct kstatfs *); | 2099 | extern int fd_statfs(int, struct kstatfs *); |
| 2094 | extern int vfs_ustat(dev_t, struct kstatfs *); | 2100 | extern int vfs_ustat(dev_t, struct kstatfs *); |
| @@ -2657,7 +2663,7 @@ extern struct file * open_exec(const char *); · 562 unmodified lines | |||
| 2657 | 2663 | ||
| 2658 | /* fs/dcache.c -- generic fs support functions */ | 2664 | /* fs/dcache.c -- generic fs support functions */ |
| 2659 | extern bool is_subdir(struct dentry *, struct dentry *); | 2665 | extern bool is_subdir(struct dentry *, struct dentry *); |
| 2660 | extern bool path_is_under(struct path *, struct path *); | 2666 | extern bool path_is_under(const struct path *, const struct path *); |
| 2661 | 2667 | ||
| 2662 | extern char *file_path(struct file *, char *, int); | 2668 | extern char *file_path(struct file *, char *, int); |
| 2663 | 2669 | ||
| @@ -17,7 +17,7 @@ · 16 unmodified lines | |||
| 17 | #include <linux/bug.h> | 17 | #include <linux/bug.h> |
| 18 | 18 | ||
| 19 | /* Notify this dentry's parent about a child's events. */ | 19 | /* Notify this dentry's parent about a child's events. */ |
| 20 | static inline int fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) | 20 | static inline int fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask) |
| 21 | { | 21 | { |
| 22 | if (!dentry) | 22 | if (!dentry) |
| 23 | dentry = path->dentry; | 23 | dentry = path->dentry; |
| @@ -28,7 +28,7 @@ static inline int fsnotify_parent(struct path *path, struct dentry *dentry, __u3 · 4 unmodified lines | |||
| 28 | /* simple call site for access decisions */ | 28 | /* simple call site for access decisions */ |
| 29 | static inline int fsnotify_perm(struct file *file, int mask) | 29 | static inline int fsnotify_perm(struct file *file, int mask) |
| 30 | { | 30 | { |
| 31 | struct path *path = &file->f_path; | 31 | const struct path *path = &file->f_path; |
| 32 | /* | 32 | /* |
| 33 | * Do not use file_inode() here or anywhere in this file to get the | 33 | * Do not use file_inode() here or anywhere in this file to get the |
| 34 | * inode. That would break *notity on overlayfs. | 34 | * inode. That would break *notity on overlayfs. |
| @@ -176,7 +176,7 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry) · 141 unmodified lines | |||
| 176 | */ | 176 | */ |
| 177 | static inline void fsnotify_access(struct file *file) | 177 | static inline void fsnotify_access(struct file *file) |
| 178 | { | 178 | { |
| 179 | struct path *path = &file->f_path; | 179 | const struct path *path = &file->f_path; |
| 180 | struct inode *inode = path->dentry->d_inode; | 180 | struct inode *inode = path->dentry->d_inode; |
| 181 | __u32 mask = FS_ACCESS; | 181 | __u32 mask = FS_ACCESS; |
| 182 | 182 | ||
| @@ -194,7 +194,7 @@ static inline void fsnotify_access(struct file *file) · 11 unmodified lines | |||
| 194 | */ | 194 | */ |
| 195 | static inline void fsnotify_modify(struct file *file) | 195 | static inline void fsnotify_modify(struct file *file) |
| 196 | { | 196 | { |
| 197 | struct path *path = &file->f_path; | 197 | const struct path *path = &file->f_path; |
| 198 | struct inode *inode = path->dentry->d_inode; | 198 | struct inode *inode = path->dentry->d_inode; |
| 199 | __u32 mask = FS_MODIFY; | 199 | __u32 mask = FS_MODIFY; |
| 200 | 200 | ||
| @@ -212,7 +212,7 @@ static inline void fsnotify_modify(struct file *file) · 11 unmodified lines | |||
| 212 | */ | 212 | */ |
| 213 | static inline void fsnotify_open(struct file *file) | 213 | static inline void fsnotify_open(struct file *file) |
| 214 | { | 214 | { |
| 215 | struct path *path = &file->f_path; | 215 | const struct path *path = &file->f_path; |
| 216 | struct inode *inode = path->dentry->d_inode; | 216 | struct inode *inode = path->dentry->d_inode; |
| 217 | __u32 mask = FS_OPEN; | 217 | __u32 mask = FS_OPEN; |
| 218 | 218 | ||
| @@ -228,7 +228,7 @@ static inline void fsnotify_open(struct file *file) · 9 unmodified lines | |||
| 228 | */ | 228 | */ |
| 229 | static inline void fsnotify_close(struct file *file) | 229 | static inline void fsnotify_close(struct file *file) |
| 230 | { | 230 | { |
| 231 | struct path *path = &file->f_path; | 231 | const struct path *path = &file->f_path; |
| 232 | struct inode *inode = path->dentry->d_inode; | 232 | struct inode *inode = path->dentry->d_inode; |
| 233 | fmode_t mode = file->f_mode; | 233 | fmode_t mode = file->f_mode; |
| 234 | __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; | 234 | __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; |
| @@ -96,7 +96,7 @@ struct fsnotify_ops { · 95 unmodified lines | |||
| 96 | struct inode *inode, | 96 | struct inode *inode, |
| 97 | struct fsnotify_mark *inode_mark, | 97 | struct fsnotify_mark *inode_mark, |
| 98 | struct fsnotify_mark *vfsmount_mark, | 98 | struct fsnotify_mark *vfsmount_mark, |
| 99 | u32 mask, void *data, int data_type, | 99 | u32 mask, const void *data, int data_type, |
| 100 | const unsigned char *file_name, u32 cookie); | 100 | const unsigned char *file_name, u32 cookie); |
| 101 | void (*free_group_priv)(struct fsnotify_group *group); | 101 | void (*free_group_priv)(struct fsnotify_group *group); |
| 102 | void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group); | 102 | void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group); |
| @@ -245,9 +245,9 @@ struct fsnotify_mark { · 142 unmodified lines | |||
| 245 | /* called from the vfs helpers */ | 245 | /* called from the vfs helpers */ |
| 246 | 246 | ||
| 247 | /* main fsnotify call to send events */ | 247 | /* main fsnotify call to send events */ |
| 248 | extern int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, | 248 | extern int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, |
| 249 | const unsigned char *name, u32 cookie); | 249 | const unsigned char *name, u32 cookie); |
| 250 | extern int __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask); | 250 | extern int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask); |
| 251 | extern void __fsnotify_inode_delete(struct inode *inode); | 251 | extern void __fsnotify_inode_delete(struct inode *inode); |
| 252 | extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt); | 252 | extern void __fsnotify_vfsmount_delete(struct vfsmount *mnt); |
| 253 | extern u32 fsnotify_get_cookie(void); | 253 | extern u32 fsnotify_get_cookie(void); |
| @@ -357,13 +357,13 @@ extern void fsnotify_init_event(struct fsnotify_event *event, · 103 unmodified lines | |||
| 357 | 357 | ||
| 358 | #else | 358 | #else |
| 359 | 359 | ||
| 360 | static inline int fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, | 360 | static inline int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is, |
| 361 | const unsigned char *name, u32 cookie) | 361 | const unsigned char *name, u32 cookie) |
| 362 | { | 362 | { |
| 363 | return 0; | 363 | return 0; |
| 364 | } | 364 | } |
| 365 | 365 | ||
| 366 | static inline int __fsnotify_parent(struct path *path, struct dentry *dentry, __u32 mask) | 366 | static inline int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask) |
| 367 | { | 367 | { |
| 368 | return 0; | 368 | return 0; |
| 369 | } | 369 | } |
| @@ -79,12 +79,12 @@ extern void mnt_drop_write(struct vfsmount *mnt); · 78 unmodified lines | |||
| 79 | extern void mnt_drop_write_file(struct file *file); | 79 | extern void mnt_drop_write_file(struct file *file); |
| 80 | extern void mntput(struct vfsmount *mnt); | 80 | extern void mntput(struct vfsmount *mnt); |
| 81 | extern struct vfsmount *mntget(struct vfsmount *mnt); | 81 | extern struct vfsmount *mntget(struct vfsmount *mnt); |
| 82 | extern struct vfsmount *mnt_clone_internal(struct path *path); | 82 | extern struct vfsmount *mnt_clone_internal(const struct path *path); |
| 83 | extern int __mnt_is_readonly(struct vfsmount *mnt); | 83 | extern int __mnt_is_readonly(struct vfsmount *mnt); |
| 84 | extern bool mnt_may_suid(struct vfsmount *mnt); | 84 | extern bool mnt_may_suid(struct vfsmount *mnt); |
| 85 | 85 | ||
| 86 | struct path; | 86 | struct path; |
| 87 | extern struct vfsmount *clone_private_mount(struct path *path); | 87 | extern struct vfsmount *clone_private_mount(const struct path *path); |
| 88 | 88 | ||
| 89 | struct file_system_type; | 89 | struct file_system_type; |
| 90 | extern struct vfsmount *vfs_kern_mount(struct file_system_type *type, | 90 | extern struct vfsmount *vfs_kern_mount(struct file_system_type *type, |
| @@ -98,4 +98,6 @@ extern dev_t name_to_dev_t(const char *name); · 7 unmodified lines | |||
| 98 | 98 | ||
| 99 | extern unsigned int sysctl_mount_max; | 99 | extern unsigned int sysctl_mount_max; |
| 100 | 100 | ||
| 101 | extern bool path_is_mountpoint(const struct path *path); | ||
| 102 | |||
| 101 | #endif /* _LINUX_MOUNT_H */ | 103 | #endif /* _LINUX_MOUNT_H */ |
| @@ -431,7 +431,7 @@ struct qc_info { · 430 unmodified lines | |||
| 431 | 431 | ||
| 432 | /* Operations handling requests from userspace */ | 432 | /* Operations handling requests from userspace */ |
| 433 | struct quotactl_ops { | 433 | struct quotactl_ops { |
| 434 | int (*quota_on)(struct super_block *, int, int, struct path *); | 434 | int (*quota_on)(struct super_block *, int, int, const struct path *); |
| 435 | int (*quota_off)(struct super_block *, int); | 435 | int (*quota_off)(struct super_block *, int); |
| 436 | int (*quota_enable)(struct super_block *, unsigned int); | 436 | int (*quota_enable)(struct super_block *, unsigned int); |
| 437 | int (*quota_disable)(struct super_block *, unsigned int); | 437 | int (*quota_disable)(struct super_block *, unsigned int); |
| @@ -90,7 +90,7 @@ int dquot_file_open(struct inode *inode, struct file *file); · 89 unmodified lines | |||
| 90 | int dquot_enable(struct inode *inode, int type, int format_id, | 90 | int dquot_enable(struct inode *inode, int type, int format_id, |
| 91 | unsigned int flags); | 91 | unsigned int flags); |
| 92 | int dquot_quota_on(struct super_block *sb, int type, int format_id, | 92 | int dquot_quota_on(struct super_block *sb, int type, int format_id, |
| 93 | struct path *path); | 93 | const struct path *path); |
| 94 | int dquot_quota_on_mount(struct super_block *sb, char *qf_name, | 94 | int dquot_quota_on_mount(struct super_block *sb, char *qf_name, |
| 95 | int format_id, int type); | 95 | int format_id, int type); |
| 96 | int dquot_quota_off(struct super_block *sb, int type); | 96 | int dquot_quota_off(struct super_block *sb, int type); |
| @@ -1893,7 +1893,7 @@ void audit_copy_inode(struct audit_names *name, const struct dentry *dentry, · 1892 unmodified lines | |||
| 1893 | * @call_panic: optional pointer to int that will be updated if secid fails | 1893 | * @call_panic: optional pointer to int that will be updated if secid fails |
| 1894 | */ | 1894 | */ |
| 1895 | void audit_log_name(struct audit_context *context, struct audit_names *n, | 1895 | void audit_log_name(struct audit_context *context, struct audit_names *n, |
| 1896 | struct path *path, int record_num, int *call_panic) | 1896 | const struct path *path, int record_num, int *call_panic) |
| 1897 | { | 1897 | { |
| 1898 | struct audit_buffer *ab; | 1898 | struct audit_buffer *ab; |
| 1899 | ab = audit_log_start(context, GFP_KERNEL, AUDIT_PATH); | 1899 | ab = audit_log_start(context, GFP_KERNEL, AUDIT_PATH); |
| @@ -2081,7 +2081,7 @@ EXPORT_SYMBOL(audit_log_task_info); · 181 unmodified lines | |||
| 2081 | * @operation: specific link operation | 2081 | * @operation: specific link operation |
| 2082 | * @link: the path that triggered the restriction | 2082 | * @link: the path that triggered the restriction |
| 2083 | */ | 2083 | */ |
| 2084 | void audit_log_link_denied(const char *operation, struct path *link) | 2084 | void audit_log_link_denied(const char *operation, const struct path *link) |
| 2085 | { | 2085 | { |
| 2086 | struct audit_buffer *ab; | 2086 | struct audit_buffer *ab; |
| 2087 | struct audit_names *name; | 2087 | struct audit_names *name; |
| @@ -212,7 +212,7 @@ extern void audit_copy_inode(struct audit_names *name, · 211 unmodified lines | |||
| 212 | extern void audit_log_cap(struct audit_buffer *ab, char *prefix, | 212 | extern void audit_log_cap(struct audit_buffer *ab, char *prefix, |
| 213 | kernel_cap_t *cap); | 213 | kernel_cap_t *cap); |
| 214 | extern void audit_log_name(struct audit_context *context, | 214 | extern void audit_log_name(struct audit_context *context, |
| 215 | struct audit_names *n, struct path *path, | 215 | struct audit_names *n, const struct path *path, |
| 216 | int record_num, int *call_panic); | 216 | int record_num, int *call_panic); |
| 217 | 217 | ||
| 218 | extern int audit_pid; | 218 | extern int audit_pid; |
| @@ -74,7 +74,7 @@ int audit_mark_compare(struct audit_fsnotify_mark *mark, unsigned long ino, dev_ · 73 unmodified lines | |||
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | static void audit_update_mark(struct audit_fsnotify_mark *audit_mark, | 76 | static void audit_update_mark(struct audit_fsnotify_mark *audit_mark, |
| 77 | struct inode *inode) | 77 | const struct inode *inode) |
| 78 | { | 78 | { |
| 79 | audit_mark->dev = inode ? inode->i_sb->s_dev : AUDIT_DEV_UNSET; | 79 | audit_mark->dev = inode ? inode->i_sb->s_dev : AUDIT_DEV_UNSET; |
| 80 | audit_mark->ino = inode ? inode->i_ino : AUDIT_INO_UNSET; | 80 | audit_mark->ino = inode ? inode->i_ino : AUDIT_INO_UNSET; |
| @@ -167,11 +167,11 @@ static int audit_mark_handle_event(struct fsnotify_group *group, · 86 unmodified lines | |||
| 167 | struct inode *to_tell, | 167 | struct inode *to_tell, |
| 168 | struct fsnotify_mark *inode_mark, | 168 | struct fsnotify_mark *inode_mark, |
| 169 | struct fsnotify_mark *vfsmount_mark, | 169 | struct fsnotify_mark *vfsmount_mark, |
| 170 | u32 mask, void *data, int data_type, | 170 | u32 mask, const void *data, int data_type, |
| 171 | const unsigned char *dname, u32 cookie) | 171 | const unsigned char *dname, u32 cookie) |
| 172 | { | 172 | { |
| 173 | struct audit_fsnotify_mark *audit_mark; | 173 | struct audit_fsnotify_mark *audit_mark; |
| 174 | struct inode *inode = NULL; | 174 | const struct inode *inode = NULL; |
| 175 | 175 | ||
| 176 | audit_mark = container_of(inode_mark, struct audit_fsnotify_mark, mark); | 176 | audit_mark = container_of(inode_mark, struct audit_fsnotify_mark, mark); |
| 177 | 177 | ||
| @@ -179,10 +179,10 @@ static int audit_mark_handle_event(struct fsnotify_group *group, · 1 unmodified line | |||
| 179 | 179 | ||
| 180 | switch (data_type) { | 180 | switch (data_type) { |
| 181 | case (FSNOTIFY_EVENT_PATH): | 181 | case (FSNOTIFY_EVENT_PATH): |
| 182 | inode = ((struct path *)data)->dentry->d_inode; | 182 | inode = ((const struct path *)data)->dentry->d_inode; |
| 183 | break; | 183 | break; |
| 184 | case (FSNOTIFY_EVENT_INODE): | 184 | case (FSNOTIFY_EVENT_INODE): |
| 185 | inode = (struct inode *)data; | 185 | inode = (const struct inode *)data; |
| 186 | break; | 186 | break; |
| 187 | default: | 187 | default: |
| 188 | BUG(); | 188 | BUG(); |
| @@ -947,7 +947,7 @@ static int audit_tree_handle_event(struct fsnotify_group *group, · 946 unmodified lines | |||
| 947 | struct inode *to_tell, | 947 | struct inode *to_tell, |
| 948 | struct fsnotify_mark *inode_mark, | 948 | struct fsnotify_mark *inode_mark, |
| 949 | struct fsnotify_mark *vfsmount_mark, | 949 | struct fsnotify_mark *vfsmount_mark, |
| 950 | u32 mask, void *data, int data_type, | 950 | u32 mask, const void *data, int data_type, |
| 951 | const unsigned char *file_name, u32 cookie) | 951 | const unsigned char *file_name, u32 cookie) |
| 952 | { | 952 | { |
| 953 | return 0; | 953 | return 0; |
| @@ -471,10 +471,10 @@ static int audit_watch_handle_event(struct fsnotify_group *group, · 470 unmodified lines | |||
| 471 | struct inode *to_tell, | 471 | struct inode *to_tell, |
| 472 | struct fsnotify_mark *inode_mark, | 472 | struct fsnotify_mark *inode_mark, |
| 473 | struct fsnotify_mark *vfsmount_mark, | 473 | struct fsnotify_mark *vfsmount_mark, |
| 474 | u32 mask, void *data, int data_type, | 474 | u32 mask, const void *data, int data_type, |
| 475 | const unsigned char *dname, u32 cookie) | 475 | const unsigned char *dname, u32 cookie) |
| 476 | { | 476 | { |
| 477 | struct inode *inode; | 477 | const struct inode *inode; |
| 478 | struct audit_parent *parent; | 478 | struct audit_parent *parent; |
| 479 | 479 | ||
| 480 | parent = container_of(inode_mark, struct audit_parent, mark); | 480 | parent = container_of(inode_mark, struct audit_parent, mark); |
| @@ -483,10 +483,10 @@ static int audit_watch_handle_event(struct fsnotify_group *group, · 2 unmodified lines | |||
| 483 | 483 | ||
| 484 | switch (data_type) { | 484 | switch (data_type) { |
| 485 | case (FSNOTIFY_EVENT_PATH): | 485 | case (FSNOTIFY_EVENT_PATH): |
| 486 | inode = d_backing_inode(((struct path *)data)->dentry); | 486 | inode = d_backing_inode(((const struct path *)data)->dentry); |
| 487 | break; | 487 | break; |
| 488 | case (FSNOTIFY_EVENT_INODE): | 488 | case (FSNOTIFY_EVENT_INODE): |
| 489 | inode = (struct inode *)data; | 489 | inode = (const struct inode *)data; |
| 490 | break; | 490 | break; |
| 491 | default: | 491 | default: |
| 492 | BUG(); | 492 | BUG(); |