diff options
Diffstat (limited to 'fs')
266 files changed, 9185 insertions, 6785 deletions
| @@ -711,10 +711,8 @@ static ssize_t aio_run_iocb(struct kiocb *iocb) | |||
| 711 | */ | 711 | */ |
| 712 | ret = retry(iocb); | 712 | ret = retry(iocb); |
| 713 | 713 | ||
| 714 | if (ret != -EIOCBRETRY && ret != -EIOCBQUEUED) { | 714 | if (ret != -EIOCBRETRY && ret != -EIOCBQUEUED) |
| 715 | BUG_ON(!list_empty(&iocb->ki_wait.task_list)); | ||
| 716 | aio_complete(iocb, ret, 0); | 715 | aio_complete(iocb, ret, 0); |
| 717 | } | ||
| 718 | out: | 716 | out: |
| 719 | spin_lock_irq(&ctx->ctx_lock); | 717 | spin_lock_irq(&ctx->ctx_lock); |
| 720 | 718 | ||
| @@ -866,13 +864,6 @@ static void try_queue_kicked_iocb(struct kiocb *iocb) | |||
| 866 | unsigned long flags; | 864 | unsigned long flags; |
| 867 | int run = 0; | 865 | int run = 0; |
| 868 | 866 | ||
| 869 | /* We're supposed to be the only path putting the iocb back on the run | ||
| 870 | * list. If we find that the iocb is *back* on a wait queue already | ||
| 871 | * than retry has happened before we could queue the iocb. This also | ||
| 872 | * means that the retry could have completed and freed our iocb, no | ||
| 873 | * good. */ | ||
| 874 | BUG_ON((!list_empty(&iocb->ki_wait.task_list))); | ||
| 875 | |||
| 876 | spin_lock_irqsave(&ctx->ctx_lock, flags); | 867 | spin_lock_irqsave(&ctx->ctx_lock, flags); |
| 877 | /* set this inside the lock so that we can't race with aio_run_iocb() | 868 | /* set this inside the lock so that we can't race with aio_run_iocb() |
| 878 | * testing it and putting the iocb on the run list under the lock */ | 869 | * testing it and putting the iocb on the run list under the lock */ |
| @@ -886,7 +877,7 @@ static void try_queue_kicked_iocb(struct kiocb *iocb) | |||
| 886 | /* | 877 | /* |
| 887 | * kick_iocb: | 878 | * kick_iocb: |
| 888 | * Called typically from a wait queue callback context | 879 | * Called typically from a wait queue callback context |
| 889 | * (aio_wake_function) to trigger a retry of the iocb. | 880 | * to trigger a retry of the iocb. |
| 890 | * The retry is usually executed by aio workqueue | 881 | * The retry is usually executed by aio workqueue |
| 891 | * threads (See aio_kick_handler). | 882 | * threads (See aio_kick_handler). |
| 892 | */ | 883 | */ |
| @@ -1520,31 +1511,6 @@ static ssize_t aio_setup_iocb(struct kiocb *kiocb) | |||
| 1520 | return 0; | 1511 | return 0; |
| 1521 | } | 1512 | } |
| 1522 | 1513 | ||
| 1523 | /* | ||
| 1524 | * aio_wake_function: | ||
| 1525 | * wait queue callback function for aio notification, | ||
| 1526 | * Simply triggers a retry of the operation via kick_iocb. | ||
| 1527 | * | ||
| 1528 | * This callback is specified in the wait queue entry in | ||
| 1529 | * a kiocb. | ||
| 1530 | * | ||
| 1531 | * Note: | ||
| 1532 | * This routine is executed with the wait queue lock held. | ||
| 1533 | * Since kick_iocb acquires iocb->ctx->ctx_lock, it nests | ||
| 1534 | * the ioctx lock inside the wait queue lock. This is safe | ||
| 1535 | * because this callback isn't used for wait queues which | ||
| 1536 | * are nested inside ioctx lock (i.e. ctx->wait) | ||
| 1537 | */ | ||
| 1538 | static int aio_wake_function(wait_queue_t *wait, unsigned mode, | ||
| 1539 | int sync, void *key) | ||
| 1540 | { | ||
| 1541 | struct kiocb *iocb = container_of(wait, struct kiocb, ki_wait); | ||
| 1542 | |||
| 1543 | list_del_init(&wait->task_list); | ||
| 1544 | kick_iocb(iocb); | ||
| 1545 | return 1; | ||
| 1546 | } | ||
| 1547 | |||
| 1548 | static void aio_batch_add(struct address_space *mapping, | 1514 | static void aio_batch_add(struct address_space *mapping, |
| 1549 | struct hlist_head *batch_hash) | 1515 | struct hlist_head *batch_hash) |
| 1550 | { | 1516 | { |
| @@ -1642,8 +1608,6 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, | |||
| 1642 | req->ki_buf = (char __user *)(unsigned long)iocb->aio_buf; | 1608 | req->ki_buf = (char __user *)(unsigned long)iocb->aio_buf; |
| 1643 | req->ki_left = req->ki_nbytes = iocb->aio_nbytes; | 1609 | req->ki_left = req->ki_nbytes = iocb->aio_nbytes; |
| 1644 | req->ki_opcode = iocb->aio_lio_opcode; | 1610 | req->ki_opcode = iocb->aio_lio_opcode; |
| 1645 | init_waitqueue_func_entry(&req->ki_wait, aio_wake_function); | ||
| 1646 | INIT_LIST_HEAD(&req->ki_wait.task_list); | ||
| 1647 | 1611 | ||
| 1648 | ret = aio_setup_iocb(req); | 1612 | ret = aio_setup_iocb(req); |
| 1649 | 1613 | ||
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c index 2ca7a7cafdbf..2c994591f4d7 100644 --- a/fs/anon_inodes.c +++ b/fs/anon_inodes.c | |||
| @@ -35,14 +35,13 @@ static int anon_inodefs_get_sb(struct file_system_type *fs_type, int flags, | |||
| 35 | mnt); | 35 | mnt); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | static int anon_inodefs_delete_dentry(struct dentry *dentry) | 38 | /* |
| 39 | * anon_inodefs_dname() is called from d_path(). | ||
| 40 | */ | ||
| 41 | static char *anon_inodefs_dname(struct dentry *dentry, char *buffer, int buflen) | ||
| 39 | { | 42 | { |
| 40 | /* | 43 | return dynamic_dname(dentry, buffer, buflen, "anon_inode:%s", |
| 41 | * We faked vfs to believe the dentry was hashed when we created it. | 44 | dentry->d_name.name); |
| 42 | * Now we restore the flag so that dput() will work correctly. | ||
| 43 | */ | ||
| 44 | dentry->d_flags |= DCACHE_UNHASHED; | ||
| 45 | return 1; | ||
| 46 | } | 45 | } |
| 47 | 46 | ||
| 48 | static struct file_system_type anon_inode_fs_type = { | 47 | static struct file_system_type anon_inode_fs_type = { |
| @@ -51,7 +50,7 @@ static struct file_system_type anon_inode_fs_type = { | |||
| 51 | .kill_sb = kill_anon_super, | 50 | .kill_sb = kill_anon_super, |
| 52 | }; | 51 | }; |
| 53 | static const struct dentry_operations anon_inodefs_dentry_operations = { | 52 | static const struct dentry_operations anon_inodefs_dentry_operations = { |
| 54 | .d_delete = anon_inodefs_delete_dentry, | 53 | .d_dname = anon_inodefs_dname, |
| 55 | }; | 54 | }; |
| 56 | 55 | ||
| 57 | /* | 56 | /* |
| @@ -88,7 +87,7 @@ struct file *anon_inode_getfile(const char *name, | |||
| 88 | void *priv, int flags) | 87 | void *priv, int flags) |
| 89 | { | 88 | { |
| 90 | struct qstr this; | 89 | struct qstr this; |
| 91 | struct dentry *dentry; | 90 | struct path path; |
| 92 | struct file *file; | 91 | struct file *file; |
| 93 | int error; | 92 | int error; |
| 94 | 93 | ||
| @@ -106,10 +105,11 @@ struct file *anon_inode_getfile(const char *name, | |||
| 106 | this.name = name; | 105 | this.name = name; |
| 107 | this.len = strlen(name); | 106 | this.len = strlen(name); |
| 108 | this.hash = 0; | 107 | this.hash = 0; |
| 109 | dentry = d_alloc(anon_inode_mnt->mnt_sb->s_root, &this); | 108 | path.dentry = d_alloc(anon_inode_mnt->mnt_sb->s_root, &this); |
| 110 | if (!dentry) | 109 | if (!path.dentry) |
| 111 | goto err_module; | 110 | goto err_module; |
| 112 | 111 | ||
| 112 | path.mnt = mntget(anon_inode_mnt); | ||
| 113 | /* | 113 | /* |
| 114 | * We know the anon_inode inode count is always greater than zero, | 114 | * We know the anon_inode inode count is always greater than zero, |
| 115 | * so we can avoid doing an igrab() and we can use an open-coded | 115 | * so we can avoid doing an igrab() and we can use an open-coded |
| @@ -117,14 +117,11 @@ struct file *anon_inode_getfile(const char *name, | |||
| 117 | */ | 117 | */ |
| 118 | atomic_inc(&anon_inode_inode->i_count); | 118 | atomic_inc(&anon_inode_inode->i_count); |
| 119 | 119 | ||
| 120 | dentry->d_op = &anon_inodefs_dentry_operations; | 120 | path.dentry->d_op = &anon_inodefs_dentry_operations; |
| 121 | /* Do not publish this dentry inside the global dentry hash table */ | 121 | d_instantiate(path.dentry, anon_inode_inode); |
| 122 | dentry->d_flags &= ~DCACHE_UNHASHED; | ||
| 123 | d_instantiate(dentry, anon_inode_inode); | ||
| 124 | 122 | ||
| 125 | error = -ENFILE; | 123 | error = -ENFILE; |
| 126 | file = alloc_file(anon_inode_mnt, dentry, | 124 | file = alloc_file(&path, FMODE_READ | FMODE_WRITE, fops); |
| 127 | FMODE_READ | FMODE_WRITE, fops); | ||
| 128 | if (!file) | 125 | if (!file) |
| 129 | goto err_dput; | 126 | goto err_dput; |
| 130 | file->f_mapping = anon_inode_inode->i_mapping; | 127 | file->f_mapping = anon_inode_inode->i_mapping; |
| @@ -137,7 +134,7 @@ struct file *anon_inode_getfile(const char *name, | |||
| 137 | return file; | 134 | return file; |
| 138 | 135 | ||
| 139 | err_dput: | 136 | err_dput: |
| 140 | dput(dentry); | 137 | path_put(&path); |
| 141 | err_module: | 138 | err_module: |
| 142 | module_put(fops->owner); | 139 | module_put(fops->owner); |
| 143 | return ERR_PTR(error); | 140 | return ERR_PTR(error); |
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h index 8f7cdde41733..0118d67221b2 100644 --- a/fs/autofs4/autofs_i.h +++ b/fs/autofs4/autofs_i.h | |||
| @@ -60,6 +60,11 @@ do { \ | |||
| 60 | current->pid, __func__, ##args); \ | 60 | current->pid, __func__, ##args); \ |
| 61 | } while (0) | 61 | } while (0) |
| 62 | 62 | ||
| 63 | struct rehash_entry { | ||
| 64 | struct task_struct *task; | ||
| 65 | struct list_head list; | ||
| 66 | }; | ||
| 67 | |||
| 63 | /* Unified info structure. This is pointed to by both the dentry and | 68 | /* Unified info structure. This is pointed to by both the dentry and |
| 64 | inode structures. Each file in the filesystem has an instance of this | 69 | inode structures. Each file in the filesystem has an instance of this |
| 65 | structure. It holds a reference to the dentry, so dentries are never | 70 | structure. It holds a reference to the dentry, so dentries are never |
| @@ -75,6 +80,9 @@ struct autofs_info { | |||
| 75 | struct completion expire_complete; | 80 | struct completion expire_complete; |
| 76 | 81 | ||
| 77 | struct list_head active; | 82 | struct list_head active; |
| 83 | int active_count; | ||
| 84 | struct list_head rehash_list; | ||
| 85 | |||
| 78 | struct list_head expiring; | 86 | struct list_head expiring; |
| 79 | 87 | ||
| 80 | struct autofs_sb_info *sbi; | 88 | struct autofs_sb_info *sbi; |
| @@ -95,6 +103,8 @@ struct autofs_info { | |||
| 95 | 103 | ||
| 96 | #define AUTOFS_INF_EXPIRING (1<<0) /* dentry is in the process of expiring */ | 104 | #define AUTOFS_INF_EXPIRING (1<<0) /* dentry is in the process of expiring */ |
| 97 | #define AUTOFS_INF_MOUNTPOINT (1<<1) /* mountpoint status for direct expire */ | 105 | #define AUTOFS_INF_MOUNTPOINT (1<<1) /* mountpoint status for direct expire */ |
| 106 | #define AUTOFS_INF_PENDING (1<<2) /* dentry pending mount */ | ||
| 107 | #define AUTOFS_INF_REHASH (1<<3) /* dentry in transit to ->lookup() */ | ||
| 98 | 108 | ||
| 99 | struct autofs_wait_queue { | 109 | struct autofs_wait_queue { |
| 100 | wait_queue_head_t queue; | 110 | wait_queue_head_t queue; |
| @@ -161,7 +171,7 @@ static inline int autofs4_ispending(struct dentry *dentry) | |||
| 161 | { | 171 | { |
| 162 | struct autofs_info *inf = autofs4_dentry_ino(dentry); | 172 | struct autofs_info *inf = autofs4_dentry_ino(dentry); |
| 163 | 173 | ||
| 164 | if (dentry->d_flags & DCACHE_AUTOFS_PENDING) | 174 | if (inf->flags & AUTOFS_INF_PENDING) |
| 165 | return 1; | 175 | return 1; |
| 166 | 176 | ||
| 167 | if (inf->flags & AUTOFS_INF_EXPIRING) | 177 | if (inf->flags & AUTOFS_INF_EXPIRING) |
| @@ -264,5 +274,31 @@ out: | |||
| 264 | return ret; | 274 | return ret; |
| 265 | } | 275 | } |
| 266 | 276 | ||
| 277 | static inline void autofs4_add_expiring(struct dentry *dentry) | ||
| 278 | { | ||
| 279 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | ||
| 280 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | ||
| 281 | if (ino) { | ||
| 282 | spin_lock(&sbi->lookup_lock); | ||
| 283 | if (list_empty(&ino->expiring)) | ||
| 284 | list_add(&ino->expiring, &sbi->expiring_list); | ||
| 285 | spin_unlock(&sbi->lookup_lock); | ||
| 286 | } | ||
| 287 | return; | ||
| 288 | } | ||
| 289 | |||
| 290 | static inline void autofs4_del_expiring(struct dentry *dentry) | ||
| 291 | { | ||
| 292 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | ||
| 293 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | ||
| 294 | if (ino) { | ||
| 295 | spin_lock(&sbi->lookup_lock); | ||
| 296 | if (!list_empty(&ino->expiring)) | ||
| 297 | list_del_init(&ino->expiring); | ||
| 298 | spin_unlock(&sbi->lookup_lock); | ||
| 299 | } | ||
| 300 | return; | ||
| 301 | } | ||
| 302 | |||
| 267 | void autofs4_dentry_release(struct dentry *); | 303 | void autofs4_dentry_release(struct dentry *); |
| 268 | extern void autofs4_kill_sb(struct super_block *); | 304 | extern void autofs4_kill_sb(struct super_block *); |
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c index 3da18d453488..74bc9aa6df31 100644 --- a/fs/autofs4/expire.c +++ b/fs/autofs4/expire.c | |||
| @@ -27,7 +27,7 @@ static inline int autofs4_can_expire(struct dentry *dentry, | |||
| 27 | return 0; | 27 | return 0; |
| 28 | 28 | ||
| 29 | /* No point expiring a pending mount */ | 29 | /* No point expiring a pending mount */ |
| 30 | if (dentry->d_flags & DCACHE_AUTOFS_PENDING) | 30 | if (ino->flags & AUTOFS_INF_PENDING) |
| 31 | return 0; | 31 | return 0; |
| 32 | 32 | ||
| 33 | if (!do_now) { | 33 | if (!do_now) { |
| @@ -279,6 +279,7 @@ struct dentry *autofs4_expire_direct(struct super_block *sb, | |||
| 279 | root->d_mounted--; | 279 | root->d_mounted--; |
| 280 | } | 280 | } |
| 281 | ino->flags |= AUTOFS_INF_EXPIRING; | 281 | ino->flags |= AUTOFS_INF_EXPIRING; |
| 282 | autofs4_add_expiring(root); | ||
| 282 | init_completion(&ino->expire_complete); | 283 | init_completion(&ino->expire_complete); |
| 283 | spin_unlock(&sbi->fs_lock); | 284 | spin_unlock(&sbi->fs_lock); |
| 284 | return root; | 285 | return root; |
| @@ -406,6 +407,7 @@ found: | |||
| 406 | expired, (int)expired->d_name.len, expired->d_name.name); | 407 | expired, (int)expired->d_name.len, expired->d_name.name); |
| 407 | ino = autofs4_dentry_ino(expired); | 408 | ino = autofs4_dentry_ino(expired); |
| 408 | ino->flags |= AUTOFS_INF_EXPIRING; | 409 | ino->flags |= AUTOFS_INF_EXPIRING; |
| 410 | autofs4_add_expiring(expired); | ||
| 409 | init_completion(&ino->expire_complete); | 411 | init_completion(&ino->expire_complete); |
| 410 | spin_unlock(&sbi->fs_lock); | 412 | spin_unlock(&sbi->fs_lock); |
| 411 | spin_lock(&dcache_lock); | 413 | spin_lock(&dcache_lock); |
| @@ -433,7 +435,7 @@ int autofs4_expire_wait(struct dentry *dentry) | |||
| 433 | 435 | ||
| 434 | DPRINTK("expire done status=%d", status); | 436 | DPRINTK("expire done status=%d", status); |
| 435 | 437 | ||
| 436 | if (d_unhashed(dentry)) | 438 | if (d_unhashed(dentry) && IS_DEADDIR(dentry->d_inode)) |
| 437 | return -EAGAIN; | 439 | return -EAGAIN; |
| 438 | 440 | ||
| 439 | return status; | 441 | return status; |
| @@ -473,6 +475,7 @@ int autofs4_expire_run(struct super_block *sb, | |||
| 473 | spin_lock(&sbi->fs_lock); | 475 | spin_lock(&sbi->fs_lock); |
| 474 | ino = autofs4_dentry_ino(dentry); | 476 | ino = autofs4_dentry_ino(dentry); |
| 475 | ino->flags &= ~AUTOFS_INF_EXPIRING; | 477 | ino->flags &= ~AUTOFS_INF_EXPIRING; |
| 478 | autofs4_del_expiring(dentry); | ||
| 476 | complete_all(&ino->expire_complete); | 479 | complete_all(&ino->expire_complete); |
| 477 | spin_unlock(&sbi->fs_lock); | 480 | spin_unlock(&sbi->fs_lock); |
| 478 | 481 | ||
| @@ -503,6 +506,7 @@ int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt, | |||
| 503 | ino->flags &= ~AUTOFS_INF_MOUNTPOINT; | 506 | ino->flags &= ~AUTOFS_INF_MOUNTPOINT; |
| 504 | } | 507 | } |
| 505 | ino->flags &= ~AUTOFS_INF_EXPIRING; | 508 | ino->flags &= ~AUTOFS_INF_EXPIRING; |
| 509 | autofs4_del_expiring(dentry); | ||
| 506 | complete_all(&ino->expire_complete); | 510 | complete_all(&ino->expire_complete); |
| 507 | spin_unlock(&sbi->fs_lock); | 511 | spin_unlock(&sbi->fs_lock); |
| 508 | dput(dentry); | 512 | dput(dentry); |
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c index 69c8142da838..d0a3de247458 100644 --- a/fs/autofs4/inode.c +++ b/fs/autofs4/inode.c | |||
| @@ -49,6 +49,8 @@ struct autofs_info *autofs4_init_ino(struct autofs_info *ino, | |||
| 49 | ino->dentry = NULL; | 49 | ino->dentry = NULL; |
| 50 | ino->size = 0; | 50 | ino->size = 0; |
| 51 | INIT_LIST_HEAD(&ino->active); | 51 | INIT_LIST_HEAD(&ino->active); |
| 52 | INIT_LIST_HEAD(&ino->rehash_list); | ||
| 53 | ino->active_count = 0; | ||
| 52 | INIT_LIST_HEAD(&ino->expiring); | 54 | INIT_LIST_HEAD(&ino->expiring); |
| 53 | atomic_set(&ino->count, 0); | 55 | atomic_set(&ino->count, 0); |
| 54 | } | 56 | } |
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c index b96a3c57359d..30cc9ddf4b70 100644 --- a/fs/autofs4/root.c +++ b/fs/autofs4/root.c | |||
| @@ -72,6 +72,139 @@ const struct inode_operations autofs4_dir_inode_operations = { | |||
| 72 | .rmdir = autofs4_dir_rmdir, | 72 | .rmdir = autofs4_dir_rmdir, |
| 73 | }; | 73 | }; |
| 74 | 74 | ||
| 75 | static void autofs4_add_active(struct dentry *dentry) | ||
| 76 | { | ||
| 77 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | ||
| 78 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | ||
| 79 | if (ino) { | ||
| 80 | spin_lock(&sbi->lookup_lock); | ||
| 81 | if (!ino->active_count) { | ||
| 82 | if (list_empty(&ino->active)) | ||
| 83 | list_add(&ino->active, &sbi->active_list); | ||
| 84 | } | ||
| 85 | ino->active_count++; | ||
| 86 | spin_unlock(&sbi->lookup_lock); | ||
| 87 | } | ||
| 88 | return; | ||
| 89 | } | ||
| 90 | |||
| 91 | static void autofs4_del_active(struct dentry *dentry) | ||
| 92 | { | ||
| 93 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | ||
| 94 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | ||
| 95 | if (ino) { | ||
| 96 | spin_lock(&sbi->lookup_lock); | ||
| 97 | ino->active_count--; | ||
| 98 | if (!ino->active_count) { | ||
| 99 | if (!list_empty(&ino->active)) | ||
| 100 | list_del_init(&ino->active); | ||
| 101 | } | ||
| 102 | spin_unlock(&sbi->lookup_lock); | ||
| 103 | } | ||
| 104 | return; | ||
| 105 | } | ||
| 106 | |||
| 107 | static void autofs4_add_rehash_entry(struct autofs_info *ino, | ||
| 108 | struct rehash_entry *entry) | ||
| 109 | { | ||
| 110 | entry->task = current; | ||
| 111 | INIT_LIST_HEAD(&entry->list); | ||
| 112 | list_add(&entry->list, &ino->rehash_list); | ||
| 113 | return; | ||
| 114 | } | ||
| 115 | |||
| 116 | static void autofs4_remove_rehash_entry(struct autofs_info *ino) | ||
| 117 | { | ||
| 118 | struct list_head *head = &ino->rehash_list; | ||
| 119 | struct rehash_entry *entry; | ||
| 120 | list_for_each_entry(entry, head, list) { | ||
| 121 | if (entry->task == current) { | ||
| 122 | list_del(&entry->list); | ||
| 123 | kfree(entry); | ||
| 124 | break; | ||
| 125 | } | ||
| 126 | } | ||
| 127 | return; | ||
| 128 | } | ||
| 129 | |||
| 130 | static void autofs4_remove_rehash_entrys(struct autofs_info *ino) | ||
| 131 | { | ||
| 132 | struct autofs_sb_info *sbi = ino->sbi; | ||
| 133 | struct rehash_entry *entry, *next; | ||
| 134 | struct list_head *head; | ||
| 135 | |||
| 136 | spin_lock(&sbi->fs_lock); | ||
| 137 | spin_lock(&sbi->lookup_lock); | ||
| 138 | if (!(ino->flags & AUTOFS_INF_REHASH)) { | ||
| 139 | spin_unlock(&sbi->lookup_lock); | ||
| 140 | spin_unlock(&sbi->fs_lock); | ||
| 141 | return; | ||
| 142 | } | ||
| 143 | ino->flags &= ~AUTOFS_INF_REHASH; | ||
| 144 | head = &ino->rehash_list; | ||
| 145 | list_for_each_entry_safe(entry, next, head, list) { | ||
| 146 | list_del(&entry->list); | ||
| 147 | kfree(entry); | ||
| 148 | } | ||
| 149 | spin_unlock(&sbi->lookup_lock); | ||
| 150 | spin_unlock(&sbi->fs_lock); | ||
| 151 | dput(ino->dentry); | ||
| 152 | |||
| 153 | return; | ||
| 154 | } | ||
| 155 | |||
| 156 | static void autofs4_revalidate_drop(struct dentry *dentry, | ||
| 157 | struct rehash_entry *entry) | ||
| 158 | { | ||
| 159 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | ||
| 160 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | ||
| 161 | /* | ||
| 162 | * Add to the active list so we can pick this up in | ||
| 163 | * ->lookup(). Also add an entry to a rehash list so | ||
| 164 | * we know when there are no dentrys in flight so we | ||
| 165 | * know when we can rehash the dentry. | ||
| 166 | */ | ||
| 167 | spin_lock(&sbi->lookup_lock); | ||
| 168 | if (list_empty(&ino->active)) | ||
| 169 | list_add(&ino->active, &sbi->active_list); | ||
| 170 | autofs4_add_rehash_entry(ino, entry); | ||
| 171 | spin_unlock(&sbi->lookup_lock); | ||
| 172 | if (!(ino->flags & AUTOFS_INF_REHASH)) { | ||
| 173 | ino->flags |= AUTOFS_INF_REHASH; | ||
| 174 | dget(dentry); | ||
| 175 | spin_lock(&dentry->d_lock); | ||
| 176 | __d_drop(dentry); | ||
| 177 | spin_unlock(&dentry->d_lock); | ||
| 178 | } | ||
| 179 | return; | ||
| 180 | } | ||
| 181 | |||
| 182 | static void autofs4_revalidate_rehash(struct dentry *dentry) | ||
| 183 | { | ||
| 184 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | ||
| 185 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | ||
| 186 | if (ino->flags & AUTOFS_INF_REHASH) { | ||
| 187 | spin_lock(&sbi->lookup_lock); | ||
| 188 | autofs4_remove_rehash_entry(ino); | ||
| 189 | if (list_empty(&ino->rehash_list)) { | ||
| 190 | spin_unlock(&sbi->lookup_lock); | ||
| 191 | ino->flags &= ~AUTOFS_INF_REHASH; | ||
| 192 | d_rehash(dentry); | ||
| 193 | dput(ino->dentry); | ||
| 194 | } else | ||
| 195 | spin_unlock(&sbi->lookup_lock); | ||
| 196 | } | ||
| 197 | return; | ||
| 198 | } | ||
| 199 | |||
| 200 | static unsigned int autofs4_need_mount(unsigned int flags) | ||
| 201 | { | ||
| 202 | unsigned int res = 0; | ||
| 203 | if (flags & (TRIGGER_FLAGS | TRIGGER_INTENTS)) | ||
| 204 | res = 1; | ||
| 205 | return res; | ||
| 206 | } | ||
| 207 | |||
| 75 | static int autofs4_dir_open(struct inode *inode, struct file *file) | 208 | static int autofs4_dir_open(struct inode *inode, struct file *file) |
| 76 | { | 209 | { |
| 77 | struct dentry *dentry = file->f_path.dentry; | 210 | struct dentry *dentry = file->f_path.dentry; |
| @@ -93,7 +226,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file) | |||
| 93 | * it. | 226 | * it. |
| 94 | */ | 227 | */ |
| 95 | spin_lock(&dcache_lock); | 228 | spin_lock(&dcache_lock); |
| 96 | if (!d_mountpoint(dentry) && __simple_empty(dentry)) { | 229 | if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) { |
| 97 | spin_unlock(&dcache_lock); | 230 | spin_unlock(&dcache_lock); |
| 98 | return -ENOENT; | 231 | return -ENOENT; |
| 99 | } | 232 | } |
| @@ -103,7 +236,7 @@ out: | |||
| 103 | return dcache_dir_open(inode, file); | 236 | return dcache_dir_open(inode, file); |
| 104 | } | 237 | } |
| 105 | 238 | ||
| 106 | static int try_to_fill_dentry(struct dentry *dentry, int flags) | 239 | static int try_to_fill_dentry(struct dentry *dentry) |
| 107 | { | 240 | { |
| 108 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | 241 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); |
| 109 | struct autofs_info *ino = autofs4_dentry_ino(dentry); | 242 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
| @@ -116,55 +249,17 @@ static int try_to_fill_dentry(struct dentry *dentry, int flags) | |||
| 116 | * Wait for a pending mount, triggering one if there | 249 | * Wait for a pending mount, triggering one if there |
| 117 | * isn't one already | 250 | * isn't one already |
| 118 | */ | 251 | */ |
| 119 | if (dentry->d_inode == NULL) { | 252 | DPRINTK("waiting for mount name=%.*s", |
| 120 | DPRINTK("waiting for mount name=%.*s", | 253 | dentry->d_name.len, dentry->d_name.name); |
| 121 | dentry->d_name.len, dentry->d_name.name); | ||
| 122 | |||
| 123 | status = autofs4_wait(sbi, dentry, NFY_MOUNT); | ||
| 124 | |||
| 125 | DPRINTK("mount done status=%d", status); | ||
| 126 | |||
| 127 | /* Turn this into a real negative dentry? */ | ||
| 128 | if (status == -ENOENT) { | ||
| 129 | spin_lock(&dentry->d_lock); | ||
| 130 | dentry->d_flags &= ~DCACHE_AUTOFS_PENDING; | ||
| 131 | spin_unlock(&dentry->d_lock); | ||
| 132 | return status; | ||
| 133 | } else if (status) { | ||
| 134 | /* Return a negative dentry, but leave it "pending" */ | ||
| 135 | return status; | ||
| 136 | } | ||
| 137 | /* Trigger mount for path component or follow link */ | ||
| 138 | } else if (dentry->d_flags & DCACHE_AUTOFS_PENDING || | ||
| 139 | flags & (TRIGGER_FLAGS | TRIGGER_INTENTS) || | ||
| 140 | current->link_count) { | ||
| 141 | DPRINTK("waiting for mount name=%.*s", | ||
| 142 | dentry->d_name.len, dentry->d_name.name); | ||
| 143 | |||
| 144 | spin_lock(&dentry->d_lock); | ||
| 145 | dentry->d_flags |= DCACHE_AUTOFS_PENDING; | ||
| 146 | spin_unlock(&dentry->d_lock); | ||
| 147 | status = autofs4_wait(sbi, dentry, NFY_MOUNT); | ||
| 148 | 254 | ||
| 149 | DPRINTK("mount done status=%d", status); | 255 | status = autofs4_wait(sbi, dentry, NFY_MOUNT); |
| 150 | 256 | ||
| 151 | if (status) { | 257 | DPRINTK("mount done status=%d", status); |
| 152 | spin_lock(&dentry->d_lock); | ||
| 153 | dentry->d_flags &= ~DCACHE_AUTOFS_PENDING; | ||
| 154 | spin_unlock(&dentry->d_lock); | ||
| 155 | return status; | ||
| 156 | } | ||
| 157 | } | ||
| 158 | |||
| 159 | /* Initialize expiry counter after successful mount */ | ||
| 160 | if (ino) | ||
| 161 | ino->last_used = jiffies; | ||
| 162 | 258 | ||
| 163 | spin_lock(&dentry->d_lock); | 259 | /* Update expiry counter */ |
| 164 | dentry->d_flags &= ~DCACHE_AUTOFS_PENDING; | 260 | ino->last_used = jiffies; |
| 165 | spin_unlock(&dentry->d_lock); | ||
| 166 | 261 | ||
| 167 | return 0; | 262 | return status; |
| 168 | } | 263 | } |
| 169 | 264 | ||
| 170 | /* For autofs direct mounts the follow link triggers the mount */ | 265 | /* For autofs direct mounts the follow link triggers the mount */ |
| @@ -202,27 +297,39 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
| 202 | autofs4_expire_wait(dentry); | 297 | autofs4_expire_wait(dentry); |
| 203 | 298 | ||
| 204 | /* We trigger a mount for almost all flags */ | 299 | /* We trigger a mount for almost all flags */ |
| 205 | lookup_type = nd->flags & (TRIGGER_FLAGS | TRIGGER_INTENTS); | 300 | lookup_type = autofs4_need_mount(nd->flags); |
| 206 | if (!(lookup_type || dentry->d_flags & DCACHE_AUTOFS_PENDING)) | 301 | spin_lock(&sbi->fs_lock); |
| 302 | spin_lock(&dcache_lock); | ||
| 303 | if (!(lookup_type || ino->flags & AUTOFS_INF_PENDING)) { | ||
| 304 | spin_unlock(&dcache_lock); | ||
| 305 | spin_unlock(&sbi->fs_lock); | ||
| 207 | goto follow; | 306 | goto follow; |
| 307 | } | ||
| 208 | 308 | ||
| 209 | /* | 309 | /* |
| 210 | * If the dentry contains directories then it is an autofs | 310 | * If the dentry contains directories then it is an autofs |
| 211 | * multi-mount with no root mount offset. So don't try to | 311 | * multi-mount with no root mount offset. So don't try to |
| 212 | * mount it again. | 312 | * mount it again. |
| 213 | */ | 313 | */ |
| 214 | spin_lock(&dcache_lock); | 314 | if (ino->flags & AUTOFS_INF_PENDING || |
| 215 | if (dentry->d_flags & DCACHE_AUTOFS_PENDING || | 315 | (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs))) { |
| 216 | (!d_mountpoint(dentry) && __simple_empty(dentry))) { | 316 | ino->flags |= AUTOFS_INF_PENDING; |
| 217 | spin_unlock(&dcache_lock); | 317 | spin_unlock(&dcache_lock); |
| 318 | spin_unlock(&sbi->fs_lock); | ||
| 319 | |||
| 320 | status = try_to_fill_dentry(dentry); | ||
| 321 | |||
| 322 | spin_lock(&sbi->fs_lock); | ||
| 323 | ino->flags &= ~AUTOFS_INF_PENDING; | ||
| 324 | spin_unlock(&sbi->fs_lock); | ||
| 218 | 325 | ||
| 219 | status = try_to_fill_dentry(dentry, 0); | ||
| 220 | if (status) | 326 | if (status) |
| 221 | goto out_error; | 327 | goto out_error; |
| 222 | 328 | ||
| 223 | goto follow; | 329 | goto follow; |
| 224 | } | 330 | } |
| 225 | spin_unlock(&dcache_lock); | 331 | spin_unlock(&dcache_lock); |
| 332 | spin_unlock(&sbi->fs_lock); | ||
| 226 | follow: | 333 | follow: |
| 227 | /* | 334 | /* |
| 228 | * If there is no root mount it must be an autofs | 335 | * If there is no root mount it must be an autofs |
| @@ -254,18 +361,47 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
| 254 | { | 361 | { |
| 255 | struct inode *dir = dentry->d_parent->d_inode; | 362 | struct inode *dir = dentry->d_parent->d_inode; |
| 256 | struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb); | 363 | struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb); |
| 257 | int oz_mode = autofs4_oz_mode(sbi); | 364 | struct autofs_info *ino = autofs4_dentry_ino(dentry); |
| 365 | struct rehash_entry *entry; | ||
| 258 | int flags = nd ? nd->flags : 0; | 366 | int flags = nd ? nd->flags : 0; |
| 259 | int status = 1; | 367 | unsigned int mutex_aquired; |
| 368 | |||
| 369 | DPRINTK("name = %.*s oz_mode = %d", | ||
| 370 | dentry->d_name.len, dentry->d_name.name, oz_mode); | ||
| 371 | |||
| 372 | /* Daemon never causes a mount to trigger */ | ||
| 373 | if (autofs4_oz_mode(sbi)) | ||
| 374 | return 1; | ||
| 375 | |||
| 376 | entry = kmalloc(sizeof(struct rehash_entry), GFP_KERNEL); | ||
| 377 | if (!entry) | ||
| 378 | return -ENOMEM; | ||
| 379 | |||
| 380 | mutex_aquired = mutex_trylock(&dir->i_mutex); | ||
| 260 | 381 | ||
| 261 | /* Pending dentry */ | ||
| 262 | spin_lock(&sbi->fs_lock); | 382 | spin_lock(&sbi->fs_lock); |
| 383 | spin_lock(&dcache_lock); | ||
| 384 | /* Pending dentry */ | ||
| 263 | if (autofs4_ispending(dentry)) { | 385 | if (autofs4_ispending(dentry)) { |
| 264 | /* The daemon never causes a mount to trigger */ | 386 | int status; |
| 265 | spin_unlock(&sbi->fs_lock); | ||
| 266 | 387 | ||
| 267 | if (oz_mode) | 388 | /* |
| 268 | return 1; | 389 | * We can only unhash and send this to ->lookup() if |
| 390 | * the directory mutex is held over d_revalidate() and | ||
| 391 | * ->lookup(). This prevents the VFS from incorrectly | ||
| 392 | * seeing the dentry as non-existent. | ||
| 393 | */ | ||
| 394 | ino->flags |= AUTOFS_INF_PENDING; | ||
| 395 | if (!mutex_aquired) { | ||
| 396 | autofs4_revalidate_drop(dentry, entry); | ||
| 397 | spin_unlock(&dcache_lock); | ||
| 398 | spin_unlock(&sbi->fs_lock); | ||
| 399 | return 0; | ||
| 400 | } | ||
| 401 | spin_unlock(&dcache_lock); | ||
| 402 | spin_unlock(&sbi->fs_lock); | ||
| 403 | mutex_unlock(&dir->i_mutex); | ||
| 404 | kfree(entry); | ||
| 269 | 405 | ||
| 270 | /* | 406 | /* |
| 271 | * If the directory has gone away due to an expire | 407 | * If the directory has gone away due to an expire |
| @@ -279,46 +415,82 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
| 279 | * A zero status is success otherwise we have a | 415 | * A zero status is success otherwise we have a |
| 280 | * negative error code. | 416 | * negative error code. |
| 281 | */ | 417 | */ |
| 282 | status = try_to_fill_dentry(dentry, flags); | 418 | status = try_to_fill_dentry(dentry); |
| 419 | |||
| 420 | spin_lock(&sbi->fs_lock); | ||
| 421 | ino->flags &= ~AUTOFS_INF_PENDING; | ||
| 422 | spin_unlock(&sbi->fs_lock); | ||
| 423 | |||
| 283 | if (status == 0) | 424 | if (status == 0) |
| 284 | return 1; | 425 | return 1; |
| 285 | 426 | ||
| 286 | return status; | 427 | return status; |
| 287 | } | 428 | } |
| 288 | spin_unlock(&sbi->fs_lock); | ||
| 289 | |||
| 290 | /* Negative dentry.. invalidate if "old" */ | ||
| 291 | if (dentry->d_inode == NULL) | ||
| 292 | return 0; | ||
| 293 | 429 | ||
| 294 | /* Check for a non-mountpoint directory with no contents */ | 430 | /* Check for a non-mountpoint directory with no contents */ |
| 295 | spin_lock(&dcache_lock); | ||
| 296 | if (S_ISDIR(dentry->d_inode->i_mode) && | 431 | if (S_ISDIR(dentry->d_inode->i_mode) && |
| 297 | !d_mountpoint(dentry) && | 432 | !d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) { |
| 298 | __simple_empty(dentry)) { | ||
| 299 | DPRINTK("dentry=%p %.*s, emptydir", | 433 | DPRINTK("dentry=%p %.*s, emptydir", |
| 300 | dentry, dentry->d_name.len, dentry->d_name.name); | 434 | dentry, dentry->d_name.len, dentry->d_name.name); |
| 301 | spin_unlock(&dcache_lock); | ||
| 302 | 435 | ||
| 303 | /* The daemon never causes a mount to trigger */ | 436 | if (autofs4_need_mount(flags) || current->link_count) { |
| 304 | if (oz_mode) | 437 | int status; |
| 305 | return 1; | ||
| 306 | 438 | ||
| 307 | /* | 439 | /* |
| 308 | * A zero status is success otherwise we have a | 440 | * We can only unhash and send this to ->lookup() if |
| 309 | * negative error code. | 441 | * the directory mutex is held over d_revalidate() and |
| 310 | */ | 442 | * ->lookup(). This prevents the VFS from incorrectly |
| 311 | status = try_to_fill_dentry(dentry, flags); | 443 | * seeing the dentry as non-existent. |
| 312 | if (status == 0) | 444 | */ |
| 313 | return 1; | 445 | ino->flags |= AUTOFS_INF_PENDING; |
| 446 | if (!mutex_aquired) { | ||
| 447 | autofs4_revalidate_drop(dentry, entry); | ||
| 448 | spin_unlock(&dcache_lock); | ||
| 449 | spin_unlock(&sbi->fs_lock); | ||
| 450 | return 0; | ||
| 451 | } | ||
| 452 | spin_unlock(&dcache_lock); | ||
| 453 | spin_unlock(&sbi->fs_lock); | ||
| 454 | mutex_unlock(&dir->i_mutex); | ||
| 455 | kfree(entry); | ||
| 314 | 456 | ||
| 315 | return status; | 457 | /* |
| 458 | * A zero status is success otherwise we have a | ||
| 459 | * negative error code. | ||
| 460 | */ | ||
| 461 | status = try_to_fill_dentry(dentry); | ||
| 462 | |||
| 463 | spin_lock(&sbi->fs_lock); | ||
| 464 | ino->flags &= ~AUTOFS_INF_PENDING; | ||
| 465 | spin_unlock(&sbi->fs_lock); | ||
| 466 | |||
| 467 | if (status == 0) | ||
| 468 | return 1; | ||
| 469 | |||
| 470 | return status; | ||
| 471 | } | ||
| 316 | } | 472 | } |
| 317 | spin_unlock(&dcache_lock); | 473 | spin_unlock(&dcache_lock); |
| 474 | spin_unlock(&sbi->fs_lock); | ||
| 475 | |||
| 476 | if (mutex_aquired) | ||
| 477 | mutex_unlock(&dir->i_mutex); | ||
| 478 | |||
| 479 | kfree(entry); | ||
| 318 | 480 | ||
| 319 | return 1; | 481 | return 1; |
| 320 | } | 482 | } |
| 321 | 483 | ||
| 484 | static void autofs4_free_rehash_entrys(struct autofs_info *inf) | ||
| 485 | { | ||
| 486 | struct list_head *head = &inf->rehash_list; | ||
| 487 | struct rehash_entry *entry, *next; | ||
| 488 | list_for_each_entry_safe(entry, next, head, list) { | ||
| 489 | list_del(&entry->list); | ||
| 490 | kfree(entry); | ||
| 491 | } | ||
| 492 | } | ||
| 493 | |||
| 322 | void autofs4_dentry_release(struct dentry *de) | 494 | void autofs4_dentry_release(struct dentry *de) |
| 323 | { | 495 | { |
| 324 | struct autofs_info *inf; | 496 | struct autofs_info *inf; |
| @@ -337,6 +509,8 @@ void autofs4_dentry_release(struct dentry *de) | |||
| 337 | list_del(&inf->active); | 509 | list_del(&inf->active); |
| 338 | if (!list_empty(&inf->expiring)) | 510 | if (!list_empty(&inf->expiring)) |
| 339 | list_del(&inf->expiring); | 511 | list_del(&inf->expiring); |
| 512 | if (!list_empty(&inf->rehash_list)) | ||
| 513 | autofs4_free_rehash_entrys(inf); | ||
| 340 | spin_unlock(&sbi->lookup_lock); | 514 | spin_unlock(&sbi->lookup_lock); |
| 341 | } | 515 | } |
| 342 | 516 | ||
| @@ -359,35 +533,52 @@ static const struct dentry_operations autofs4_dentry_operations = { | |||
| 359 | .d_release = autofs4_dentry_release, | 533 | .d_release = autofs4_dentry_release, |
| 360 | }; | 534 | }; |
| 361 | 535 | ||
| 362 | static struct dentry *autofs4_lookup_active(struct autofs_sb_info *sbi, struct dentry *parent, struct qstr *name) | 536 | static struct dentry *autofs4_lookup_active(struct dentry *dentry) |
| 363 | { | 537 | { |
| 538 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | ||
| 539 | struct dentry *parent = dentry->d_parent; | ||
| 540 | struct qstr *name = &dentry->d_name; | ||
| 364 | unsigned int len = name->len; | 541 | unsigned int len = name->len; |
| 365 | unsigned int hash = name->hash; | 542 | unsigned int hash = name->hash; |
| 366 | const unsigned char *str = name->name; | 543 | const unsigned char *str = name->name; |
| 367 | struct list_head *p, *head; | 544 | struct list_head *p, *head; |
| 368 | 545 | ||
| 546 | restart: | ||
| 369 | spin_lock(&dcache_lock); | 547 | spin_lock(&dcache_lock); |
| 370 | spin_lock(&sbi->lookup_lock); | 548 | spin_lock(&sbi->lookup_lock); |
| 371 | head = &sbi->active_list; | 549 | head = &sbi->active_list; |
| 372 | list_for_each(p, head) { | 550 | list_for_each(p, head) { |
| 373 | struct autofs_info *ino; | 551 | struct autofs_info *ino; |
| 374 | struct dentry *dentry; | 552 | struct dentry *active; |
| 375 | struct qstr *qstr; | 553 | struct qstr *qstr; |
| 376 | 554 | ||
| 377 | ino = list_entry(p, struct autofs_info, active); | 555 | ino = list_entry(p, struct autofs_info, active); |
| 378 | dentry = ino->dentry; | 556 | active = ino->dentry; |
| 379 | 557 | ||
| 380 | spin_lock(&dentry->d_lock); | 558 | spin_lock(&active->d_lock); |
| 381 | 559 | ||
| 382 | /* Already gone? */ | 560 | /* Already gone? */ |
| 383 | if (atomic_read(&dentry->d_count) == 0) | 561 | if (atomic_read(&active->d_count) == 0) |
| 384 | goto next; | 562 | goto next; |
| 385 | 563 | ||
| 386 | qstr = &dentry->d_name; | 564 | if (active->d_inode && IS_DEADDIR(active->d_inode)) { |
| 565 | if (!list_empty(&ino->rehash_list)) { | ||
| 566 | dget(active); | ||
| 567 | spin_unlock(&active->d_lock); | ||
| 568 | spin_unlock(&sbi->lookup_lock); | ||
| 569 | spin_unlock(&dcache_lock); | ||
| 570 | autofs4_remove_rehash_entrys(ino); | ||
| 571 | dput(active); | ||
| 572 | goto restart; | ||
| 573 | } | ||
| 574 | goto next; | ||
| 575 | } | ||
| 576 | |||
| 577 | qstr = &active->d_name; | ||
| 387 | 578 | ||
| 388 | if (dentry->d_name.hash != hash) | 579 | if (active->d_name.hash != hash) |
| 389 | goto next; | 580 | goto next; |
| 390 | if (dentry->d_parent != parent) | 581 | if (active->d_parent != parent) |
| 391 | goto next; | 582 | goto next; |
| 392 | 583 | ||
| 393 | if (qstr->len != len) | 584 | if (qstr->len != len) |
| @@ -395,15 +586,13 @@ static struct dentry *autofs4_lookup_active(struct autofs_sb_info *sbi, struct d | |||
| 395 | if (memcmp(qstr->name, str, len)) | 586 | if (memcmp(qstr->name, str, len)) |
| 396 | goto next; | 587 | goto next; |
| 397 | 588 | ||
| 398 | if (d_unhashed(dentry)) { | 589 | dget(active); |
| 399 | dget(dentry); | 590 | spin_unlock(&active->d_lock); |
| 400 | spin_unlock(&dentry->d_lock); | 591 | spin_unlock(&sbi->lookup_lock); |
| 401 | spin_unlock(&sbi->lookup_lock); | 592 | spin_unlock(&dcache_lock); |
| 402 | spin_unlock(&dcache_lock); | 593 | return active; |
| 403 | return dentry; | ||
| 404 | } | ||
| 405 | next: | 594 | next: |
| 406 | spin_unlock(&dentry->d_lock); | 595 | spin_unlock(&active->d_lock); |
| 407 | } | 596 | } |
| 408 | spin_unlock(&sbi->lookup_lock); | 597 | spin_unlock(&sbi->lookup_lock); |
| 409 | spin_unlock(&dcache_lock); | 598 | spin_unlock(&dcache_lock); |
| @@ -411,8 +600,11 @@ next: | |||
| 411 | return NULL; | 600 | return NULL; |
| 412 | } | 601 | } |
| 413 | 602 | ||
| 414 | static struct dentry *autofs4_lookup_expiring(struct autofs_sb_info *sbi, struct dentry *parent, struct qstr *name) | 603 | static struct dentry *autofs4_lookup_expiring(struct dentry *dentry) |
| 415 | { | 604 | { |
| 605 | struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); | ||
| 606 | struct dentry *parent = dentry->d_parent; | ||
| 607 | struct qstr *name = &dentry->d_name; | ||
| 416 | unsigned int len = name->len; | 608 | unsigned int len = name->len; |
| 417 | unsigned int hash = name->hash; | 609 | unsigned int hash = name->hash; |
| 418 | const unsigned char *str = name->name; | 610 | const unsigned char *str = name->name; |
| @@ -423,23 +615,23 @@ static struct dentry *autofs4_lookup_expiring(struct autofs_sb_info *sbi, struct | |||
| 423 | head = &sbi->expiring_list; | 615 | head = &sbi->expiring_list; |
| 424 | list_for_each(p, head) { | 616 | list_for_each(p, head) { |
| 425 | struct autofs_info *ino; | 617 | struct autofs_info *ino; |
| 426 | struct dentry *dentry; | 618 | struct dentry *expiring; |
| 427 | struct qstr *qstr; | 619 | struct qstr *qstr; |
| 428 | 620 | ||
| 429 | ino = list_entry(p, struct autofs_info, expiring); | 621 | ino = list_entry(p, struct autofs_info, expiring); |
| 430 | dentry = ino->dentry; | 622 | expiring = ino->dentry; |
| 431 | 623 | ||
| 432 | spin_lock(&dentry->d_lock); | 624 | spin_lock(&expiring->d_lock); |
| 433 | 625 | ||
| 434 | /* Bad luck, we've already been dentry_iput */ | 626 | /* Bad luck, we've already been dentry_iput */ |
| 435 | if (!dentry->d_inode) | 627 | if (!expiring->d_inode) |
| 436 | goto next; | 628 | goto next; |
| 437 | 629 | ||
| 438 | qstr = &dentry->d_name; | 630 | qstr = &expiring->d_name; |
| 439 | 631 | ||
| 440 | if (dentry->d_name.hash != hash) | 632 | if (expiring->d_name.hash != hash) |
| 441 | goto next; | 633 | goto next; |
| 442 | if (dentry->d_parent != parent) | 634 | if (expiring->d_parent != parent) |
| 443 | goto next; | 635 | goto next; |
| 444 | 636 | ||
| 445 | if (qstr->len != len) | 637 | if (qstr->len != len) |
| @@ -447,15 +639,13 @@ static struct dentry *autofs4_lookup_expiring(struct autofs_sb_info *sbi, struct | |||
| 447 | if (memcmp(qstr->name, str, len)) | 639 | if (memcmp(qstr->name, str, len)) |
| 448 | goto next; | 640 | goto next; |
| 449 | 641 | ||
| 450 | if (d_unhashed(dentry)) { | 642 | dget(expiring); |
| 451 | dget(dentry); | 643 | spin_unlock(&expiring->d_lock); |
| 452 | spin_unlock(&dentry->d_lock); | 644 | spin_unlock(&sbi->lookup_lock); |
| 453 | spin_unlock(&sbi->lookup_lock); | 645 | spin_unlock(&dcache_lock); |
| 454 | spin_unlock(&dcache_lock); | 646 | return expiring; |
| 455 | return dentry; | ||
| 456 | } | ||
| 457 | next: | 647 | next: |
| 458 | spin_unlock(&dentry->d_lock); | 648 | spin_unlock(&expiring->d_lock); |
| 459 | } | 649 | } |
| 460 | spin_unlock(&sbi->lookup_lock); | 650 | spin_unlock(&sbi->lookup_lock); |
| 461 | spin_unlock(&dcache_lock); | 651 | spin_unlock(&dcache_lock); |
| @@ -463,13 +653,56 @@ next: | |||
| 463 | return NULL; | 653 | return NULL; |
| 464 | } | 654 | } |
| 465 | 655 | ||
| 656 | static struct autofs_info *init_new_dentry(struct autofs_sb_info *sbi, | ||
| 657 | struct dentry *dentry, int oz_mode) | ||
| 658 | { | ||
| 659 | struct autofs_info *ino; | ||
| 660 | |||
| 661 | /* | ||
| 662 | * Mark the dentry incomplete but don't hash it. We do this | ||
| 663 | * to serialize our inode creation operations (symlink and | ||
| 664 | * mkdir) which prevents deadlock during the callback to | ||
| 665 | * the daemon. Subsequent user space lookups for the same | ||
| 666 | * dentry are placed on the wait queue while the daemon | ||
| 667 | * itself is allowed passage unresticted so the create | ||
| 668 | * operation itself can then hash the dentry. Finally, | ||
| 669 | * we check for the hashed dentry and return the newly | ||
| 670 | * hashed dentry. | ||
| 671 | */ | ||
| 672 | dentry->d_op = &autofs4_root_dentry_operations; | ||
| 673 | |||
| 674 | /* | ||
| 675 | * And we need to ensure that the same dentry is used for | ||
| 676 | * all following lookup calls until it is hashed so that | ||
| 677 | * the dentry flags are persistent throughout the request. | ||
| 678 | */ | ||
| 679 | ino = autofs4_init_ino(NULL, sbi, 0555); | ||
| 680 | if (!ino) | ||
| 681 | return ERR_PTR(-ENOMEM); | ||
| 682 | |||
| 683 | dentry->d_fsdata = ino; | ||
| 684 | ino->dentry = dentry; | ||
| 685 | |||
| 686 | /* | ||
| 687 | * Only set the mount pending flag for new dentrys not created | ||
| 688 | * by the daemon. | ||
| 689 | */ | ||
| 690 | if (!oz_mode) | ||
| 691 | ino->flags |= AUTOFS_INF_PENDING; | ||
| 692 | |||
| 693 | d_instantiate(dentry, NULL); | ||
| 694 | |||
| 695 | return ino; | ||
| 696 | } | ||
| 697 | |||
| 466 | /* Lookups in the root directory */ | 698 | /* Lookups in the root directory */ |
| 467 | static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | 699 | static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) |
| 468 | { | 700 | { |
| 469 | struct autofs_sb_info *sbi; | 701 | struct autofs_sb_info *sbi; |
| 470 | struct autofs_info *ino; | 702 | struct autofs_info *ino; |
| 471 | struct dentry *expiring, *unhashed; | 703 | struct dentry *expiring, *active; |
| 472 | int oz_mode; | 704 | int oz_mode; |
| 705 | int status = 0; | ||
| 473 | 706 | ||
| 474 | DPRINTK("name = %.*s", | 707 | DPRINTK("name = %.*s", |
| 475 | dentry->d_name.len, dentry->d_name.name); | 708 | dentry->d_name.len, dentry->d_name.name); |
| @@ -484,123 +717,100 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, s | |||
| 484 | DPRINTK("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d", | 717 | DPRINTK("pid = %u, pgrp = %u, catatonic = %d, oz_mode = %d", |
| 485 | current->pid, task_pgrp_nr(current), sbi->catatonic, oz_mode); | 718 | current->pid, task_pgrp_nr(current), sbi->catatonic, oz_mode); |
| 486 | 719 | ||
| 487 | unhashed = autofs4_lookup_active(sbi, dentry->d_parent, &dentry->d_name); | 720 | spin_lock(&sbi->fs_lock); |
| 488 | if (unhashed) | 721 | active = autofs4_lookup_active(dentry); |
| 489 | dentry = unhashed; | 722 | if (active) { |
| 490 | else { | 723 | dentry = active; |
| 491 | /* | 724 | ino = autofs4_dentry_ino(dentry); |
| 492 | * Mark the dentry incomplete but don't hash it. We do this | 725 | /* If this came from revalidate, rehash it */ |
| 493 | * to serialize our inode creation operations (symlink and | 726 | autofs4_revalidate_rehash(dentry); |
| 494 | * mkdir) which prevents deadlock during the callback to | 727 | spin_unlock(&sbi->fs_lock); |
| 495 | * the daemon. Subsequent user space lookups for the same | 728 | } else { |
| 496 | * dentry are placed on the wait queue while the daemon | 729 | spin_unlock(&sbi->fs_lock); |
| 497 | * itself is allowed passage unresticted so the create | 730 | ino = init_new_dentry(sbi, dentry, oz_mode); |
| 498 | * operation itself can then hash the dentry. Finally, | 731 | if (IS_ERR(ino)) |
| 499 | * we check for the hashed dentry and return the newly | 732 | return (struct dentry *) ino; |
| 500 | * hashed dentry. | ||
| 501 | */ | ||
| 502 | dentry->d_op = &autofs4_root_dentry_operations; | ||
| 503 | |||
| 504 | /* | ||
| 505 | * And we need to ensure that the same dentry is used for | ||
| 506 | * all following lookup calls until it is hashed so that | ||
| 507 | * the dentry flags are persistent throughout the request. | ||
| 508 | */ | ||
| 509 | ino = autofs4_init_ino(NULL, sbi, 0555); | ||
| 510 | if (!ino) | ||
| 511 | return ERR_PTR(-ENOMEM); | ||
| 512 | |||
| 513 | dentry->d_fsdata = ino; | ||
| 514 | ino->dentry = dentry; | ||
| 515 | |||
| 516 | spin_lock(&sbi->lookup_lock); | ||
| 517 | list_add(&ino->active, &sbi->active_list); | ||
| 518 | spin_unlock(&sbi->lookup_lock); | ||
| 519 | |||
| 520 | d_instantiate(dentry, NULL); | ||
| 521 | } | 733 | } |
| 522 | 734 | ||
| 735 | autofs4_add_active(dentry); | ||
| 736 | |||
| 523 | if (!oz_mode) { | 737 | if (!oz_mode) { |
| 738 | expiring = autofs4_lookup_expiring(dentry); | ||
| 524 | mutex_unlock(&dir->i_mutex); | 739 | mutex_unlock(&dir->i_mutex); |
| 525 | expiring = autofs4_lookup_expiring(sbi, | ||
| 526 | dentry->d_parent, | ||
| 527 | &dentry->d_name); | ||
| 528 | if (expiring) { | 740 | if (expiring) { |
| 529 | /* | 741 | /* |
| 530 | * If we are racing with expire the request might not | 742 | * If we are racing with expire the request might not |
| 531 | * be quite complete but the directory has been removed | 743 | * be quite complete but the directory has been removed |
| 532 | * so it must have been successful, so just wait for it. | 744 | * so it must have been successful, so just wait for it. |
| 533 | */ | 745 | */ |
| 534 | ino = autofs4_dentry_ino(expiring); | ||
| 535 | autofs4_expire_wait(expiring); | 746 | autofs4_expire_wait(expiring); |
| 536 | spin_lock(&sbi->lookup_lock); | ||
| 537 | if (!list_empty(&ino->expiring)) | ||
| 538 | list_del_init(&ino->expiring); | ||
| 539 | spin_unlock(&sbi->lookup_lock); | ||
| 540 | dput(expiring); | 747 | dput(expiring); |
| 541 | } | 748 | } |
| 542 | 749 | status = try_to_fill_dentry(dentry); | |
| 543 | spin_lock(&dentry->d_lock); | ||
| 544 | dentry->d_flags |= DCACHE_AUTOFS_PENDING; | ||
| 545 | spin_unlock(&dentry->d_lock); | ||
| 546 | if (dentry->d_op && dentry->d_op->d_revalidate) | ||
| 547 | (dentry->d_op->d_revalidate)(dentry, nd); | ||
| 548 | mutex_lock(&dir->i_mutex); | 750 | mutex_lock(&dir->i_mutex); |
| 751 | spin_lock(&sbi->fs_lock); | ||
| 752 | ino->flags &= ~AUTOFS_INF_PENDING; | ||
| 753 | spin_unlock(&sbi->fs_lock); | ||
| 549 | } | 754 | } |
| 550 | 755 | ||
| 756 | autofs4_del_active(dentry); | ||
| 757 | |||
| 551 | /* | 758 | /* |
| 552 | * If we are still pending, check if we had to handle | 759 | * If we had a mount fail, check if we had to handle |
| 553 | * a signal. If so we can force a restart.. | 760 | * a signal. If so we can force a restart.. |
| 554 | */ | 761 | */ |
| 555 | if (dentry->d_flags & DCACHE_AUTOFS_PENDING) { | 762 | if (status) { |
| 556 | /* See if we were interrupted */ | 763 | /* See if we were interrupted */ |
| 557 | if (signal_pending(current)) { | 764 | if (signal_pending(current)) { |
| 558 | sigset_t *sigset = ¤t->pending.signal; | 765 | sigset_t *sigset = ¤t->pending.signal; |
| 559 | if (sigismember (sigset, SIGKILL) || | 766 | if (sigismember (sigset, SIGKILL) || |
| 560 | sigismember (sigset, SIGQUIT) || | 767 | sigismember (sigset, SIGQUIT) || |
| 561 | sigismember (sigset, SIGINT)) { | 768 | sigismember (sigset, SIGINT)) { |
| 562 | if (unhashed) | 769 | if (active) |
| 563 | dput(unhashed); | 770 | dput(active); |
| 564 | return ERR_PTR(-ERESTARTNOINTR); | 771 | return ERR_PTR(-ERESTARTNOINTR); |
| 565 | } | 772 | } |
| 566 | } | 773 | } |
| 567 | if (!oz_mode) { | 774 | } |
| 568 | spin_lock(&dentry->d_lock); | 775 | |
| 569 | dentry->d_flags &= ~DCACHE_AUTOFS_PENDING; | 776 | /* |
| 570 | spin_unlock(&dentry->d_lock); | 777 | * User space can (and has done in the past) remove and re-create |
| 778 | * this directory during the callback. This can leave us with an | ||
| 779 | * unhashed dentry, but a successful mount! So we need to | ||
| 780 | * perform another cached lookup in case the dentry now exists. | ||
| 781 | */ | ||
| 782 | if (!oz_mode && !have_submounts(dentry)) { | ||
| 783 | struct dentry *new; | ||
| 784 | new = d_lookup(dentry->d_parent, &dentry->d_name); | ||
| 785 | if (new) { | ||
| 786 | if (active) | ||
| 787 | dput(active); | ||
| 788 | return new; | ||
| 789 | } else { | ||
| 790 | if (!status) | ||
| 791 | status = -ENOENT; | ||
| 571 | } | 792 | } |
| 572 | } | 793 | } |
| 573 | 794 | ||
| 574 | /* | 795 | /* |
| 575 | * If this dentry is unhashed, then we shouldn't honour this | 796 | * If we had a mount failure, return status to user space. |
| 576 | * lookup. Returning ENOENT here doesn't do the right thing | 797 | * If the mount succeeded and we used a dentry from the active queue |
| 577 | * for all system calls, but it should be OK for the operations | 798 | * return it. |
| 578 | * we permit from an autofs. | ||
| 579 | */ | 799 | */ |
| 580 | if (!oz_mode && d_unhashed(dentry)) { | 800 | if (status) { |
| 801 | dentry = ERR_PTR(status); | ||
| 802 | if (active) | ||
| 803 | dput(active); | ||
| 804 | return dentry; | ||
| 805 | } else { | ||
| 581 | /* | 806 | /* |
| 582 | * A user space application can (and has done in the past) | 807 | * Valid successful mount, return active dentry or NULL |
| 583 | * remove and re-create this directory during the callback. | 808 | * for a new dentry. |
| 584 | * This can leave us with an unhashed dentry, but a | ||
| 585 | * successful mount! So we need to perform another | ||
| 586 | * cached lookup in case the dentry now exists. | ||
| 587 | */ | 809 | */ |
| 588 | struct dentry *parent = dentry->d_parent; | 810 | if (active) |
| 589 | struct dentry *new = d_lookup(parent, &dentry->d_name); | 811 | return active; |
| 590 | if (new != NULL) | ||
| 591 | dentry = new; | ||
| 592 | else | ||
| 593 | dentry = ERR_PTR(-ENOENT); | ||
| 594 | |||
| 595 | if (unhashed) | ||
| 596 | dput(unhashed); | ||
| 597 | |||
| 598 | return dentry; | ||
| 599 | } | 812 | } |
| 600 | 813 | ||
| 601 | if (unhashed) | ||
| 602 | return unhashed; | ||
| 603 | |||
| 604 | return NULL; | 814 | return NULL; |
| 605 | } | 815 | } |
| 606 | 816 | ||
| @@ -624,11 +834,6 @@ static int autofs4_dir_symlink(struct inode *dir, | |||
| 624 | if (!ino) | 834 | if (!ino) |
| 625 | return -ENOMEM; | 835 | return -ENOMEM; |
| 626 | 836 | ||
| 627 | spin_lock(&sbi->lookup_lock); | ||
| 628 | if (!list_empty(&ino->active)) | ||
| 629 | list_del_init(&ino->active); | ||
| 630 | spin_unlock(&sbi->lookup_lock); | ||
| 631 | |||
| 632 | ino->size = strlen(symname); | 837 | ino->size = strlen(symname); |
| 633 | cp = kmalloc(ino->size + 1, GFP_KERNEL); | 838 | cp = kmalloc(ino->size + 1, GFP_KERNEL); |
| 634 | if (!cp) { | 839 | if (!cp) { |
| @@ -705,10 +910,6 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry) | |||
| 705 | dir->i_mtime = CURRENT_TIME; | 910 | dir->i_mtime = CURRENT_TIME; |
| 706 | 911 | ||
| 707 | spin_lock(&dcache_lock); | 912 | spin_lock(&dcache_lock); |
| 708 | spin_lock(&sbi->lookup_lock); | ||
| 709 | if (list_empty(&ino->expiring)) | ||
| 710 | list_add(&ino->expiring, &sbi->expiring_list); | ||
| 711 | spin_unlock(&sbi->lookup_lock); | ||
| 712 | spin_lock(&dentry->d_lock); | 913 | spin_lock(&dentry->d_lock); |
| 713 | __d_drop(dentry); | 914 | __d_drop(dentry); |
| 714 | spin_unlock(&dentry->d_lock); | 915 | spin_unlock(&dentry->d_lock); |
| @@ -734,10 +935,6 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry) | |||
| 734 | spin_unlock(&dcache_lock); | 935 | spin_unlock(&dcache_lock); |
| 735 | return -ENOTEMPTY; | 936 | return -ENOTEMPTY; |
| 736 | } | 937 | } |
| 737 | spin_lock(&sbi->lookup_lock); | ||
| 738 | if (list_empty(&ino->expiring)) | ||
| 739 | list_add(&ino->expiring, &sbi->expiring_list); | ||
| 740 | spin_unlock(&sbi->lookup_lock); | ||
| 741 | spin_lock(&dentry->d_lock); | 938 | spin_lock(&dentry->d_lock); |
| 742 | __d_drop(dentry); | 939 | __d_drop(dentry); |
| 743 | spin_unlock(&dentry->d_lock); | 940 | spin_unlock(&dentry->d_lock); |
| @@ -775,11 +972,6 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
| 775 | if (!ino) | 972 | if (!ino) |
| 776 | return -ENOMEM; | 973 | return -ENOMEM; |
| 777 | 974 | ||
| 778 | spin_lock(&sbi->lookup_lock); | ||
| 779 | if (!list_empty(&ino->active)) | ||
| 780 | list_del_init(&ino->active); | ||
| 781 | spin_unlock(&sbi->lookup_lock); | ||
| 782 | |||
| 783 | inode = autofs4_get_inode(dir->i_sb, ino); | 975 | inode = autofs4_get_inode(dir->i_sb, ino); |
| 784 | if (!inode) { | 976 | if (!inode) { |
| 785 | if (!dentry->d_fsdata) | 977 | if (!dentry->d_fsdata) |
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index b639dcf7c778..346b69405363 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c | |||
| @@ -32,7 +32,7 @@ | |||
| 32 | 32 | ||
| 33 | static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs); | 33 | static int load_aout_binary(struct linux_binprm *, struct pt_regs * regs); |
| 34 | static int load_aout_library(struct file*); | 34 | static int load_aout_library(struct file*); |
| 35 | static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit); | 35 | static int aout_core_dump(struct coredump_params *cprm); |
| 36 | 36 | ||
| 37 | static struct linux_binfmt aout_format = { | 37 | static struct linux_binfmt aout_format = { |
| 38 | .module = THIS_MODULE, | 38 | .module = THIS_MODULE, |
| @@ -89,8 +89,9 @@ if (file->f_op->llseek) { \ | |||
| 89 | * dumping of the process results in another error.. | 89 | * dumping of the process results in another error.. |
| 90 | */ | 90 | */ |
| 91 | 91 | ||
| 92 | static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit) | 92 | static int aout_core_dump(struct coredump_params *cprm) |
| 93 | { | 93 | { |
| 94 | struct file *file = cprm->file; | ||
| 94 | mm_segment_t fs; | 95 | mm_segment_t fs; |
| 95 | int has_dumped = 0; | 96 | int has_dumped = 0; |
| 96 | unsigned long dump_start, dump_size; | 97 | unsigned long dump_start, dump_size; |
| @@ -108,16 +109,16 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file, u | |||
| 108 | current->flags |= PF_DUMPCORE; | 109 | current->flags |= PF_DUMPCORE; |
| 109 | strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm)); | 110 | strncpy(dump.u_comm, current->comm, sizeof(dump.u_comm)); |
| 110 | dump.u_ar0 = offsetof(struct user, regs); | 111 | dump.u_ar0 = offsetof(struct user, regs); |
| 111 | dump.signal = signr; | 112 | dump.signal = cprm->signr; |
| 112 | aout_dump_thread(regs, &dump); | 113 | aout_dump_thread(cprm->regs, &dump); |
| 113 | 114 | ||
| 114 | /* If the size of the dump file exceeds the rlimit, then see what would happen | 115 | /* If the size of the dump file exceeds the rlimit, then see what would happen |
| 115 | if we wrote the stack, but not the data area. */ | 116 | if we wrote the stack, but not the data area. */ |
| 116 | if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > limit) | 117 | if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit) |
| 117 | dump.u_dsize = 0; | 118 | dump.u_dsize = 0; |
| 118 | 119 | ||
| 119 | /* Make sure we have enough room to write the stack and data areas. */ | 120 | /* Make sure we have enough room to write the stack and data areas. */ |
| 120 | if ((dump.u_ssize + 1) * PAGE_SIZE > limit) | 121 | if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit) |
| 121 | dump.u_ssize = 0; | 122 | dump.u_ssize = 0; |
| 122 | 123 | ||
| 123 | /* make sure we actually have a data and stack area to dump */ | 124 | /* make sure we actually have a data and stack area to dump */ |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index d15ea1790bfb..edd90c49003c 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
| @@ -44,8 +44,8 @@ static unsigned long elf_map(struct file *, unsigned long, struct elf_phdr *, | |||
| 44 | * If we don't support core dumping, then supply a NULL so we | 44 | * If we don't support core dumping, then supply a NULL so we |
| 45 | * don't even try. | 45 | * don't even try. |
| 46 | */ | 46 | */ |
| 47 | #if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE) | 47 | #ifdef CONFIG_ELF_CORE |
| 48 | static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit); | 48 | static int elf_core_dump(struct coredump_params *cprm); |
| 49 | #else | 49 | #else |
| 50 | #define elf_core_dump NULL | 50 | #define elf_core_dump NULL |
| 51 | #endif | 51 | #endif |
| @@ -1101,12 +1101,7 @@ out: | |||
| 1101 | return error; | 1101 | return error; |
| 1102 | } | 1102 | } |
| 1103 | 1103 | ||
| 1104 | /* | 1104 | #ifdef CONFIG_ELF_CORE |
| 1105 | * Note that some platforms still use traditional core dumps and not | ||
| 1106 | * the ELF core dump. Each platform can select it as appropriate. | ||
| 1107 | */ | ||
| 1108 | #if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE) | ||
| 1109 | |||
| 1110 | /* | 1105 | /* |
| 1111 | * ELF core dumper | 1106 | * ELF core dumper |
| 1112 | * | 1107 | * |
| @@ -1277,8 +1272,9 @@ static int writenote(struct memelfnote *men, struct file *file, | |||
| 1277 | } | 1272 | } |
| 1278 | #undef DUMP_WRITE | 1273 | #undef DUMP_WRITE |
| 1279 | 1274 | ||
| 1280 | #define DUMP_WRITE(addr, nr) \ | 1275 | #define DUMP_WRITE(addr, nr) \ |
| 1281 | if ((size += (nr)) > limit || !dump_write(file, (addr), (nr))) \ | 1276 | if ((size += (nr)) > cprm->limit || \ |
| 1277 | !dump_write(cprm->file, (addr), (nr))) \ | ||
| 1282 | goto end_coredump; | 1278 | goto end_coredump; |
| 1283 | 1279 | ||
| 1284 | static void fill_elf_header(struct elfhdr *elf, int segs, | 1280 | static void fill_elf_header(struct elfhdr *elf, int segs, |
| @@ -1906,7 +1902,7 @@ static struct vm_area_struct *next_vma(struct vm_area_struct *this_vma, | |||
| 1906 | * and then they are actually written out. If we run out of core limit | 1902 | * and then they are actually written out. If we run out of core limit |
| 1907 | * we just truncate. | 1903 | * we just truncate. |
| 1908 | */ | 1904 | */ |
| 1909 | static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit) | 1905 | static int elf_core_dump(struct coredump_params *cprm) |
| 1910 | { | 1906 | { |
| 1911 | int has_dumped = 0; | 1907 | int has_dumped = 0; |
| 1912 | mm_segment_t fs; | 1908 | mm_segment_t fs; |
| @@ -1952,7 +1948,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un | |||
| 1952 | * notes. This also sets up the file header. | 1948 | * notes. This also sets up the file header. |
| 1953 | */ | 1949 | */ |
| 1954 | if (!fill_note_info(elf, segs + 1, /* including notes section */ | 1950 | if (!fill_note_info(elf, segs + 1, /* including notes section */ |
| 1955 | &info, signr, regs)) | 1951 | &info, cprm->signr, cprm->regs)) |
| 1956 | goto cleanup; | 1952 | goto cleanup; |
| 1957 | 1953 | ||
| 1958 | has_dumped = 1; | 1954 | has_dumped = 1; |
| @@ -2014,14 +2010,14 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un | |||
| 2014 | #endif | 2010 | #endif |
| 2015 | 2011 | ||
| 2016 | /* write out the notes section */ | 2012 | /* write out the notes section */ |
| 2017 | if (!write_note_info(&info, file, &foffset)) | 2013 | if (!write_note_info(&info, cprm->file, &foffset)) |
| 2018 | goto end_coredump; | 2014 | goto end_coredump; |
| 2019 | 2015 | ||
| 2020 | if (elf_coredump_extra_notes_write(file, &foffset)) | 2016 | if (elf_coredump_extra_notes_write(cprm->file, &foffset)) |
| 2021 | goto end_coredump; | 2017 | goto end_coredump; |
| 2022 | 2018 | ||
| 2023 | /* Align to page */ | 2019 | /* Align to page */ |
| 2024 | if (!dump_seek(file, dataoff - foffset)) | 2020 | if (!dump_seek(cprm->file, dataoff - foffset)) |
| 2025 | goto end_coredump; | 2021 | goto end_coredump; |
| 2026 | 2022 | ||
| 2027 | for (vma = first_vma(current, gate_vma); vma != NULL; | 2023 | for (vma = first_vma(current, gate_vma); vma != NULL; |
| @@ -2038,12 +2034,13 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file, un | |||
| 2038 | page = get_dump_page(addr); | 2034 | page = get_dump_page(addr); |
| 2039 | if (page) { | 2035 | if (page) { |
| 2040 | void *kaddr = kmap(page); | 2036 | void *kaddr = kmap(page); |
| 2041 | stop = ((size += PAGE_SIZE) > limit) || | 2037 | stop = ((size += PAGE_SIZE) > cprm->limit) || |
| 2042 | !dump_write(file, kaddr, PAGE_SIZE); | 2038 | !dump_write(cprm->file, kaddr, |
| 2039 | PAGE_SIZE); | ||
| 2043 | kunmap(page); | 2040 | kunmap(page); |
| 2044 | page_cache_release(page); | 2041 | page_cache_release(page); |
| 2045 | } else | 2042 | } else |
| 2046 | stop = !dump_seek(file, PAGE_SIZE); | 2043 | stop = !dump_seek(cprm->file, PAGE_SIZE); |
| 2047 | if (stop) | 2044 | if (stop) |
| 2048 | goto end_coredump; | 2045 | goto end_coredump; |
| 2049 | } | 2046 | } |
| @@ -2063,7 +2060,7 @@ out: | |||
| 2063 | return has_dumped; | 2060 | return has_dumped; |
| 2064 | } | 2061 | } |
| 2065 | 2062 | ||
| 2066 | #endif /* USE_ELF_CORE_DUMP */ | 2063 | #endif /* CONFIG_ELF_CORE */ |
| 2067 | 2064 | ||
| 2068 | static int __init init_elf_binfmt(void) | 2065 | static int __init init_elf_binfmt(void) |
| 2069 | { | 2066 | { |
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index 38502c67987c..c25256a5c5b0 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
| @@ -75,14 +75,14 @@ static int elf_fdpic_map_file_constdisp_on_uclinux(struct elf_fdpic_params *, | |||
| 75 | static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *, | 75 | static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *, |
| 76 | struct file *, struct mm_struct *); | 76 | struct file *, struct mm_struct *); |
| 77 | 77 | ||
| 78 | #if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE) | 78 | #ifdef CONFIG_ELF_CORE |
| 79 | static int elf_fdpic_core_dump(long, struct pt_regs *, struct file *, unsigned long limit); | 79 | static int elf_fdpic_core_dump(struct coredump_params *cprm); |
| 80 | #endif | 80 | #endif |
| 81 | 81 | ||
| 82 | static struct linux_binfmt elf_fdpic_format = { | 82 | static struct linux_binfmt elf_fdpic_format = { |
| 83 | .module = THIS_MODULE, | 83 | .module = THIS_MODULE, |
| 84 | .load_binary = load_elf_fdpic_binary, | 84 | .load_binary = load_elf_fdpic_binary, |
| 85 | #if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE) | 85 | #ifdef CONFIG_ELF_CORE |
| 86 | .core_dump = elf_fdpic_core_dump, | 86 | .core_dump = elf_fdpic_core_dump, |
| 87 | #endif | 87 | #endif |
| 88 | .min_coredump = ELF_EXEC_PAGESIZE, | 88 | .min_coredump = ELF_EXEC_PAGESIZE, |
| @@ -380,7 +380,8 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm, | |||
| 380 | down_write(¤t->mm->mmap_sem); | 380 | down_write(¤t->mm->mmap_sem); |
| 381 | current->mm->start_brk = do_mmap(NULL, 0, stack_size, | 381 | current->mm->start_brk = do_mmap(NULL, 0, stack_size, |
| 382 | PROT_READ | PROT_WRITE | PROT_EXEC, | 382 | PROT_READ | PROT_WRITE | PROT_EXEC, |
| 383 | MAP_PRIVATE | MAP_ANONYMOUS | MAP_GROWSDOWN, | 383 | MAP_PRIVATE | MAP_ANONYMOUS | |
| 384 | MAP_UNINITIALIZED | MAP_GROWSDOWN, | ||
| 384 | 0); | 385 | 0); |
| 385 | 386 | ||
| 386 | if (IS_ERR_VALUE(current->mm->start_brk)) { | 387 | if (IS_ERR_VALUE(current->mm->start_brk)) { |
| @@ -1200,7 +1201,7 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params, | |||
| 1200 | * | 1201 | * |
| 1201 | * Modelled on fs/binfmt_elf.c core dumper | 1202 | * Modelled on fs/binfmt_elf.c core dumper |
| 1202 | */ | 1203 | */ |
| 1203 | #if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE) | 1204 | #ifdef CONFIG_ELF_CORE |
| 1204 | 1205 | ||
| 1205 | /* | 1206 | /* |
| 1206 | * These are the only things you should do on a core-file: use only these | 1207 | * These are the only things you should do on a core-file: use only these |
| @@ -1325,8 +1326,9 @@ static int writenote(struct memelfnote *men, struct file *file) | |||
| 1325 | #undef DUMP_WRITE | 1326 | #undef DUMP_WRITE |
| 1326 | #undef DUMP_SEEK | 1327 | #undef DUMP_SEEK |
| 1327 | 1328 | ||
| 1328 | #define DUMP_WRITE(addr, nr) \ | 1329 | #define DUMP_WRITE(addr, nr) \ |
| 1329 | if ((size += (nr)) > limit || !dump_write(file, (addr), (nr))) \ | 1330 | if ((size += (nr)) > cprm->limit || \ |
| 1331 | !dump_write(cprm->file, (addr), (nr))) \ | ||
| 1330 | goto end_coredump; | 1332 | goto end_coredump; |
| 1331 | 1333 | ||
| 1332 | static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs) | 1334 | static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs) |
| @@ -1581,8 +1583,7 @@ static int elf_fdpic_dump_segments(struct file *file, size_t *size, | |||
| 1581 | * and then they are actually written out. If we run out of core limit | 1583 | * and then they are actually written out. If we run out of core limit |
| 1582 | * we just truncate. | 1584 | * we just truncate. |
| 1583 | */ | 1585 | */ |
| 1584 | static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, | 1586 | static int elf_fdpic_core_dump(struct coredump_params *cprm) |
| 1585 | struct file *file, unsigned long limit) | ||
| 1586 | { | 1587 | { |
| 1587 | #define NUM_NOTES 6 | 1588 | #define NUM_NOTES 6 |
| 1588 | int has_dumped = 0; | 1589 | int has_dumped = 0; |
| @@ -1641,7 +1642,7 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, | |||
| 1641 | goto cleanup; | 1642 | goto cleanup; |
| 1642 | #endif | 1643 | #endif |
| 1643 | 1644 | ||
| 1644 | if (signr) { | 1645 | if (cprm->signr) { |
| 1645 | struct core_thread *ct; | 1646 | struct core_thread *ct; |
| 1646 | struct elf_thread_status *tmp; | 1647 | struct elf_thread_status *tmp; |
| 1647 | 1648 | ||
| @@ -1660,14 +1661,14 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, | |||
| 1660 | int sz; | 1661 | int sz; |
| 1661 | 1662 | ||
| 1662 | tmp = list_entry(t, struct elf_thread_status, list); | 1663 | tmp = list_entry(t, struct elf_thread_status, list); |
| 1663 | sz = elf_dump_thread_status(signr, tmp); | 1664 | sz = elf_dump_thread_status(cprm->signr, tmp); |
| 1664 | thread_status_size += sz; | 1665 | thread_status_size += sz; |
| 1665 | } | 1666 | } |
| 1666 | } | 1667 | } |
| 1667 | 1668 | ||
| 1668 | /* now collect the dump for the current */ | 1669 | /* now collect the dump for the current */ |
| 1669 | fill_prstatus(prstatus, current, signr); | 1670 | fill_prstatus(prstatus, current, cprm->signr); |
| 1670 | elf_core_copy_regs(&prstatus->pr_reg, regs); | 1671 | elf_core_copy_regs(&prstatus->pr_reg, cprm->regs); |
| 1671 | 1672 | ||
| 1672 | segs = current->mm->map_count; | 1673 | segs = current->mm->map_count; |
| 1673 | #ifdef ELF_CORE_EXTRA_PHDRS | 1674 | #ifdef ELF_CORE_EXTRA_PHDRS |
| @@ -1702,7 +1703,7 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, | |||
| 1702 | 1703 | ||
| 1703 | /* Try to dump the FPU. */ | 1704 | /* Try to dump the FPU. */ |
| 1704 | if ((prstatus->pr_fpvalid = | 1705 | if ((prstatus->pr_fpvalid = |
| 1705 | elf_core_copy_task_fpregs(current, regs, fpu))) | 1706 | elf_core_copy_task_fpregs(current, cprm->regs, fpu))) |
| 1706 | fill_note(notes + numnote++, | 1707 | fill_note(notes + numnote++, |
| 1707 | "CORE", NT_PRFPREG, sizeof(*fpu), fpu); | 1708 | "CORE", NT_PRFPREG, sizeof(*fpu), fpu); |
| 1708 | #ifdef ELF_CORE_COPY_XFPREGS | 1709 | #ifdef ELF_CORE_COPY_XFPREGS |
| @@ -1773,7 +1774,7 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, | |||
| 1773 | 1774 | ||
| 1774 | /* write out the notes section */ | 1775 | /* write out the notes section */ |
| 1775 | for (i = 0; i < numnote; i++) | 1776 | for (i = 0; i < numnote; i++) |
| 1776 | if (!writenote(notes + i, file)) | 1777 | if (!writenote(notes + i, cprm->file)) |
| 1777 | goto end_coredump; | 1778 | goto end_coredump; |
| 1778 | 1779 | ||
| 1779 | /* write out the thread status notes section */ | 1780 | /* write out the thread status notes section */ |
| @@ -1782,14 +1783,15 @@ static int elf_fdpic_core_dump(long signr, struct pt_regs *regs, | |||
| 1782 | list_entry(t, struct elf_thread_status, list); | 1783 | list_entry(t, struct elf_thread_status, list); |
| 1783 | 1784 | ||
| 1784 | for (i = 0; i < tmp->num_notes; i++) | 1785 | for (i = 0; i < tmp->num_notes; i++) |
| 1785 | if (!writenote(&tmp->notes[i], file)) | 1786 | if (!writenote(&tmp->notes[i], cprm->file)) |
| 1786 | goto end_coredump; | 1787 | goto end_coredump; |
| 1787 | } | 1788 | } |
| 1788 | 1789 | ||
| 1789 | if (!dump_seek(file, dataoff)) | 1790 | if (!dump_seek(cprm->file, dataoff)) |
| 1790 | goto end_coredump; | 1791 | goto end_coredump; |
| 1791 | 1792 | ||
| 1792 | if (elf_fdpic_dump_segments(file, &size, &limit, mm_flags) < 0) | 1793 | if (elf_fdpic_dump_segments(cprm->file, &size, &cprm->limit, |
| 1794 | mm_flags) < 0) | ||
| 1793 | goto end_coredump; | 1795 | goto end_coredump; |
| 1794 | 1796 | ||
| 1795 | #ifdef ELF_CORE_WRITE_EXTRA_DATA | 1797 | #ifdef ELF_CORE_WRITE_EXTRA_DATA |
| @@ -1825,4 +1827,4 @@ cleanup: | |||
| 1825 | #undef NUM_NOTES | 1827 | #undef NUM_NOTES |
| 1826 | } | 1828 | } |
| 1827 | 1829 | ||
| 1828 | #endif /* USE_ELF_CORE_DUMP */ | 1830 | #endif /* CONFIG_ELF_CORE */ |
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index a2796651e756..d4a00ea1054c 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c | |||
| @@ -87,7 +87,7 @@ static int load_flat_shared_library(int id, struct lib_info *p); | |||
| 87 | #endif | 87 | #endif |
| 88 | 88 | ||
| 89 | static int load_flat_binary(struct linux_binprm *, struct pt_regs * regs); | 89 | static int load_flat_binary(struct linux_binprm *, struct pt_regs * regs); |
| 90 | static int flat_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit); | 90 | static int flat_core_dump(struct coredump_params *cprm); |
| 91 | 91 | ||
| 92 | static struct linux_binfmt flat_format = { | 92 | static struct linux_binfmt flat_format = { |
| 93 | .module = THIS_MODULE, | 93 | .module = THIS_MODULE, |
| @@ -102,10 +102,10 @@ static struct linux_binfmt flat_format = { | |||
| 102 | * Currently only a stub-function. | 102 | * Currently only a stub-function. |
| 103 | */ | 103 | */ |
| 104 | 104 | ||
| 105 | static int flat_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit) | 105 | static int flat_core_dump(struct coredump_params *cprm) |
| 106 | { | 106 | { |
| 107 | printk("Process %s:%d received signr %d and should have core dumped\n", | 107 | printk("Process %s:%d received signr %d and should have core dumped\n", |
| 108 | current->comm, current->pid, (int) signr); | 108 | current->comm, current->pid, (int) cprm->signr); |
| 109 | return(1); | 109 | return(1); |
| 110 | } | 110 | } |
| 111 | 111 | ||
diff --git a/fs/binfmt_som.c b/fs/binfmt_som.c index eff74b9c9e77..2a9b5330cc5e 100644 --- a/fs/binfmt_som.c +++ b/fs/binfmt_som.c | |||
| @@ -43,7 +43,7 @@ static int load_som_library(struct file *); | |||
| 43 | * don't even try. | 43 | * don't even try. |
| 44 | */ | 44 | */ |
| 45 | #if 0 | 45 | #if 0 |
| 46 | static int som_core_dump(long signr, struct pt_regs *regs, unsigned long limit); | 46 | static int som_core_dump(struct coredump_params *cprm); |
| 47 | #else | 47 | #else |
| 48 | #define som_core_dump NULL | 48 | #define som_core_dump NULL |
| 49 | #endif | 49 | #endif |
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c index 361604244271..2e9e69987a82 100644 --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c | |||
| @@ -73,13 +73,13 @@ static struct posix_acl *btrfs_get_acl(struct inode *inode, int type) | |||
| 73 | return acl; | 73 | return acl; |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | static int btrfs_xattr_get_acl(struct inode *inode, int type, | 76 | static int btrfs_xattr_acl_get(struct dentry *dentry, const char *name, |
| 77 | void *value, size_t size) | 77 | void *value, size_t size, int type) |
| 78 | { | 78 | { |
| 79 | struct posix_acl *acl; | 79 | struct posix_acl *acl; |
| 80 | int ret = 0; | 80 | int ret = 0; |
| 81 | 81 | ||
| 82 | acl = btrfs_get_acl(inode, type); | 82 | acl = btrfs_get_acl(dentry->d_inode, type); |
| 83 | 83 | ||
| 84 | if (IS_ERR(acl)) | 84 | if (IS_ERR(acl)) |
| 85 | return PTR_ERR(acl); | 85 | return PTR_ERR(acl); |
| @@ -94,7 +94,8 @@ static int btrfs_xattr_get_acl(struct inode *inode, int type, | |||
| 94 | /* | 94 | /* |
| 95 | * Needs to be called with fs_mutex held | 95 | * Needs to be called with fs_mutex held |
| 96 | */ | 96 | */ |
| 97 | static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) | 97 | static int btrfs_set_acl(struct btrfs_trans_handle *trans, |
| 98 | struct inode *inode, struct posix_acl *acl, int type) | ||
| 98 | { | 99 | { |
| 99 | int ret, size = 0; | 100 | int ret, size = 0; |
| 100 | const char *name; | 101 | const char *name; |
| @@ -140,8 +141,7 @@ static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) | |||
| 140 | goto out; | 141 | goto out; |
| 141 | } | 142 | } |
| 142 | 143 | ||
| 143 | ret = __btrfs_setxattr(inode, name, value, size, 0); | 144 | ret = __btrfs_setxattr(trans, inode, name, value, size, 0); |
| 144 | |||
| 145 | out: | 145 | out: |
| 146 | kfree(value); | 146 | kfree(value); |
| 147 | 147 | ||
| @@ -151,10 +151,10 @@ out: | |||
| 151 | return ret; | 151 | return ret; |
| 152 | } | 152 | } |
| 153 | 153 | ||
| 154 | static int btrfs_xattr_set_acl(struct inode *inode, int type, | 154 | static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name, |
| 155 | const void *value, size_t size) | 155 | const void *value, size_t size, int flags, int type) |
| 156 | { | 156 | { |
| 157 | int ret = 0; | 157 | int ret; |
| 158 | struct posix_acl *acl = NULL; | 158 | struct posix_acl *acl = NULL; |
| 159 | 159 | ||
| 160 | if (value) { | 160 | if (value) { |
| @@ -167,38 +167,13 @@ static int btrfs_xattr_set_acl(struct inode *inode, int type, | |||
| 167 | } | 167 | } |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | ret = btrfs_set_acl(inode, acl, type); | 170 | ret = btrfs_set_acl(NULL, dentry->d_inode, acl, type); |
| 171 | 171 | ||
| 172 | posix_acl_release(acl); | 172 | posix_acl_release(acl); |
| 173 | 173 | ||
| 174 | return ret; | 174 | return ret; |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | |||
| 178 | static int btrfs_xattr_acl_access_get(struct inode *inode, const char *name, | ||
| 179 | void *value, size_t size) | ||
| 180 | { | ||
| 181 | return btrfs_xattr_get_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
| 182 | } | ||
| 183 | |||
| 184 | static int btrfs_xattr_acl_access_set(struct inode *inode, const char *name, | ||
| 185 | const void *value, size_t size, int flags) | ||
| 186 | { | ||
| 187 | return btrfs_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
| 188 | } | ||
| 189 | |||
| 190 | static int btrfs_xattr_acl_default_get(struct inode *inode, const char *name, | ||
| 191 | void *value, size_t size) | ||
| 192 | { | ||
| 193 | return btrfs_xattr_get_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
| 194 | } | ||
| 195 | |||
| 196 | static int btrfs_xattr_acl_default_set(struct inode *inode, const char *name, | ||
| 197 | const void *value, size_t size, int flags) | ||
| 198 | { | ||
| 199 | return btrfs_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
| 200 | } | ||
| 201 | |||
| 202 | int btrfs_check_acl(struct inode *inode, int mask) | 177 | int btrfs_check_acl(struct inode *inode, int mask) |
| 203 | { | 178 | { |
| 204 | struct posix_acl *acl; | 179 | struct posix_acl *acl; |
| @@ -221,7 +196,8 @@ int btrfs_check_acl(struct inode *inode, int mask) | |||
| 221 | * stuff has been fixed to work with that. If the locking stuff changes, we | 196 | * stuff has been fixed to work with that. If the locking stuff changes, we |
| 222 | * need to re-evaluate the acl locking stuff. | 197 | * need to re-evaluate the acl locking stuff. |
| 223 | */ | 198 | */ |
| 224 | int btrfs_init_acl(struct inode *inode, struct inode *dir) | 199 | int btrfs_init_acl(struct btrfs_trans_handle *trans, |
| 200 | struct inode *inode, struct inode *dir) | ||
| 225 | { | 201 | { |
| 226 | struct posix_acl *acl = NULL; | 202 | struct posix_acl *acl = NULL; |
| 227 | int ret = 0; | 203 | int ret = 0; |
| @@ -246,7 +222,8 @@ int btrfs_init_acl(struct inode *inode, struct inode *dir) | |||
| 246 | mode_t mode; | 222 | mode_t mode; |
| 247 | 223 | ||
| 248 | if (S_ISDIR(inode->i_mode)) { | 224 | if (S_ISDIR(inode->i_mode)) { |
| 249 | ret = btrfs_set_acl(inode, acl, ACL_TYPE_DEFAULT); | 225 | ret = btrfs_set_acl(trans, inode, acl, |
| 226 | ACL_TYPE_DEFAULT); | ||
| 250 | if (ret) | 227 | if (ret) |
| 251 | goto failed; | 228 | goto failed; |
| 252 | } | 229 | } |
| @@ -261,7 +238,7 @@ int btrfs_init_acl(struct inode *inode, struct inode *dir) | |||
| 261 | inode->i_mode = mode; | 238 | inode->i_mode = mode; |
| 262 | if (ret > 0) { | 239 | if (ret > 0) { |
| 263 | /* we need an acl */ | 240 | /* we need an acl */ |
| 264 | ret = btrfs_set_acl(inode, clone, | 241 | ret = btrfs_set_acl(trans, inode, clone, |
| 265 | ACL_TYPE_ACCESS); | 242 | ACL_TYPE_ACCESS); |
| 266 | } | 243 | } |
| 267 | } | 244 | } |
| @@ -294,7 +271,7 @@ int btrfs_acl_chmod(struct inode *inode) | |||
| 294 | 271 | ||
| 295 | ret = posix_acl_chmod_masq(clone, inode->i_mode); | 272 | ret = posix_acl_chmod_masq(clone, inode->i_mode); |
| 296 | if (!ret) | 273 | if (!ret) |
| 297 | ret = btrfs_set_acl(inode, clone, ACL_TYPE_ACCESS); | 274 | ret = btrfs_set_acl(NULL, inode, clone, ACL_TYPE_ACCESS); |
| 298 | 275 | ||
| 299 | posix_acl_release(clone); | 276 | posix_acl_release(clone); |
| 300 | 277 | ||
| @@ -303,14 +280,16 @@ int btrfs_acl_chmod(struct inode *inode) | |||
| 303 | 280 | ||
| 304 | struct xattr_handler btrfs_xattr_acl_default_handler = { | 281 | struct xattr_handler btrfs_xattr_acl_default_handler = { |
| 305 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 282 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
| 306 | .get = btrfs_xattr_acl_default_get, | 283 | .flags = ACL_TYPE_DEFAULT, |
| 307 | .set = btrfs_xattr_acl_default_set, | 284 | .get = btrfs_xattr_acl_get, |
| 285 | .set = btrfs_xattr_acl_set, | ||
| 308 | }; | 286 | }; |
| 309 | 287 | ||
| 310 | struct xattr_handler btrfs_xattr_acl_access_handler = { | 288 | struct xattr_handler btrfs_xattr_acl_access_handler = { |
| 311 | .prefix = POSIX_ACL_XATTR_ACCESS, | 289 | .prefix = POSIX_ACL_XATTR_ACCESS, |
| 312 | .get = btrfs_xattr_acl_access_get, | 290 | .flags = ACL_TYPE_ACCESS, |
| 313 | .set = btrfs_xattr_acl_access_set, | 291 | .get = btrfs_xattr_acl_get, |
| 292 | .set = btrfs_xattr_acl_set, | ||
| 314 | }; | 293 | }; |
| 315 | 294 | ||
| 316 | #else /* CONFIG_BTRFS_FS_POSIX_ACL */ | 295 | #else /* CONFIG_BTRFS_FS_POSIX_ACL */ |
| @@ -320,7 +299,8 @@ int btrfs_acl_chmod(struct inode *inode) | |||
| 320 | return 0; | 299 | return 0; |
| 321 | } | 300 | } |
| 322 | 301 | ||
| 323 | int btrfs_init_acl(struct inode *inode, struct inode *dir) | 302 | int btrfs_init_acl(struct btrfs_trans_handle *trans, |
| 303 | struct inode *inode, struct inode *dir) | ||
| 324 | { | 304 | { |
| 325 | return 0; | 305 | return 0; |
| 326 | } | 306 | } |
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index f6783a42f010..3f1f50d9d916 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h | |||
| @@ -44,9 +44,6 @@ struct btrfs_inode { | |||
| 44 | */ | 44 | */ |
| 45 | struct extent_io_tree io_failure_tree; | 45 | struct extent_io_tree io_failure_tree; |
| 46 | 46 | ||
| 47 | /* held while inesrting or deleting extents from files */ | ||
| 48 | struct mutex extent_mutex; | ||
| 49 | |||
| 50 | /* held while logging the inode in tree-log.c */ | 47 | /* held while logging the inode in tree-log.c */ |
| 51 | struct mutex log_mutex; | 48 | struct mutex log_mutex; |
| 52 | 49 | ||
| @@ -166,7 +163,7 @@ static inline struct btrfs_inode *BTRFS_I(struct inode *inode) | |||
| 166 | 163 | ||
| 167 | static inline void btrfs_i_size_write(struct inode *inode, u64 size) | 164 | static inline void btrfs_i_size_write(struct inode *inode, u64 size) |
| 168 | { | 165 | { |
| 169 | inode->i_size = size; | 166 | i_size_write(inode, size); |
| 170 | BTRFS_I(inode)->disk_i_size = size; | 167 | BTRFS_I(inode)->disk_i_size = size; |
| 171 | } | 168 | } |
| 172 | 169 | ||
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index ec96f3a6d536..c4bc570a396e 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
| @@ -37,6 +37,11 @@ static int balance_node_right(struct btrfs_trans_handle *trans, | |||
| 37 | struct extent_buffer *src_buf); | 37 | struct extent_buffer *src_buf); |
| 38 | static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, | 38 | static int del_ptr(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
| 39 | struct btrfs_path *path, int level, int slot); | 39 | struct btrfs_path *path, int level, int slot); |
| 40 | static int setup_items_for_insert(struct btrfs_trans_handle *trans, | ||
| 41 | struct btrfs_root *root, struct btrfs_path *path, | ||
| 42 | struct btrfs_key *cpu_key, u32 *data_size, | ||
| 43 | u32 total_data, u32 total_size, int nr); | ||
| 44 | |||
| 40 | 45 | ||
| 41 | struct btrfs_path *btrfs_alloc_path(void) | 46 | struct btrfs_path *btrfs_alloc_path(void) |
| 42 | { | 47 | { |
| @@ -451,9 +456,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, | |||
| 451 | extent_buffer_get(cow); | 456 | extent_buffer_get(cow); |
| 452 | spin_unlock(&root->node_lock); | 457 | spin_unlock(&root->node_lock); |
| 453 | 458 | ||
| 454 | btrfs_free_extent(trans, root, buf->start, buf->len, | 459 | btrfs_free_tree_block(trans, root, buf->start, buf->len, |
| 455 | parent_start, root->root_key.objectid, | 460 | parent_start, root->root_key.objectid, level); |
| 456 | level, 0); | ||
| 457 | free_extent_buffer(buf); | 461 | free_extent_buffer(buf); |
| 458 | add_root_to_dirty_list(root); | 462 | add_root_to_dirty_list(root); |
| 459 | } else { | 463 | } else { |
| @@ -468,9 +472,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, | |||
| 468 | btrfs_set_node_ptr_generation(parent, parent_slot, | 472 | btrfs_set_node_ptr_generation(parent, parent_slot, |
| 469 | trans->transid); | 473 | trans->transid); |
| 470 | btrfs_mark_buffer_dirty(parent); | 474 | btrfs_mark_buffer_dirty(parent); |
| 471 | btrfs_free_extent(trans, root, buf->start, buf->len, | 475 | btrfs_free_tree_block(trans, root, buf->start, buf->len, |
| 472 | parent_start, root->root_key.objectid, | 476 | parent_start, root->root_key.objectid, level); |
| 473 | level, 0); | ||
| 474 | } | 477 | } |
| 475 | if (unlock_orig) | 478 | if (unlock_orig) |
| 476 | btrfs_tree_unlock(buf); | 479 | btrfs_tree_unlock(buf); |
| @@ -1030,8 +1033,8 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, | |||
| 1030 | btrfs_tree_unlock(mid); | 1033 | btrfs_tree_unlock(mid); |
| 1031 | /* once for the path */ | 1034 | /* once for the path */ |
| 1032 | free_extent_buffer(mid); | 1035 | free_extent_buffer(mid); |
| 1033 | ret = btrfs_free_extent(trans, root, mid->start, mid->len, | 1036 | ret = btrfs_free_tree_block(trans, root, mid->start, mid->len, |
| 1034 | 0, root->root_key.objectid, level, 1); | 1037 | 0, root->root_key.objectid, level); |
| 1035 | /* once for the root ptr */ | 1038 | /* once for the root ptr */ |
| 1036 | free_extent_buffer(mid); | 1039 | free_extent_buffer(mid); |
| 1037 | return ret; | 1040 | return ret; |
| @@ -1095,10 +1098,10 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, | |||
| 1095 | 1); | 1098 | 1); |
| 1096 | if (wret) | 1099 | if (wret) |
| 1097 | ret = wret; | 1100 | ret = wret; |
| 1098 | wret = btrfs_free_extent(trans, root, bytenr, | 1101 | wret = btrfs_free_tree_block(trans, root, |
| 1099 | blocksize, 0, | 1102 | bytenr, blocksize, 0, |
| 1100 | root->root_key.objectid, | 1103 | root->root_key.objectid, |
| 1101 | level, 0); | 1104 | level); |
| 1102 | if (wret) | 1105 | if (wret) |
| 1103 | ret = wret; | 1106 | ret = wret; |
| 1104 | } else { | 1107 | } else { |
| @@ -1143,9 +1146,8 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, | |||
| 1143 | wret = del_ptr(trans, root, path, level + 1, pslot); | 1146 | wret = del_ptr(trans, root, path, level + 1, pslot); |
| 1144 | if (wret) | 1147 | if (wret) |
| 1145 | ret = wret; | 1148 | ret = wret; |
| 1146 | wret = btrfs_free_extent(trans, root, bytenr, blocksize, | 1149 | wret = btrfs_free_tree_block(trans, root, bytenr, blocksize, |
| 1147 | 0, root->root_key.objectid, | 1150 | 0, root->root_key.objectid, level); |
| 1148 | level, 0); | ||
| 1149 | if (wret) | 1151 | if (wret) |
| 1150 | ret = wret; | 1152 | ret = wret; |
| 1151 | } else { | 1153 | } else { |
| @@ -2997,75 +2999,85 @@ again: | |||
| 2997 | return ret; | 2999 | return ret; |
| 2998 | } | 3000 | } |
| 2999 | 3001 | ||
| 3000 | /* | 3002 | static noinline int setup_leaf_for_split(struct btrfs_trans_handle *trans, |
| 3001 | * This function splits a single item into two items, | 3003 | struct btrfs_root *root, |
| 3002 | * giving 'new_key' to the new item and splitting the | 3004 | struct btrfs_path *path, int ins_len) |
| 3003 | * old one at split_offset (from the start of the item). | ||
| 3004 | * | ||
| 3005 | * The path may be released by this operation. After | ||
| 3006 | * the split, the path is pointing to the old item. The | ||
| 3007 | * new item is going to be in the same node as the old one. | ||
| 3008 | * | ||
| 3009 | * Note, the item being split must be smaller enough to live alone on | ||
| 3010 | * a tree block with room for one extra struct btrfs_item | ||
| 3011 | * | ||
| 3012 | * This allows us to split the item in place, keeping a lock on the | ||
| 3013 | * leaf the entire time. | ||
| 3014 | */ | ||
| 3015 | int btrfs_split_item(struct btrfs_trans_handle *trans, | ||
| 3016 | struct btrfs_root *root, | ||
| 3017 | struct btrfs_path *path, | ||
| 3018 | struct btrfs_key *new_key, | ||
| 3019 | unsigned long split_offset) | ||
| 3020 | { | 3005 | { |
| 3021 | u32 item_size; | 3006 | struct btrfs_key key; |
| 3022 | struct extent_buffer *leaf; | 3007 | struct extent_buffer *leaf; |
| 3023 | struct btrfs_key orig_key; | 3008 | struct btrfs_file_extent_item *fi; |
| 3024 | struct btrfs_item *item; | 3009 | u64 extent_len = 0; |
| 3025 | struct btrfs_item *new_item; | 3010 | u32 item_size; |
| 3026 | int ret = 0; | 3011 | int ret; |
| 3027 | int slot; | ||
| 3028 | u32 nritems; | ||
| 3029 | u32 orig_offset; | ||
| 3030 | struct btrfs_disk_key disk_key; | ||
| 3031 | char *buf; | ||
| 3032 | 3012 | ||
| 3033 | leaf = path->nodes[0]; | 3013 | leaf = path->nodes[0]; |
| 3034 | btrfs_item_key_to_cpu(leaf, &orig_key, path->slots[0]); | 3014 | btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); |
| 3035 | if (btrfs_leaf_free_space(root, leaf) >= sizeof(struct btrfs_item)) | 3015 | |
| 3036 | goto split; | 3016 | BUG_ON(key.type != BTRFS_EXTENT_DATA_KEY && |
| 3017 | key.type != BTRFS_EXTENT_CSUM_KEY); | ||
| 3018 | |||
| 3019 | if (btrfs_leaf_free_space(root, leaf) >= ins_len) | ||
| 3020 | return 0; | ||
| 3037 | 3021 | ||
| 3038 | item_size = btrfs_item_size_nr(leaf, path->slots[0]); | 3022 | item_size = btrfs_item_size_nr(leaf, path->slots[0]); |
| 3023 | if (key.type == BTRFS_EXTENT_DATA_KEY) { | ||
| 3024 | fi = btrfs_item_ptr(leaf, path->slots[0], | ||
| 3025 | struct btrfs_file_extent_item); | ||
| 3026 | extent_len = btrfs_file_extent_num_bytes(leaf, fi); | ||
| 3027 | } | ||
| 3039 | btrfs_release_path(root, path); | 3028 | btrfs_release_path(root, path); |
| 3040 | 3029 | ||
| 3041 | path->search_for_split = 1; | ||
| 3042 | path->keep_locks = 1; | 3030 | path->keep_locks = 1; |
| 3043 | 3031 | path->search_for_split = 1; | |
| 3044 | ret = btrfs_search_slot(trans, root, &orig_key, path, 0, 1); | 3032 | ret = btrfs_search_slot(trans, root, &key, path, 0, 1); |
| 3045 | path->search_for_split = 0; | 3033 | path->search_for_split = 0; |
| 3034 | if (ret < 0) | ||
| 3035 | goto err; | ||
| 3046 | 3036 | ||
| 3037 | ret = -EAGAIN; | ||
| 3038 | leaf = path->nodes[0]; | ||
| 3047 | /* if our item isn't there or got smaller, return now */ | 3039 | /* if our item isn't there or got smaller, return now */ |
| 3048 | if (ret != 0 || item_size != btrfs_item_size_nr(path->nodes[0], | 3040 | if (ret > 0 || item_size != btrfs_item_size_nr(leaf, path->slots[0])) |
| 3049 | path->slots[0])) { | 3041 | goto err; |
| 3050 | path->keep_locks = 0; | 3042 | |
| 3051 | return -EAGAIN; | 3043 | if (key.type == BTRFS_EXTENT_DATA_KEY) { |
| 3044 | fi = btrfs_item_ptr(leaf, path->slots[0], | ||
| 3045 | struct btrfs_file_extent_item); | ||
| 3046 | if (extent_len != btrfs_file_extent_num_bytes(leaf, fi)) | ||
| 3047 | goto err; | ||
| 3052 | } | 3048 | } |
| 3053 | 3049 | ||
| 3054 | btrfs_set_path_blocking(path); | 3050 | btrfs_set_path_blocking(path); |
| 3055 | ret = split_leaf(trans, root, &orig_key, path, | 3051 | ret = split_leaf(trans, root, &key, path, ins_len, 1); |
| 3056 | sizeof(struct btrfs_item), 1); | ||
| 3057 | path->keep_locks = 0; | ||
| 3058 | BUG_ON(ret); | 3052 | BUG_ON(ret); |
| 3059 | 3053 | ||
| 3054 | path->keep_locks = 0; | ||
| 3060 | btrfs_unlock_up_safe(path, 1); | 3055 | btrfs_unlock_up_safe(path, 1); |
| 3056 | return 0; | ||
| 3057 | err: | ||
| 3058 | path->keep_locks = 0; | ||
| 3059 | return ret; | ||
| 3060 | } | ||
| 3061 | |||
| 3062 | static noinline int split_item(struct btrfs_trans_handle *trans, | ||
| 3063 | struct btrfs_root *root, | ||
| 3064 | struct btrfs_path *path, | ||
| 3065 | struct btrfs_key *new_key, | ||
| 3066 | unsigned long split_offset) | ||
| 3067 | { | ||
| 3068 | struct extent_buffer *leaf; | ||
| 3069 | struct btrfs_item *item; | ||
| 3070 | struct btrfs_item *new_item; | ||
| 3071 | int slot; | ||
| 3072 | char *buf; | ||
| 3073 | u32 nritems; | ||
| 3074 | u32 item_size; | ||
| 3075 | u32 orig_offset; | ||
| 3076 | struct btrfs_disk_key disk_key; | ||
| 3077 | |||
| 3061 | leaf = path->nodes[0]; | 3078 | leaf = path->nodes[0]; |
| 3062 | BUG_ON(btrfs_leaf_free_space(root, leaf) < sizeof(struct btrfs_item)); | 3079 | BUG_ON(btrfs_leaf_free_space(root, leaf) < sizeof(struct btrfs_item)); |
| 3063 | 3080 | ||
| 3064 | split: | ||
| 3065 | /* | ||
| 3066 | * make sure any changes to the path from split_leaf leave it | ||
| 3067 | * in a blocking state | ||
| 3068 | */ | ||
| 3069 | btrfs_set_path_blocking(path); | 3081 | btrfs_set_path_blocking(path); |
| 3070 | 3082 | ||
| 3071 | item = btrfs_item_nr(leaf, path->slots[0]); | 3083 | item = btrfs_item_nr(leaf, path->slots[0]); |
| @@ -3073,19 +3085,19 @@ split: | |||
| 3073 | item_size = btrfs_item_size(leaf, item); | 3085 | item_size = btrfs_item_size(leaf, item); |
| 3074 | 3086 | ||
| 3075 | buf = kmalloc(item_size, GFP_NOFS); | 3087 | buf = kmalloc(item_size, GFP_NOFS); |
| 3088 | if (!buf) | ||
| 3089 | return -ENOMEM; | ||
| 3090 | |||
| 3076 | read_extent_buffer(leaf, buf, btrfs_item_ptr_offset(leaf, | 3091 | read_extent_buffer(leaf, buf, btrfs_item_ptr_offset(leaf, |
| 3077 | path->slots[0]), item_size); | 3092 | path->slots[0]), item_size); |
| 3078 | slot = path->slots[0] + 1; | ||
| 3079 | leaf = path->nodes[0]; | ||
| 3080 | 3093 | ||
| 3094 | slot = path->slots[0] + 1; | ||
| 3081 | nritems = btrfs_header_nritems(leaf); | 3095 | nritems = btrfs_header_nritems(leaf); |
| 3082 | |||
| 3083 | if (slot != nritems) { | 3096 | if (slot != nritems) { |
| 3084 | /* shift the items */ | 3097 | /* shift the items */ |
| 3085 | memmove_extent_buffer(leaf, btrfs_item_nr_offset(slot + 1), | 3098 | memmove_extent_buffer(leaf, btrfs_item_nr_offset(slot + 1), |
| 3086 | btrfs_item_nr_offset(slot), | 3099 | btrfs_item_nr_offset(slot), |
| 3087 | (nritems - slot) * sizeof(struct btrfs_item)); | 3100 | (nritems - slot) * sizeof(struct btrfs_item)); |
| 3088 | |||
| 3089 | } | 3101 | } |
| 3090 | 3102 | ||
| 3091 | btrfs_cpu_key_to_disk(&disk_key, new_key); | 3103 | btrfs_cpu_key_to_disk(&disk_key, new_key); |
| @@ -3113,16 +3125,81 @@ split: | |||
| 3113 | item_size - split_offset); | 3125 | item_size - split_offset); |
| 3114 | btrfs_mark_buffer_dirty(leaf); | 3126 | btrfs_mark_buffer_dirty(leaf); |
| 3115 | 3127 | ||
| 3116 | ret = 0; | 3128 | BUG_ON(btrfs_leaf_free_space(root, leaf) < 0); |
| 3117 | if (btrfs_leaf_free_space(root, leaf) < 0) { | ||
| 3118 | btrfs_print_leaf(root, leaf); | ||
| 3119 | BUG(); | ||
| 3120 | } | ||
| 3121 | kfree(buf); | 3129 | kfree(buf); |
| 3130 | return 0; | ||
| 3131 | } | ||
| 3132 | |||
| 3133 | /* | ||
| 3134 | * This function splits a single item into two items, | ||
| 3135 | * giving 'new_key' to the new item and splitting the | ||
| 3136 | * old one at split_offset (from the start of the item). | ||
| 3137 | * | ||
| 3138 | * The path may be released by this operation. After | ||
| 3139 | * the split, the path is pointing to the old item. The | ||
| 3140 | * new item is going to be in the same node as the old one. | ||
| 3141 | * | ||
| 3142 | * Note, the item being split must be smaller enough to live alone on | ||
| 3143 | * a tree block with room for one extra struct btrfs_item | ||
| 3144 | * | ||
| 3145 | * This allows us to split the item in place, keeping a lock on the | ||
| 3146 | * leaf the entire time. | ||
| 3147 | */ | ||
| 3148 | int btrfs_split_item(struct btrfs_trans_handle *trans, | ||
| 3149 | struct btrfs_root *root, | ||
| 3150 | struct btrfs_path *path, | ||
| 3151 | struct btrfs_key *new_key, | ||
| 3152 | unsigned long split_offset) | ||
| 3153 | { | ||
| 3154 | int ret; | ||
| 3155 | ret = setup_leaf_for_split(trans, root, path, | ||
| 3156 | sizeof(struct btrfs_item)); | ||
| 3157 | if (ret) | ||
| 3158 | return ret; | ||
| 3159 | |||
| 3160 | ret = split_item(trans, root, path, new_key, split_offset); | ||
| 3122 | return ret; | 3161 | return ret; |
| 3123 | } | 3162 | } |
| 3124 | 3163 | ||
| 3125 | /* | 3164 | /* |
| 3165 | * This function duplicate a item, giving 'new_key' to the new item. | ||
| 3166 | * It guarantees both items live in the same tree leaf and the new item | ||
| 3167 | * is contiguous with the original item. | ||
| 3168 | * | ||
| 3169 | * This allows us to split file extent in place, keeping a lock on the | ||
| 3170 | * leaf the entire time. | ||
| 3171 | */ | ||
| 3172 | int btrfs_duplicate_item(struct btrfs_trans_handle *trans, | ||
| 3173 | struct btrfs_root *root, | ||
| 3174 | struct btrfs_path *path, | ||
| 3175 | struct btrfs_key *new_key) | ||
| 3176 | { | ||
| 3177 | struct extent_buffer *leaf; | ||
| 3178 | int ret; | ||
| 3179 | u32 item_size; | ||
| 3180 | |||
| 3181 | leaf = path->nodes[0]; | ||
| 3182 | item_size = btrfs_item_size_nr(leaf, path->slots[0]); | ||
| 3183 | ret = setup_leaf_for_split(trans, root, path, | ||
| 3184 | item_size + sizeof(struct btrfs_item)); | ||
| 3185 | if (ret) | ||
| 3186 | return ret; | ||
| 3187 | |||
| 3188 | path->slots[0]++; | ||
| 3189 | ret = setup_items_for_insert(trans, root, path, new_key, &item_size, | ||
| 3190 | item_size, item_size + | ||
| 3191 | sizeof(struct btrfs_item), 1); | ||
| 3192 | BUG_ON(ret); | ||
| 3193 | |||
| 3194 | leaf = path->nodes[0]; | ||
| 3195 | memcpy_extent_buffer(leaf, | ||
| 3196 | btrfs_item_ptr_offset(leaf, path->slots[0]), | ||
| 3197 | btrfs_item_ptr_offset(leaf, path->slots[0] - 1), | ||
| 3198 | item_size); | ||
| 3199 | return 0; | ||
| 3200 | } | ||
| 3201 | |||
| 3202 | /* | ||
| 3126 | * make the item pointed to by the path smaller. new_size indicates | 3203 | * make the item pointed to by the path smaller. new_size indicates |
| 3127 | * how small to make it, and from_end tells us if we just chop bytes | 3204 | * how small to make it, and from_end tells us if we just chop bytes |
| 3128 | * off the end of the item or if we shift the item to chop bytes off | 3205 | * off the end of the item or if we shift the item to chop bytes off |
| @@ -3714,8 +3791,8 @@ static noinline int btrfs_del_leaf(struct btrfs_trans_handle *trans, | |||
| 3714 | */ | 3791 | */ |
| 3715 | btrfs_unlock_up_safe(path, 0); | 3792 | btrfs_unlock_up_safe(path, 0); |
| 3716 | 3793 | ||
| 3717 | ret = btrfs_free_extent(trans, root, leaf->start, leaf->len, | 3794 | ret = btrfs_free_tree_block(trans, root, leaf->start, leaf->len, |
| 3718 | 0, root->root_key.objectid, 0, 0); | 3795 | 0, root->root_key.objectid, 0); |
| 3719 | return ret; | 3796 | return ret; |
| 3720 | } | 3797 | } |
| 3721 | /* | 3798 | /* |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 444b3e9b92a4..9f806dd04c27 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
| @@ -310,6 +310,9 @@ struct btrfs_header { | |||
| 310 | #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \ | 310 | #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \ |
| 311 | sizeof(struct btrfs_item) - \ | 311 | sizeof(struct btrfs_item) - \ |
| 312 | sizeof(struct btrfs_file_extent_item)) | 312 | sizeof(struct btrfs_file_extent_item)) |
| 313 | #define BTRFS_MAX_XATTR_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \ | ||
| 314 | sizeof(struct btrfs_item) -\ | ||
| 315 | sizeof(struct btrfs_dir_item)) | ||
| 313 | 316 | ||
| 314 | 317 | ||
| 315 | /* | 318 | /* |
| @@ -859,8 +862,9 @@ struct btrfs_fs_info { | |||
| 859 | struct mutex ordered_operations_mutex; | 862 | struct mutex ordered_operations_mutex; |
| 860 | struct rw_semaphore extent_commit_sem; | 863 | struct rw_semaphore extent_commit_sem; |
| 861 | 864 | ||
| 862 | struct rw_semaphore subvol_sem; | 865 | struct rw_semaphore cleanup_work_sem; |
| 863 | 866 | ||
| 867 | struct rw_semaphore subvol_sem; | ||
| 864 | struct srcu_struct subvol_srcu; | 868 | struct srcu_struct subvol_srcu; |
| 865 | 869 | ||
| 866 | struct list_head trans_list; | 870 | struct list_head trans_list; |
| @@ -868,6 +872,9 @@ struct btrfs_fs_info { | |||
| 868 | struct list_head dead_roots; | 872 | struct list_head dead_roots; |
| 869 | struct list_head caching_block_groups; | 873 | struct list_head caching_block_groups; |
| 870 | 874 | ||
| 875 | spinlock_t delayed_iput_lock; | ||
| 876 | struct list_head delayed_iputs; | ||
| 877 | |||
| 871 | atomic_t nr_async_submits; | 878 | atomic_t nr_async_submits; |
| 872 | atomic_t async_submit_draining; | 879 | atomic_t async_submit_draining; |
| 873 | atomic_t nr_async_bios; | 880 | atomic_t nr_async_bios; |
| @@ -1034,12 +1041,12 @@ struct btrfs_root { | |||
| 1034 | int ref_cows; | 1041 | int ref_cows; |
| 1035 | int track_dirty; | 1042 | int track_dirty; |
| 1036 | int in_radix; | 1043 | int in_radix; |
| 1044 | int clean_orphans; | ||
| 1037 | 1045 | ||
| 1038 | u64 defrag_trans_start; | 1046 | u64 defrag_trans_start; |
| 1039 | struct btrfs_key defrag_progress; | 1047 | struct btrfs_key defrag_progress; |
| 1040 | struct btrfs_key defrag_max; | 1048 | struct btrfs_key defrag_max; |
| 1041 | int defrag_running; | 1049 | int defrag_running; |
| 1042 | int defrag_level; | ||
| 1043 | char *name; | 1050 | char *name; |
| 1044 | int in_sysfs; | 1051 | int in_sysfs; |
| 1045 | 1052 | ||
| @@ -1975,6 +1982,10 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, | |||
| 1975 | u64 parent, u64 root_objectid, | 1982 | u64 parent, u64 root_objectid, |
| 1976 | struct btrfs_disk_key *key, int level, | 1983 | struct btrfs_disk_key *key, int level, |
| 1977 | u64 hint, u64 empty_size); | 1984 | u64 hint, u64 empty_size); |
| 1985 | int btrfs_free_tree_block(struct btrfs_trans_handle *trans, | ||
| 1986 | struct btrfs_root *root, | ||
| 1987 | u64 bytenr, u32 blocksize, | ||
| 1988 | u64 parent, u64 root_objectid, int level); | ||
| 1978 | struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans, | 1989 | struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans, |
| 1979 | struct btrfs_root *root, | 1990 | struct btrfs_root *root, |
| 1980 | u64 bytenr, u32 blocksize, | 1991 | u64 bytenr, u32 blocksize, |
| @@ -2089,6 +2100,10 @@ int btrfs_split_item(struct btrfs_trans_handle *trans, | |||
| 2089 | struct btrfs_path *path, | 2100 | struct btrfs_path *path, |
| 2090 | struct btrfs_key *new_key, | 2101 | struct btrfs_key *new_key, |
| 2091 | unsigned long split_offset); | 2102 | unsigned long split_offset); |
| 2103 | int btrfs_duplicate_item(struct btrfs_trans_handle *trans, | ||
| 2104 | struct btrfs_root *root, | ||
| 2105 | struct btrfs_path *path, | ||
| 2106 | struct btrfs_key *new_key); | ||
| 2092 | int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root | 2107 | int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root |
| 2093 | *root, struct btrfs_key *key, struct btrfs_path *p, int | 2108 | *root, struct btrfs_key *key, struct btrfs_path *p, int |
| 2094 | ins_len, int cow); | 2109 | ins_len, int cow); |
| @@ -2196,9 +2211,10 @@ int btrfs_delete_one_dir_name(struct btrfs_trans_handle *trans, | |||
| 2196 | struct btrfs_path *path, | 2211 | struct btrfs_path *path, |
| 2197 | struct btrfs_dir_item *di); | 2212 | struct btrfs_dir_item *di); |
| 2198 | int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans, | 2213 | int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans, |
| 2199 | struct btrfs_root *root, const char *name, | 2214 | struct btrfs_root *root, |
| 2200 | u16 name_len, const void *data, u16 data_len, | 2215 | struct btrfs_path *path, u64 objectid, |
| 2201 | u64 dir); | 2216 | const char *name, u16 name_len, |
| 2217 | const void *data, u16 data_len); | ||
| 2202 | struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans, | 2218 | struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans, |
| 2203 | struct btrfs_root *root, | 2219 | struct btrfs_root *root, |
| 2204 | struct btrfs_path *path, u64 dir, | 2220 | struct btrfs_path *path, u64 dir, |
| @@ -2292,7 +2308,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, | |||
| 2292 | struct inode *inode, u64 new_size, | 2308 | struct inode *inode, u64 new_size, |
| 2293 | u32 min_type); | 2309 | u32 min_type); |
| 2294 | 2310 | ||
| 2295 | int btrfs_start_delalloc_inodes(struct btrfs_root *root); | 2311 | int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput); |
| 2296 | int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end); | 2312 | int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end); |
| 2297 | int btrfs_writepages(struct address_space *mapping, | 2313 | int btrfs_writepages(struct address_space *mapping, |
| 2298 | struct writeback_control *wbc); | 2314 | struct writeback_control *wbc); |
| @@ -2332,6 +2348,8 @@ int btrfs_orphan_del(struct btrfs_trans_handle *trans, struct inode *inode); | |||
| 2332 | void btrfs_orphan_cleanup(struct btrfs_root *root); | 2348 | void btrfs_orphan_cleanup(struct btrfs_root *root); |
| 2333 | int btrfs_cont_expand(struct inode *inode, loff_t size); | 2349 | int btrfs_cont_expand(struct inode *inode, loff_t size); |
| 2334 | int btrfs_invalidate_inodes(struct btrfs_root *root); | 2350 | int btrfs_invalidate_inodes(struct btrfs_root *root); |
| 2351 | void btrfs_add_delayed_iput(struct inode *inode); | ||
| 2352 | void btrfs_run_delayed_iputs(struct btrfs_root *root); | ||
| 2335 | extern const struct dentry_operations btrfs_dentry_operations; | 2353 | extern const struct dentry_operations btrfs_dentry_operations; |
| 2336 | 2354 | ||
| 2337 | /* ioctl.c */ | 2355 | /* ioctl.c */ |
| @@ -2345,12 +2363,9 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end, | |||
| 2345 | int skip_pinned); | 2363 | int skip_pinned); |
| 2346 | int btrfs_check_file(struct btrfs_root *root, struct inode *inode); | 2364 | int btrfs_check_file(struct btrfs_root *root, struct inode *inode); |
| 2347 | extern const struct file_operations btrfs_file_operations; | 2365 | extern const struct file_operations btrfs_file_operations; |
| 2348 | int btrfs_drop_extents(struct btrfs_trans_handle *trans, | 2366 | int btrfs_drop_extents(struct btrfs_trans_handle *trans, struct inode *inode, |
| 2349 | struct btrfs_root *root, struct inode *inode, | 2367 | u64 start, u64 end, u64 *hint_byte, int drop_cache); |
| 2350 | u64 start, u64 end, u64 locked_end, | ||
| 2351 | u64 inline_limit, u64 *hint_block, int drop_cache); | ||
| 2352 | int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, | 2368 | int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, |
| 2353 | struct btrfs_root *root, | ||
| 2354 | struct inode *inode, u64 start, u64 end); | 2369 | struct inode *inode, u64 start, u64 end); |
| 2355 | int btrfs_release_file(struct inode *inode, struct file *file); | 2370 | int btrfs_release_file(struct inode *inode, struct file *file); |
| 2356 | 2371 | ||
| @@ -2380,7 +2395,8 @@ int btrfs_check_acl(struct inode *inode, int mask); | |||
| 2380 | #else | 2395 | #else |
| 2381 | #define btrfs_check_acl NULL | 2396 | #define btrfs_check_acl NULL |
| 2382 | #endif | 2397 | #endif |
| 2383 | int btrfs_init_acl(struct inode *inode, struct inode *dir); | 2398 | int btrfs_init_acl(struct btrfs_trans_handle *trans, |
| 2399 | struct inode *inode, struct inode *dir); | ||
| 2384 | int btrfs_acl_chmod(struct inode *inode); | 2400 | int btrfs_acl_chmod(struct inode *inode); |
| 2385 | 2401 | ||
| 2386 | /* relocation.c */ | 2402 | /* relocation.c */ |
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c index f3a6075519cc..e9103b3baa49 100644 --- a/fs/btrfs/dir-item.c +++ b/fs/btrfs/dir-item.c | |||
| @@ -68,12 +68,12 @@ static struct btrfs_dir_item *insert_with_overflow(struct btrfs_trans_handle | |||
| 68 | * into the tree | 68 | * into the tree |
| 69 | */ | 69 | */ |
| 70 | int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans, | 70 | int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans, |
| 71 | struct btrfs_root *root, const char *name, | 71 | struct btrfs_root *root, |
| 72 | u16 name_len, const void *data, u16 data_len, | 72 | struct btrfs_path *path, u64 objectid, |
| 73 | u64 dir) | 73 | const char *name, u16 name_len, |
| 74 | const void *data, u16 data_len) | ||
| 74 | { | 75 | { |
| 75 | int ret = 0; | 76 | int ret = 0; |
| 76 | struct btrfs_path *path; | ||
| 77 | struct btrfs_dir_item *dir_item; | 77 | struct btrfs_dir_item *dir_item; |
| 78 | unsigned long name_ptr, data_ptr; | 78 | unsigned long name_ptr, data_ptr; |
| 79 | struct btrfs_key key, location; | 79 | struct btrfs_key key, location; |
| @@ -81,15 +81,11 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans, | |||
| 81 | struct extent_buffer *leaf; | 81 | struct extent_buffer *leaf; |
| 82 | u32 data_size; | 82 | u32 data_size; |
| 83 | 83 | ||
| 84 | key.objectid = dir; | 84 | BUG_ON(name_len + data_len > BTRFS_MAX_XATTR_SIZE(root)); |
| 85 | |||
| 86 | key.objectid = objectid; | ||
| 85 | btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY); | 87 | btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY); |
| 86 | key.offset = btrfs_name_hash(name, name_len); | 88 | key.offset = btrfs_name_hash(name, name_len); |
| 87 | path = btrfs_alloc_path(); | ||
| 88 | if (!path) | ||
| 89 | return -ENOMEM; | ||
| 90 | if (name_len + data_len + sizeof(struct btrfs_dir_item) > | ||
| 91 | BTRFS_LEAF_DATA_SIZE(root) - sizeof(struct btrfs_item)) | ||
| 92 | return -ENOSPC; | ||
| 93 | 89 | ||
| 94 | data_size = sizeof(*dir_item) + name_len + data_len; | 90 | data_size = sizeof(*dir_item) + name_len + data_len; |
| 95 | dir_item = insert_with_overflow(trans, root, path, &key, data_size, | 91 | dir_item = insert_with_overflow(trans, root, path, &key, data_size, |
| @@ -117,7 +113,6 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans, | |||
| 117 | write_extent_buffer(leaf, data, data_ptr, data_len); | 113 | write_extent_buffer(leaf, data, data_ptr, data_len); |
| 118 | btrfs_mark_buffer_dirty(path->nodes[0]); | 114 | btrfs_mark_buffer_dirty(path->nodes[0]); |
| 119 | 115 | ||
| 120 | btrfs_free_path(path); | ||
| 121 | return ret; | 116 | return ret; |
| 122 | } | 117 | } |
| 123 | 118 | ||
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 02b6afbd7450..009e3bd18f23 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
| @@ -892,6 +892,8 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize, | |||
| 892 | root->stripesize = stripesize; | 892 | root->stripesize = stripesize; |
| 893 | root->ref_cows = 0; | 893 | root->ref_cows = 0; |
| 894 | root->track_dirty = 0; | 894 | root->track_dirty = 0; |
| 895 | root->in_radix = 0; | ||
| 896 | root->clean_orphans = 0; | ||
| 895 | 897 | ||
| 896 | root->fs_info = fs_info; | 898 | root->fs_info = fs_info; |
| 897 | root->objectid = objectid; | 899 | root->objectid = objectid; |
| @@ -928,7 +930,6 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize, | |||
| 928 | root->defrag_trans_start = fs_info->generation; | 930 | root->defrag_trans_start = fs_info->generation; |
| 929 | init_completion(&root->kobj_unregister); | 931 | init_completion(&root->kobj_unregister); |
| 930 | root->defrag_running = 0; | 932 | root->defrag_running = 0; |
| 931 | root->defrag_level = 0; | ||
| 932 | root->root_key.objectid = objectid; | 933 | root->root_key.objectid = objectid; |
| 933 | root->anon_super.s_root = NULL; | 934 | root->anon_super.s_root = NULL; |
| 934 | root->anon_super.s_dev = 0; | 935 | root->anon_super.s_dev = 0; |
| @@ -980,12 +981,12 @@ int btrfs_free_log_root_tree(struct btrfs_trans_handle *trans, | |||
| 980 | 981 | ||
| 981 | while (1) { | 982 | while (1) { |
| 982 | ret = find_first_extent_bit(&log_root_tree->dirty_log_pages, | 983 | ret = find_first_extent_bit(&log_root_tree->dirty_log_pages, |
| 983 | 0, &start, &end, EXTENT_DIRTY); | 984 | 0, &start, &end, EXTENT_DIRTY | EXTENT_NEW); |
| 984 | if (ret) | 985 | if (ret) |
| 985 | break; | 986 | break; |
| 986 | 987 | ||
| 987 | clear_extent_dirty(&log_root_tree->dirty_log_pages, | 988 | clear_extent_bits(&log_root_tree->dirty_log_pages, start, end, |
| 988 | start, end, GFP_NOFS); | 989 | EXTENT_DIRTY | EXTENT_NEW, GFP_NOFS); |
| 989 | } | 990 | } |
| 990 | eb = fs_info->log_root_tree->node; | 991 | eb = fs_info->log_root_tree->node; |
| 991 | 992 | ||
| @@ -1210,8 +1211,10 @@ again: | |||
| 1210 | ret = radix_tree_insert(&fs_info->fs_roots_radix, | 1211 | ret = radix_tree_insert(&fs_info->fs_roots_radix, |
| 1211 | (unsigned long)root->root_key.objectid, | 1212 | (unsigned long)root->root_key.objectid, |
| 1212 | root); | 1213 | root); |
| 1213 | if (ret == 0) | 1214 | if (ret == 0) { |
| 1214 | root->in_radix = 1; | 1215 | root->in_radix = 1; |
| 1216 | root->clean_orphans = 1; | ||
| 1217 | } | ||
| 1215 | spin_unlock(&fs_info->fs_roots_radix_lock); | 1218 | spin_unlock(&fs_info->fs_roots_radix_lock); |
| 1216 | radix_tree_preload_end(); | 1219 | radix_tree_preload_end(); |
| 1217 | if (ret) { | 1220 | if (ret) { |
| @@ -1225,10 +1228,6 @@ again: | |||
| 1225 | ret = btrfs_find_dead_roots(fs_info->tree_root, | 1228 | ret = btrfs_find_dead_roots(fs_info->tree_root, |
| 1226 | root->root_key.objectid); | 1229 | root->root_key.objectid); |
| 1227 | WARN_ON(ret); | 1230 | WARN_ON(ret); |
| 1228 | |||
| 1229 | if (!(fs_info->sb->s_flags & MS_RDONLY)) | ||
| 1230 | btrfs_orphan_cleanup(root); | ||
| 1231 | |||
| 1232 | return root; | 1231 | return root; |
| 1233 | fail: | 1232 | fail: |
| 1234 | free_fs_root(root); | 1233 | free_fs_root(root); |
| @@ -1477,6 +1476,7 @@ static int cleaner_kthread(void *arg) | |||
| 1477 | 1476 | ||
| 1478 | if (!(root->fs_info->sb->s_flags & MS_RDONLY) && | 1477 | if (!(root->fs_info->sb->s_flags & MS_RDONLY) && |
| 1479 | mutex_trylock(&root->fs_info->cleaner_mutex)) { | 1478 | mutex_trylock(&root->fs_info->cleaner_mutex)) { |
| 1479 | btrfs_run_delayed_iputs(root); | ||
| 1480 | btrfs_clean_old_snapshots(root); | 1480 | btrfs_clean_old_snapshots(root); |
| 1481 | mutex_unlock(&root->fs_info->cleaner_mutex); | 1481 | mutex_unlock(&root->fs_info->cleaner_mutex); |
| 1482 | } | 1482 | } |
| @@ -1606,6 +1606,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
| 1606 | INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_ATOMIC); | 1606 | INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_ATOMIC); |
| 1607 | INIT_LIST_HEAD(&fs_info->trans_list); | 1607 | INIT_LIST_HEAD(&fs_info->trans_list); |
| 1608 | INIT_LIST_HEAD(&fs_info->dead_roots); | 1608 | INIT_LIST_HEAD(&fs_info->dead_roots); |
| 1609 | INIT_LIST_HEAD(&fs_info->delayed_iputs); | ||
| 1609 | INIT_LIST_HEAD(&fs_info->hashers); | 1610 | INIT_LIST_HEAD(&fs_info->hashers); |
| 1610 | INIT_LIST_HEAD(&fs_info->delalloc_inodes); | 1611 | INIT_LIST_HEAD(&fs_info->delalloc_inodes); |
| 1611 | INIT_LIST_HEAD(&fs_info->ordered_operations); | 1612 | INIT_LIST_HEAD(&fs_info->ordered_operations); |
| @@ -1614,6 +1615,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
| 1614 | spin_lock_init(&fs_info->new_trans_lock); | 1615 | spin_lock_init(&fs_info->new_trans_lock); |
| 1615 | spin_lock_init(&fs_info->ref_cache_lock); | 1616 | spin_lock_init(&fs_info->ref_cache_lock); |
| 1616 | spin_lock_init(&fs_info->fs_roots_radix_lock); | 1617 | spin_lock_init(&fs_info->fs_roots_radix_lock); |
| 1618 | spin_lock_init(&fs_info->delayed_iput_lock); | ||
| 1617 | 1619 | ||
| 1618 | init_completion(&fs_info->kobj_unregister); | 1620 | init_completion(&fs_info->kobj_unregister); |
| 1619 | fs_info->tree_root = tree_root; | 1621 | fs_info->tree_root = tree_root; |
| @@ -1689,6 +1691,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
| 1689 | mutex_init(&fs_info->cleaner_mutex); | 1691 | mutex_init(&fs_info->cleaner_mutex); |
| 1690 | mutex_init(&fs_info->volume_mutex); | 1692 | mutex_init(&fs_info->volume_mutex); |
| 1691 | init_rwsem(&fs_info->extent_commit_sem); | 1693 | init_rwsem(&fs_info->extent_commit_sem); |
| 1694 | init_rwsem(&fs_info->cleanup_work_sem); | ||
| 1692 | init_rwsem(&fs_info->subvol_sem); | 1695 | init_rwsem(&fs_info->subvol_sem); |
| 1693 | 1696 | ||
| 1694 | btrfs_init_free_cluster(&fs_info->meta_alloc_cluster); | 1697 | btrfs_init_free_cluster(&fs_info->meta_alloc_cluster); |
| @@ -2386,8 +2389,14 @@ int btrfs_commit_super(struct btrfs_root *root) | |||
| 2386 | int ret; | 2389 | int ret; |
| 2387 | 2390 | ||
| 2388 | mutex_lock(&root->fs_info->cleaner_mutex); | 2391 | mutex_lock(&root->fs_info->cleaner_mutex); |
| 2392 | btrfs_run_delayed_iputs(root); | ||
| 2389 | btrfs_clean_old_snapshots(root); | 2393 | btrfs_clean_old_snapshots(root); |
| 2390 | mutex_unlock(&root->fs_info->cleaner_mutex); | 2394 | mutex_unlock(&root->fs_info->cleaner_mutex); |
| 2395 | |||
| 2396 | /* wait until ongoing cleanup work done */ | ||
| 2397 | down_write(&root->fs_info->cleanup_work_sem); | ||
| 2398 | up_write(&root->fs_info->cleanup_work_sem); | ||
| 2399 | |||
| 2391 | trans = btrfs_start_transaction(root, 1); | 2400 | trans = btrfs_start_transaction(root, 1); |
| 2392 | ret = btrfs_commit_transaction(trans, root); | 2401 | ret = btrfs_commit_transaction(trans, root); |
| 2393 | BUG_ON(ret); | 2402 | BUG_ON(ret); |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 94627c4cc193..56e50137d0e6 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
| @@ -195,6 +195,14 @@ static int exclude_super_stripes(struct btrfs_root *root, | |||
| 195 | int stripe_len; | 195 | int stripe_len; |
| 196 | int i, nr, ret; | 196 | int i, nr, ret; |
| 197 | 197 | ||
| 198 | if (cache->key.objectid < BTRFS_SUPER_INFO_OFFSET) { | ||
| 199 | stripe_len = BTRFS_SUPER_INFO_OFFSET - cache->key.objectid; | ||
| 200 | cache->bytes_super += stripe_len; | ||
| 201 | ret = add_excluded_extent(root, cache->key.objectid, | ||
| 202 | stripe_len); | ||
| 203 | BUG_ON(ret); | ||
| 204 | } | ||
| 205 | |||
| 198 | for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) { | 206 | for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) { |
| 199 | bytenr = btrfs_sb_offset(i); | 207 | bytenr = btrfs_sb_offset(i); |
| 200 | ret = btrfs_rmap_block(&root->fs_info->mapping_tree, | 208 | ret = btrfs_rmap_block(&root->fs_info->mapping_tree, |
| @@ -255,7 +263,7 @@ static u64 add_new_free_space(struct btrfs_block_group_cache *block_group, | |||
| 255 | if (ret) | 263 | if (ret) |
| 256 | break; | 264 | break; |
| 257 | 265 | ||
| 258 | if (extent_start == start) { | 266 | if (extent_start <= start) { |
| 259 | start = extent_end + 1; | 267 | start = extent_end + 1; |
| 260 | } else if (extent_start > start && extent_start < end) { | 268 | } else if (extent_start > start && extent_start < end) { |
| 261 | size = extent_start - start; | 269 | size = extent_start - start; |
| @@ -2880,9 +2888,9 @@ static noinline void flush_delalloc_async(struct btrfs_work *work) | |||
| 2880 | root = async->root; | 2888 | root = async->root; |
| 2881 | info = async->info; | 2889 | info = async->info; |
| 2882 | 2890 | ||
| 2883 | btrfs_start_delalloc_inodes(root); | 2891 | btrfs_start_delalloc_inodes(root, 0); |
| 2884 | wake_up(&info->flush_wait); | 2892 | wake_up(&info->flush_wait); |
| 2885 | btrfs_wait_ordered_extents(root, 0); | 2893 | btrfs_wait_ordered_extents(root, 0, 0); |
| 2886 | 2894 | ||
| 2887 | spin_lock(&info->lock); | 2895 | spin_lock(&info->lock); |
| 2888 | info->flushing = 0; | 2896 | info->flushing = 0; |
| @@ -2956,8 +2964,8 @@ static void flush_delalloc(struct btrfs_root *root, | |||
| 2956 | return; | 2964 | return; |
| 2957 | 2965 | ||
| 2958 | flush: | 2966 | flush: |
| 2959 | btrfs_start_delalloc_inodes(root); | 2967 | btrfs_start_delalloc_inodes(root, 0); |
| 2960 | btrfs_wait_ordered_extents(root, 0); | 2968 | btrfs_wait_ordered_extents(root, 0, 0); |
| 2961 | 2969 | ||
| 2962 | spin_lock(&info->lock); | 2970 | spin_lock(&info->lock); |
| 2963 | info->flushing = 0; | 2971 | info->flushing = 0; |
| @@ -3454,14 +3462,6 @@ static int update_block_group(struct btrfs_trans_handle *trans, | |||
| 3454 | else | 3462 | else |
| 3455 | old_val -= num_bytes; | 3463 | old_val -= num_bytes; |
| 3456 | btrfs_set_super_bytes_used(&info->super_copy, old_val); | 3464 | btrfs_set_super_bytes_used(&info->super_copy, old_val); |
| 3457 | |||
| 3458 | /* block accounting for root item */ | ||
| 3459 | old_val = btrfs_root_used(&root->root_item); | ||
| 3460 | if (alloc) | ||
| 3461 | old_val += num_bytes; | ||
| 3462 | else | ||
| 3463 | old_val -= num_bytes; | ||
| 3464 | btrfs_set_root_used(&root->root_item, old_val); | ||
| 3465 | spin_unlock(&info->delalloc_lock); | 3465 | spin_unlock(&info->delalloc_lock); |
| 3466 | 3466 | ||
| 3467 | while (total) { | 3467 | while (total) { |
| @@ -4049,6 +4049,21 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, | |||
| 4049 | return ret; | 4049 | return ret; |
| 4050 | } | 4050 | } |
| 4051 | 4051 | ||
| 4052 | int btrfs_free_tree_block(struct btrfs_trans_handle *trans, | ||
| 4053 | struct btrfs_root *root, | ||
| 4054 | u64 bytenr, u32 blocksize, | ||
| 4055 | u64 parent, u64 root_objectid, int level) | ||
| 4056 | { | ||
| 4057 | u64 used; | ||
| 4058 | spin_lock(&root->node_lock); | ||
| 4059 | used = btrfs_root_used(&root->root_item) - blocksize; | ||
| 4060 | btrfs_set_root_used(&root->root_item, used); | ||
| 4061 | spin_unlock(&root->node_lock); | ||
| 4062 | |||
| 4063 | return btrfs_free_extent(trans, root, bytenr, blocksize, | ||
| 4064 | parent, root_objectid, level, 0); | ||
| 4065 | } | ||
| 4066 | |||
| 4052 | static u64 stripe_align(struct btrfs_root *root, u64 val) | 4067 | static u64 stripe_align(struct btrfs_root *root, u64 val) |
| 4053 | { | 4068 | { |
| 4054 | u64 mask = ((u64)root->stripesize - 1); | 4069 | u64 mask = ((u64)root->stripesize - 1); |
| @@ -4578,7 +4593,6 @@ int btrfs_reserve_extent(struct btrfs_trans_handle *trans, | |||
| 4578 | { | 4593 | { |
| 4579 | int ret; | 4594 | int ret; |
| 4580 | u64 search_start = 0; | 4595 | u64 search_start = 0; |
| 4581 | struct btrfs_fs_info *info = root->fs_info; | ||
| 4582 | 4596 | ||
| 4583 | data = btrfs_get_alloc_profile(root, data); | 4597 | data = btrfs_get_alloc_profile(root, data); |
| 4584 | again: | 4598 | again: |
| @@ -4586,17 +4600,9 @@ again: | |||
| 4586 | * the only place that sets empty_size is btrfs_realloc_node, which | 4600 | * the only place that sets empty_size is btrfs_realloc_node, which |
| 4587 | * is not called recursively on allocations | 4601 | * is not called recursively on allocations |
| 4588 | */ | 4602 | */ |
| 4589 | if (empty_size || root->ref_cows) { | 4603 | if (empty_size || root->ref_cows) |
| 4590 | if (!(data & BTRFS_BLOCK_GROUP_METADATA)) { | ||
| 4591 | ret = do_chunk_alloc(trans, root->fs_info->extent_root, | ||
| 4592 | 2 * 1024 * 1024, | ||
| 4593 | BTRFS_BLOCK_GROUP_METADATA | | ||
| 4594 | (info->metadata_alloc_profile & | ||
| 4595 | info->avail_metadata_alloc_bits), 0); | ||
| 4596 | } | ||
| 4597 | ret = do_chunk_alloc(trans, root->fs_info->extent_root, | 4604 | ret = do_chunk_alloc(trans, root->fs_info->extent_root, |
| 4598 | num_bytes + 2 * 1024 * 1024, data, 0); | 4605 | num_bytes + 2 * 1024 * 1024, data, 0); |
| 4599 | } | ||
| 4600 | 4606 | ||
| 4601 | WARN_ON(num_bytes < root->sectorsize); | 4607 | WARN_ON(num_bytes < root->sectorsize); |
| 4602 | ret = find_free_extent(trans, root, num_bytes, empty_size, | 4608 | ret = find_free_extent(trans, root, num_bytes, empty_size, |
| @@ -4897,6 +4903,14 @@ static int alloc_tree_block(struct btrfs_trans_handle *trans, | |||
| 4897 | extent_op); | 4903 | extent_op); |
| 4898 | BUG_ON(ret); | 4904 | BUG_ON(ret); |
| 4899 | } | 4905 | } |
| 4906 | |||
| 4907 | if (root_objectid == root->root_key.objectid) { | ||
| 4908 | u64 used; | ||
| 4909 | spin_lock(&root->node_lock); | ||
| 4910 | used = btrfs_root_used(&root->root_item) + num_bytes; | ||
| 4911 | btrfs_set_root_used(&root->root_item, used); | ||
| 4912 | spin_unlock(&root->node_lock); | ||
| 4913 | } | ||
| 4900 | return ret; | 4914 | return ret; |
| 4901 | } | 4915 | } |
| 4902 | 4916 | ||
| @@ -4919,8 +4933,16 @@ struct extent_buffer *btrfs_init_new_buffer(struct btrfs_trans_handle *trans, | |||
| 4919 | btrfs_set_buffer_uptodate(buf); | 4933 | btrfs_set_buffer_uptodate(buf); |
| 4920 | 4934 | ||
| 4921 | if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) { | 4935 | if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) { |
| 4922 | set_extent_dirty(&root->dirty_log_pages, buf->start, | 4936 | /* |
| 4923 | buf->start + buf->len - 1, GFP_NOFS); | 4937 | * we allow two log transactions at a time, use different |
| 4938 | * EXENT bit to differentiate dirty pages. | ||
| 4939 | */ | ||
| 4940 | if (root->log_transid % 2 == 0) | ||
| 4941 | set_extent_dirty(&root->dirty_log_pages, buf->start, | ||
| 4942 | buf->start + buf->len - 1, GFP_NOFS); | ||
| 4943 | else | ||
| 4944 | set_extent_new(&root->dirty_log_pages, buf->start, | ||
| 4945 | buf->start + buf->len - 1, GFP_NOFS); | ||
| 4924 | } else { | 4946 | } else { |
| 4925 | set_extent_dirty(&trans->transaction->dirty_pages, buf->start, | 4947 | set_extent_dirty(&trans->transaction->dirty_pages, buf->start, |
| 4926 | buf->start + buf->len - 1, GFP_NOFS); | 4948 | buf->start + buf->len - 1, GFP_NOFS); |
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 77f759302e12..feaa13b105d9 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
| @@ -179,18 +179,14 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end, | |||
| 179 | } | 179 | } |
| 180 | flags = em->flags; | 180 | flags = em->flags; |
| 181 | if (skip_pinned && test_bit(EXTENT_FLAG_PINNED, &em->flags)) { | 181 | if (skip_pinned && test_bit(EXTENT_FLAG_PINNED, &em->flags)) { |
| 182 | if (em->start <= start && | 182 | if (testend && em->start + em->len >= start + len) { |
| 183 | (!testend || em->start + em->len >= start + len)) { | ||
| 184 | free_extent_map(em); | 183 | free_extent_map(em); |
| 185 | write_unlock(&em_tree->lock); | 184 | write_unlock(&em_tree->lock); |
| 186 | break; | 185 | break; |
| 187 | } | 186 | } |
| 188 | if (start < em->start) { | 187 | start = em->start + em->len; |
| 189 | len = em->start - start; | 188 | if (testend) |
| 190 | } else { | ||
| 191 | len = start + len - (em->start + em->len); | 189 | len = start + len - (em->start + em->len); |
| 192 | start = em->start + em->len; | ||
| 193 | } | ||
| 194 | free_extent_map(em); | 190 | free_extent_map(em); |
| 195 | write_unlock(&em_tree->lock); | 191 | write_unlock(&em_tree->lock); |
| 196 | continue; | 192 | continue; |
| @@ -265,319 +261,247 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end, | |||
| 265 | * If an extent intersects the range but is not entirely inside the range | 261 | * If an extent intersects the range but is not entirely inside the range |
| 266 | * it is either truncated or split. Anything entirely inside the range | 262 | * it is either truncated or split. Anything entirely inside the range |
| 267 | * is deleted from the tree. | 263 | * is deleted from the tree. |
| 268 | * | ||
| 269 | * inline_limit is used to tell this code which offsets in the file to keep | ||
| 270 | * if they contain inline extents. | ||
| 271 | */ | 264 | */ |
| 272 | noinline int btrfs_drop_extents(struct btrfs_trans_handle *trans, | 265 | int btrfs_drop_extents(struct btrfs_trans_handle *trans, struct inode *inode, |
| 273 | struct btrfs_root *root, struct inode *inode, | 266 | u64 start, u64 end, u64 *hint_byte, int drop_cache) |
| 274 | u64 start, u64 end, u64 locked_end, | ||
| 275 | u64 inline_limit, u64 *hint_byte, int drop_cache) | ||
| 276 | { | 267 | { |
| 277 | u64 extent_end = 0; | 268 | struct btrfs_root *root = BTRFS_I(inode)->root; |
| 278 | u64 search_start = start; | ||
| 279 | u64 ram_bytes = 0; | ||
| 280 | u64 disk_bytenr = 0; | ||
| 281 | u64 orig_locked_end = locked_end; | ||
| 282 | u8 compression; | ||
| 283 | u8 encryption; | ||
| 284 | u16 other_encoding = 0; | ||
| 285 | struct extent_buffer *leaf; | 269 | struct extent_buffer *leaf; |
| 286 | struct btrfs_file_extent_item *extent; | 270 | struct btrfs_file_extent_item *fi; |
| 287 | struct btrfs_path *path; | 271 | struct btrfs_path *path; |
| 288 | struct btrfs_key key; | 272 | struct btrfs_key key; |
| 289 | struct btrfs_file_extent_item old; | 273 | struct btrfs_key new_key; |
| 290 | int keep; | 274 | u64 search_start = start; |
| 291 | int slot; | 275 | u64 disk_bytenr = 0; |
| 292 | int bookend; | 276 | u64 num_bytes = 0; |
| 293 | int found_type = 0; | 277 | u64 extent_offset = 0; |
| 294 | int found_extent; | 278 | u64 extent_end = 0; |
| 295 | int found_inline; | 279 | int del_nr = 0; |
| 280 | int del_slot = 0; | ||
| 281 | int extent_type; | ||
| 296 | int recow; | 282 | int recow; |
| 297 | int ret; | 283 | int ret; |
| 298 | 284 | ||
| 299 | inline_limit = 0; | ||
| 300 | if (drop_cache) | 285 | if (drop_cache) |
| 301 | btrfs_drop_extent_cache(inode, start, end - 1, 0); | 286 | btrfs_drop_extent_cache(inode, start, end - 1, 0); |
| 302 | 287 | ||
| 303 | path = btrfs_alloc_path(); | 288 | path = btrfs_alloc_path(); |
| 304 | if (!path) | 289 | if (!path) |
| 305 | return -ENOMEM; | 290 | return -ENOMEM; |
| 291 | |||
| 306 | while (1) { | 292 | while (1) { |
| 307 | recow = 0; | 293 | recow = 0; |
| 308 | btrfs_release_path(root, path); | ||
| 309 | ret = btrfs_lookup_file_extent(trans, root, path, inode->i_ino, | 294 | ret = btrfs_lookup_file_extent(trans, root, path, inode->i_ino, |
| 310 | search_start, -1); | 295 | search_start, -1); |
| 311 | if (ret < 0) | 296 | if (ret < 0) |
| 312 | goto out; | 297 | break; |
| 313 | if (ret > 0) { | 298 | if (ret > 0 && path->slots[0] > 0 && search_start == start) { |
| 314 | if (path->slots[0] == 0) { | 299 | leaf = path->nodes[0]; |
| 315 | ret = 0; | 300 | btrfs_item_key_to_cpu(leaf, &key, path->slots[0] - 1); |
| 316 | goto out; | 301 | if (key.objectid == inode->i_ino && |
| 317 | } | 302 | key.type == BTRFS_EXTENT_DATA_KEY) |
| 318 | path->slots[0]--; | 303 | path->slots[0]--; |
| 319 | } | 304 | } |
| 305 | ret = 0; | ||
| 320 | next_slot: | 306 | next_slot: |
| 321 | keep = 0; | ||
| 322 | bookend = 0; | ||
| 323 | found_extent = 0; | ||
| 324 | found_inline = 0; | ||
| 325 | compression = 0; | ||
| 326 | encryption = 0; | ||
| 327 | extent = NULL; | ||
| 328 | leaf = path->nodes[0]; | 307 | leaf = path->nodes[0]; |
| 329 | slot = path->slots[0]; | 308 | if (path->slots[0] >= btrfs_header_nritems(leaf)) { |
| 330 | ret = 0; | 309 | BUG_ON(del_nr > 0); |
| 331 | btrfs_item_key_to_cpu(leaf, &key, slot); | 310 | ret = btrfs_next_leaf(root, path); |
| 332 | if (btrfs_key_type(&key) == BTRFS_EXTENT_DATA_KEY && | 311 | if (ret < 0) |
| 333 | key.offset >= end) { | 312 | break; |
| 334 | goto out; | 313 | if (ret > 0) { |
| 335 | } | 314 | ret = 0; |
| 336 | if (btrfs_key_type(&key) > BTRFS_EXTENT_DATA_KEY || | 315 | break; |
| 337 | key.objectid != inode->i_ino) { | ||
| 338 | goto out; | ||
| 339 | } | ||
| 340 | if (recow) { | ||
| 341 | search_start = max(key.offset, start); | ||
| 342 | continue; | ||
| 343 | } | ||
| 344 | if (btrfs_key_type(&key) == BTRFS_EXTENT_DATA_KEY) { | ||
| 345 | extent = btrfs_item_ptr(leaf, slot, | ||
| 346 | struct btrfs_file_extent_item); | ||
| 347 | found_type = btrfs_file_extent_type(leaf, extent); | ||
| 348 | compression = btrfs_file_extent_compression(leaf, | ||
| 349 | extent); | ||
| 350 | encryption = btrfs_file_extent_encryption(leaf, | ||
| 351 | extent); | ||
| 352 | other_encoding = btrfs_file_extent_other_encoding(leaf, | ||
| 353 | extent); | ||
| 354 | if (found_type == BTRFS_FILE_EXTENT_REG || | ||
| 355 | found_type == BTRFS_FILE_EXTENT_PREALLOC) { | ||
| 356 | extent_end = | ||
| 357 | btrfs_file_extent_disk_bytenr(leaf, | ||
| 358 | extent); | ||
| 359 | if (extent_end) | ||
| 360 | *hint_byte = extent_end; | ||
| 361 | |||
| 362 | extent_end = key.offset + | ||
| 363 | btrfs_file_extent_num_bytes(leaf, extent); | ||
| 364 | ram_bytes = btrfs_file_extent_ram_bytes(leaf, | ||
| 365 | extent); | ||
| 366 | found_extent = 1; | ||
| 367 | } else if (found_type == BTRFS_FILE_EXTENT_INLINE) { | ||
| 368 | found_inline = 1; | ||
| 369 | extent_end = key.offset + | ||
| 370 | btrfs_file_extent_inline_len(leaf, extent); | ||
| 371 | } | 316 | } |
| 317 | leaf = path->nodes[0]; | ||
| 318 | recow = 1; | ||
| 319 | } | ||
| 320 | |||
| 321 | btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); | ||
| 322 | if (key.objectid > inode->i_ino || | ||
| 323 | key.type > BTRFS_EXTENT_DATA_KEY || key.offset >= end) | ||
| 324 | break; | ||
| 325 | |||
| 326 | fi = btrfs_item_ptr(leaf, path->slots[0], | ||
| 327 | struct btrfs_file_extent_item); | ||
| 328 | extent_type = btrfs_file_extent_type(leaf, fi); | ||
| 329 | |||
| 330 | if (extent_type == BTRFS_FILE_EXTENT_REG || | ||
| 331 | extent_type == BTRFS_FILE_EXTENT_PREALLOC) { | ||
| 332 | disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, fi); | ||
| 333 | num_bytes = btrfs_file_extent_disk_num_bytes(leaf, fi); | ||
| 334 | extent_offset = btrfs_file_extent_offset(leaf, fi); | ||
| 335 | extent_end = key.offset + | ||
| 336 | btrfs_file_extent_num_bytes(leaf, fi); | ||
| 337 | } else if (extent_type == BTRFS_FILE_EXTENT_INLINE) { | ||
| 338 | extent_end = key.offset + | ||
| 339 | btrfs_file_extent_inline_len(leaf, fi); | ||
| 372 | } else { | 340 | } else { |
| 341 | WARN_ON(1); | ||
| 373 | extent_end = search_start; | 342 | extent_end = search_start; |
| 374 | } | 343 | } |
| 375 | 344 | ||
| 376 | /* we found nothing we can drop */ | 345 | if (extent_end <= search_start) { |
| 377 | if ((!found_extent && !found_inline) || | 346 | path->slots[0]++; |
| 378 | search_start >= extent_end) { | ||
| 379 | int nextret; | ||
| 380 | u32 nritems; | ||
| 381 | nritems = btrfs_header_nritems(leaf); | ||
| 382 | if (slot >= nritems - 1) { | ||
| 383 | nextret = btrfs_next_leaf(root, path); | ||
| 384 | if (nextret) | ||
| 385 | goto out; | ||
| 386 | recow = 1; | ||
| 387 | } else { | ||
| 388 | path->slots[0]++; | ||
| 389 | } | ||
| 390 | goto next_slot; | 347 | goto next_slot; |
| 391 | } | 348 | } |
| 392 | 349 | ||
| 393 | if (end <= extent_end && start >= key.offset && found_inline) | 350 | search_start = max(key.offset, start); |
| 394 | *hint_byte = EXTENT_MAP_INLINE; | 351 | if (recow) { |
| 395 | 352 | btrfs_release_path(root, path); | |
| 396 | if (found_extent) { | 353 | continue; |
| 397 | read_extent_buffer(leaf, &old, (unsigned long)extent, | ||
| 398 | sizeof(old)); | ||
| 399 | } | ||
| 400 | |||
| 401 | if (end < extent_end && end >= key.offset) { | ||
| 402 | bookend = 1; | ||
| 403 | if (found_inline && start <= key.offset) | ||
| 404 | keep = 1; | ||
| 405 | } | 354 | } |
| 406 | 355 | ||
| 407 | if (bookend && found_extent) { | 356 | /* |
| 408 | if (locked_end < extent_end) { | 357 | * | - range to drop - | |
| 409 | ret = try_lock_extent(&BTRFS_I(inode)->io_tree, | 358 | * | -------- extent -------- | |
| 410 | locked_end, extent_end - 1, | 359 | */ |
| 411 | GFP_NOFS); | 360 | if (start > key.offset && end < extent_end) { |
| 412 | if (!ret) { | 361 | BUG_ON(del_nr > 0); |
| 413 | btrfs_release_path(root, path); | 362 | BUG_ON(extent_type == BTRFS_FILE_EXTENT_INLINE); |
| 414 | lock_extent(&BTRFS_I(inode)->io_tree, | 363 | |
| 415 | locked_end, extent_end - 1, | 364 | memcpy(&new_key, &key, sizeof(new_key)); |
| 416 | GFP_NOFS); | 365 | new_key.offset = start; |
| 417 | locked_end = extent_end; | 366 | ret = btrfs_duplicate_item(trans, root, path, |
| 418 | continue; | 367 | &new_key); |
| 419 | } | 368 | if (ret == -EAGAIN) { |
| 420 | locked_end = extent_end; | 369 | btrfs_release_path(root, path); |
| 370 | continue; | ||
| 421 | } | 371 | } |
| 422 | disk_bytenr = le64_to_cpu(old.disk_bytenr); | 372 | if (ret < 0) |
| 423 | if (disk_bytenr != 0) { | 373 | break; |
| 374 | |||
| 375 | leaf = path->nodes[0]; | ||
| 376 | fi = btrfs_item_ptr(leaf, path->slots[0] - 1, | ||
| 377 | struct btrfs_file_extent_item); | ||
| 378 | btrfs_set_file_extent_num_bytes(leaf, fi, | ||
| 379 | start - key.offset); | ||
| 380 | |||
| 381 | fi = btrfs_item_ptr(leaf, path->slots[0], | ||
| 382 | struct btrfs_file_extent_item); | ||
| 383 | |||
| 384 | extent_offset += start - key.offset; | ||
| 385 | btrfs_set_file_extent_offset(leaf, fi, extent_offset); | ||
| 386 | btrfs_set_file_extent_num_bytes(leaf, fi, | ||
| 387 | extent_end - start); | ||
| 388 | btrfs_mark_buffer_dirty(leaf); | ||
| 389 | |||
| 390 | if (disk_bytenr > 0) { | ||
| 424 | ret = btrfs_inc_extent_ref(trans, root, | 391 | ret = btrfs_inc_extent_ref(trans, root, |
| 425 | disk_bytenr, | 392 | disk_bytenr, num_bytes, 0, |
| 426 | le64_to_cpu(old.disk_num_bytes), 0, | 393 | root->root_key.objectid, |
| 427 | root->root_key.objectid, | 394 | new_key.objectid, |
| 428 | key.objectid, key.offset - | 395 | start - extent_offset); |
| 429 | le64_to_cpu(old.offset)); | ||
| 430 | BUG_ON(ret); | 396 | BUG_ON(ret); |
| 397 | *hint_byte = disk_bytenr; | ||
| 431 | } | 398 | } |
| 399 | key.offset = start; | ||
| 432 | } | 400 | } |
| 401 | /* | ||
| 402 | * | ---- range to drop ----- | | ||
| 403 | * | -------- extent -------- | | ||
| 404 | */ | ||
| 405 | if (start <= key.offset && end < extent_end) { | ||
| 406 | BUG_ON(extent_type == BTRFS_FILE_EXTENT_INLINE); | ||
| 433 | 407 | ||
| 434 | if (found_inline) { | 408 | memcpy(&new_key, &key, sizeof(new_key)); |
| 435 | u64 mask = root->sectorsize - 1; | 409 | new_key.offset = end; |
| 436 | search_start = (extent_end + mask) & ~mask; | 410 | btrfs_set_item_key_safe(trans, root, path, &new_key); |
| 437 | } else | 411 | |
| 438 | search_start = extent_end; | 412 | extent_offset += end - key.offset; |
| 439 | 413 | btrfs_set_file_extent_offset(leaf, fi, extent_offset); | |
| 440 | /* truncate existing extent */ | 414 | btrfs_set_file_extent_num_bytes(leaf, fi, |
| 441 | if (start > key.offset) { | 415 | extent_end - end); |
| 442 | u64 new_num; | 416 | btrfs_mark_buffer_dirty(leaf); |
| 443 | u64 old_num; | 417 | if (disk_bytenr > 0) { |
| 444 | keep = 1; | 418 | inode_sub_bytes(inode, end - key.offset); |
| 445 | WARN_ON(start & (root->sectorsize - 1)); | 419 | *hint_byte = disk_bytenr; |
| 446 | if (found_extent) { | ||
| 447 | new_num = start - key.offset; | ||
| 448 | old_num = btrfs_file_extent_num_bytes(leaf, | ||
| 449 | extent); | ||
| 450 | *hint_byte = | ||
| 451 | btrfs_file_extent_disk_bytenr(leaf, | ||
| 452 | extent); | ||
| 453 | if (btrfs_file_extent_disk_bytenr(leaf, | ||
| 454 | extent)) { | ||
| 455 | inode_sub_bytes(inode, old_num - | ||
| 456 | new_num); | ||
| 457 | } | ||
| 458 | btrfs_set_file_extent_num_bytes(leaf, | ||
| 459 | extent, new_num); | ||
| 460 | btrfs_mark_buffer_dirty(leaf); | ||
| 461 | } else if (key.offset < inline_limit && | ||
| 462 | (end > extent_end) && | ||
| 463 | (inline_limit < extent_end)) { | ||
| 464 | u32 new_size; | ||
| 465 | new_size = btrfs_file_extent_calc_inline_size( | ||
| 466 | inline_limit - key.offset); | ||
| 467 | inode_sub_bytes(inode, extent_end - | ||
| 468 | inline_limit); | ||
| 469 | btrfs_set_file_extent_ram_bytes(leaf, extent, | ||
| 470 | new_size); | ||
| 471 | if (!compression && !encryption) { | ||
| 472 | btrfs_truncate_item(trans, root, path, | ||
| 473 | new_size, 1); | ||
| 474 | } | ||
| 475 | } | 420 | } |
| 421 | break; | ||
| 476 | } | 422 | } |
| 477 | /* delete the entire extent */ | ||
| 478 | if (!keep) { | ||
| 479 | if (found_inline) | ||
| 480 | inode_sub_bytes(inode, extent_end - | ||
| 481 | key.offset); | ||
| 482 | ret = btrfs_del_item(trans, root, path); | ||
| 483 | /* TODO update progress marker and return */ | ||
| 484 | BUG_ON(ret); | ||
| 485 | extent = NULL; | ||
| 486 | btrfs_release_path(root, path); | ||
| 487 | /* the extent will be freed later */ | ||
| 488 | } | ||
| 489 | if (bookend && found_inline && start <= key.offset) { | ||
| 490 | u32 new_size; | ||
| 491 | new_size = btrfs_file_extent_calc_inline_size( | ||
| 492 | extent_end - end); | ||
| 493 | inode_sub_bytes(inode, end - key.offset); | ||
| 494 | btrfs_set_file_extent_ram_bytes(leaf, extent, | ||
| 495 | new_size); | ||
| 496 | if (!compression && !encryption) | ||
| 497 | ret = btrfs_truncate_item(trans, root, path, | ||
| 498 | new_size, 0); | ||
| 499 | BUG_ON(ret); | ||
| 500 | } | ||
| 501 | /* create bookend, splitting the extent in two */ | ||
| 502 | if (bookend && found_extent) { | ||
| 503 | struct btrfs_key ins; | ||
| 504 | ins.objectid = inode->i_ino; | ||
| 505 | ins.offset = end; | ||
| 506 | btrfs_set_key_type(&ins, BTRFS_EXTENT_DATA_KEY); | ||
| 507 | 423 | ||
| 508 | btrfs_release_path(root, path); | 424 | search_start = extent_end; |
| 509 | path->leave_spinning = 1; | 425 | /* |
| 510 | ret = btrfs_insert_empty_item(trans, root, path, &ins, | 426 | * | ---- range to drop ----- | |
| 511 | sizeof(*extent)); | 427 | * | -------- extent -------- | |
| 512 | BUG_ON(ret); | 428 | */ |
| 429 | if (start > key.offset && end >= extent_end) { | ||
| 430 | BUG_ON(del_nr > 0); | ||
| 431 | BUG_ON(extent_type == BTRFS_FILE_EXTENT_INLINE); | ||
| 513 | 432 | ||
| 514 | leaf = path->nodes[0]; | 433 | btrfs_set_file_extent_num_bytes(leaf, fi, |
| 515 | extent = btrfs_item_ptr(leaf, path->slots[0], | 434 | start - key.offset); |
| 516 | struct btrfs_file_extent_item); | 435 | btrfs_mark_buffer_dirty(leaf); |
| 517 | write_extent_buffer(leaf, &old, | 436 | if (disk_bytenr > 0) { |
| 518 | (unsigned long)extent, sizeof(old)); | 437 | inode_sub_bytes(inode, extent_end - start); |
| 519 | 438 | *hint_byte = disk_bytenr; | |
| 520 | btrfs_set_file_extent_compression(leaf, extent, | 439 | } |
| 521 | compression); | 440 | if (end == extent_end) |
| 522 | btrfs_set_file_extent_encryption(leaf, extent, | 441 | break; |
| 523 | encryption); | ||
| 524 | btrfs_set_file_extent_other_encoding(leaf, extent, | ||
| 525 | other_encoding); | ||
| 526 | btrfs_set_file_extent_offset(leaf, extent, | ||
| 527 | le64_to_cpu(old.offset) + end - key.offset); | ||
| 528 | WARN_ON(le64_to_cpu(old.num_bytes) < | ||
| 529 | (extent_end - end)); | ||
| 530 | btrfs_set_file_extent_num_bytes(leaf, extent, | ||
| 531 | extent_end - end); | ||
| 532 | 442 | ||
| 533 | /* | 443 | path->slots[0]++; |
| 534 | * set the ram bytes to the size of the full extent | 444 | goto next_slot; |
| 535 | * before splitting. This is a worst case flag, | ||
| 536 | * but its the best we can do because we don't know | ||
| 537 | * how splitting affects compression | ||
| 538 | */ | ||
| 539 | btrfs_set_file_extent_ram_bytes(leaf, extent, | ||
| 540 | ram_bytes); | ||
| 541 | btrfs_set_file_extent_type(leaf, extent, found_type); | ||
| 542 | |||
| 543 | btrfs_unlock_up_safe(path, 1); | ||
| 544 | btrfs_mark_buffer_dirty(path->nodes[0]); | ||
| 545 | btrfs_set_lock_blocking(path->nodes[0]); | ||
| 546 | |||
| 547 | path->leave_spinning = 0; | ||
| 548 | btrfs_release_path(root, path); | ||
| 549 | if (disk_bytenr != 0) | ||
| 550 | inode_add_bytes(inode, extent_end - end); | ||
| 551 | } | 445 | } |
| 552 | 446 | ||
| 553 | if (found_extent && !keep) { | 447 | /* |
| 554 | u64 old_disk_bytenr = le64_to_cpu(old.disk_bytenr); | 448 | * | ---- range to drop ----- | |
| 449 | * | ------ extent ------ | | ||
| 450 | */ | ||
| 451 | if (start <= key.offset && end >= extent_end) { | ||
| 452 | if (del_nr == 0) { | ||
| 453 | del_slot = path->slots[0]; | ||
| 454 | del_nr = 1; | ||
| 455 | } else { | ||
| 456 | BUG_ON(del_slot + del_nr != path->slots[0]); | ||
| 457 | del_nr++; | ||
| 458 | } | ||
| 555 | 459 | ||
| 556 | if (old_disk_bytenr != 0) { | 460 | if (extent_type == BTRFS_FILE_EXTENT_INLINE) { |
| 557 | inode_sub_bytes(inode, | 461 | inode_sub_bytes(inode, |
| 558 | le64_to_cpu(old.num_bytes)); | 462 | extent_end - key.offset); |
| 463 | extent_end = ALIGN(extent_end, | ||
| 464 | root->sectorsize); | ||
| 465 | } else if (disk_bytenr > 0) { | ||
| 559 | ret = btrfs_free_extent(trans, root, | 466 | ret = btrfs_free_extent(trans, root, |
| 560 | old_disk_bytenr, | 467 | disk_bytenr, num_bytes, 0, |
| 561 | le64_to_cpu(old.disk_num_bytes), | 468 | root->root_key.objectid, |
| 562 | 0, root->root_key.objectid, | ||
| 563 | key.objectid, key.offset - | 469 | key.objectid, key.offset - |
| 564 | le64_to_cpu(old.offset)); | 470 | extent_offset); |
| 565 | BUG_ON(ret); | 471 | BUG_ON(ret); |
| 566 | *hint_byte = old_disk_bytenr; | 472 | inode_sub_bytes(inode, |
| 473 | extent_end - key.offset); | ||
| 474 | *hint_byte = disk_bytenr; | ||
| 567 | } | 475 | } |
| 568 | } | ||
| 569 | 476 | ||
| 570 | if (search_start >= end) { | 477 | if (end == extent_end) |
| 571 | ret = 0; | 478 | break; |
| 572 | goto out; | 479 | |
| 480 | if (path->slots[0] + 1 < btrfs_header_nritems(leaf)) { | ||
| 481 | path->slots[0]++; | ||
| 482 | goto next_slot; | ||
| 483 | } | ||
| 484 | |||
| 485 | ret = btrfs_del_items(trans, root, path, del_slot, | ||
| 486 | del_nr); | ||
| 487 | BUG_ON(ret); | ||
| 488 | |||
| 489 | del_nr = 0; | ||
| 490 | del_slot = 0; | ||
| 491 | |||
| 492 | btrfs_release_path(root, path); | ||
| 493 | continue; | ||
| 573 | } | 494 | } |
| 495 | |||
| 496 | BUG_ON(1); | ||
| 574 | } | 497 | } |
| 575 | out: | 498 | |
| 576 | btrfs_free_path(path); | 499 | if (del_nr > 0) { |
| 577 | if (locked_end > orig_locked_end) { | 500 | ret = btrfs_del_items(trans, root, path, del_slot, del_nr); |
| 578 | unlock_extent(&BTRFS_I(inode)->io_tree, orig_locked_end, | 501 | BUG_ON(ret); |
| 579 | locked_end - 1, GFP_NOFS); | ||
| 580 | } | 502 | } |
| 503 | |||
| 504 | btrfs_free_path(path); | ||
| 581 | return ret; | 505 | return ret; |
| 582 | } | 506 | } |
| 583 | 507 | ||
| @@ -620,23 +544,23 @@ static int extent_mergeable(struct extent_buffer *leaf, int slot, | |||
| 620 | * two or three. | 544 | * two or three. |
| 621 | */ | 545 | */ |
| 622 | int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, | 546 | int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, |
| 623 | struct btrfs_root *root, | ||
| 624 | struct inode *inode, u64 start, u64 end) | 547 | struct inode *inode, u64 start, u64 end) |
| 625 | { | 548 | { |
| 549 | struct btrfs_root *root = BTRFS_I(inode)->root; | ||
| 626 | struct extent_buffer *leaf; | 550 | struct extent_buffer *leaf; |
| 627 | struct btrfs_path *path; | 551 | struct btrfs_path *path; |
| 628 | struct btrfs_file_extent_item *fi; | 552 | struct btrfs_file_extent_item *fi; |
| 629 | struct btrfs_key key; | 553 | struct btrfs_key key; |
| 554 | struct btrfs_key new_key; | ||
| 630 | u64 bytenr; | 555 | u64 bytenr; |
| 631 | u64 num_bytes; | 556 | u64 num_bytes; |
| 632 | u64 extent_end; | 557 | u64 extent_end; |
| 633 | u64 orig_offset; | 558 | u64 orig_offset; |
| 634 | u64 other_start; | 559 | u64 other_start; |
| 635 | u64 other_end; | 560 | u64 other_end; |
| 636 | u64 split = start; | 561 | u64 split; |
| 637 | u64 locked_end = end; | 562 | int del_nr = 0; |
| 638 | int extent_type; | 563 | int del_slot = 0; |
| 639 | int split_end = 1; | ||
| 640 | int ret; | 564 | int ret; |
| 641 | 565 | ||
| 642 | btrfs_drop_extent_cache(inode, start, end - 1, 0); | 566 | btrfs_drop_extent_cache(inode, start, end - 1, 0); |
| @@ -644,12 +568,10 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, | |||
| 644 | path = btrfs_alloc_path(); | 568 | path = btrfs_alloc_path(); |
| 645 | BUG_ON(!path); | 569 | BUG_ON(!path); |
| 646 | again: | 570 | again: |
| 571 | split = start; | ||
| 647 | key.objectid = inode->i_ino; | 572 | key.objectid = inode->i_ino; |
| 648 | key.type = BTRFS_EXTENT_DATA_KEY; | 573 | key.type = BTRFS_EXTENT_DATA_KEY; |
| 649 | if (split == start) | 574 | key.offset = split; |
| 650 | key.offset = split; | ||
| 651 | else | ||
| 652 | key.offset = split - 1; | ||
| 653 | 575 | ||
| 654 | ret = btrfs_search_slot(trans, root, &key, path, -1, 1); | 576 | ret = btrfs_search_slot(trans, root, &key, path, -1, 1); |
| 655 | if (ret > 0 && path->slots[0] > 0) | 577 | if (ret > 0 && path->slots[0] > 0) |
| @@ -661,8 +583,8 @@ again: | |||
| 661 | key.type != BTRFS_EXTENT_DATA_KEY); | 583 | key.type != BTRFS_EXTENT_DATA_KEY); |
| 662 | fi = btrfs_item_ptr(leaf, path->slots[0], | 584 | fi = btrfs_item_ptr(leaf, path->slots[0], |
| 663 | struct btrfs_file_extent_item); | 585 | struct btrfs_file_extent_item); |
| 664 | extent_type = btrfs_file_extent_type(leaf, fi); | 586 | BUG_ON(btrfs_file_extent_type(leaf, fi) != |
| 665 | BUG_ON(extent_type != BTRFS_FILE_EXTENT_PREALLOC); | 587 | BTRFS_FILE_EXTENT_PREALLOC); |
| 666 | extent_end = key.offset + btrfs_file_extent_num_bytes(leaf, fi); | 588 | extent_end = key.offset + btrfs_file_extent_num_bytes(leaf, fi); |
| 667 | BUG_ON(key.offset > start || extent_end < end); | 589 | BUG_ON(key.offset > start || extent_end < end); |
| 668 | 590 | ||
| @@ -670,150 +592,91 @@ again: | |||
| 670 | num_bytes = btrfs_file_extent_disk_num_bytes(leaf, fi); | 592 | num_bytes = btrfs_file_extent_disk_num_bytes(leaf, fi); |
| 671 | orig_offset = key.offset - btrfs_file_extent_offset(leaf, fi); | 593 | orig_offset = key.offset - btrfs_file_extent_offset(leaf, fi); |
| 672 | 594 | ||
| 673 | if (key.offset == start) | 595 | while (start > key.offset || end < extent_end) { |
| 674 | split = end; | 596 | if (key.offset == start) |
| 675 | 597 | split = end; | |
| 676 | if (key.offset == start && extent_end == end) { | 598 | |
| 677 | int del_nr = 0; | 599 | memcpy(&new_key, &key, sizeof(new_key)); |
| 678 | int del_slot = 0; | 600 | new_key.offset = split; |
| 679 | other_start = end; | 601 | ret = btrfs_duplicate_item(trans, root, path, &new_key); |
| 680 | other_end = 0; | 602 | if (ret == -EAGAIN) { |
| 681 | if (extent_mergeable(leaf, path->slots[0] + 1, inode->i_ino, | 603 | btrfs_release_path(root, path); |
| 682 | bytenr, &other_start, &other_end)) { | 604 | goto again; |
| 683 | extent_end = other_end; | ||
| 684 | del_slot = path->slots[0] + 1; | ||
| 685 | del_nr++; | ||
| 686 | ret = btrfs_free_extent(trans, root, bytenr, num_bytes, | ||
| 687 | 0, root->root_key.objectid, | ||
| 688 | inode->i_ino, orig_offset); | ||
| 689 | BUG_ON(ret); | ||
| 690 | } | ||
| 691 | other_start = 0; | ||
| 692 | other_end = start; | ||
| 693 | if (extent_mergeable(leaf, path->slots[0] - 1, inode->i_ino, | ||
| 694 | bytenr, &other_start, &other_end)) { | ||
| 695 | key.offset = other_start; | ||
| 696 | del_slot = path->slots[0]; | ||
| 697 | del_nr++; | ||
| 698 | ret = btrfs_free_extent(trans, root, bytenr, num_bytes, | ||
| 699 | 0, root->root_key.objectid, | ||
| 700 | inode->i_ino, orig_offset); | ||
| 701 | BUG_ON(ret); | ||
| 702 | } | ||
| 703 | split_end = 0; | ||
| 704 | if (del_nr == 0) { | ||
| 705 | btrfs_set_file_extent_type(leaf, fi, | ||
| 706 | BTRFS_FILE_EXTENT_REG); | ||
| 707 | goto done; | ||
| 708 | } | 605 | } |
| 606 | BUG_ON(ret < 0); | ||
| 709 | 607 | ||
| 710 | fi = btrfs_item_ptr(leaf, del_slot - 1, | 608 | leaf = path->nodes[0]; |
| 609 | fi = btrfs_item_ptr(leaf, path->slots[0] - 1, | ||
| 711 | struct btrfs_file_extent_item); | 610 | struct btrfs_file_extent_item); |
| 712 | btrfs_set_file_extent_type(leaf, fi, BTRFS_FILE_EXTENT_REG); | ||
| 713 | btrfs_set_file_extent_num_bytes(leaf, fi, | 611 | btrfs_set_file_extent_num_bytes(leaf, fi, |
| 714 | extent_end - key.offset); | 612 | split - key.offset); |
| 613 | |||
| 614 | fi = btrfs_item_ptr(leaf, path->slots[0], | ||
| 615 | struct btrfs_file_extent_item); | ||
| 616 | |||
| 617 | btrfs_set_file_extent_offset(leaf, fi, split - orig_offset); | ||
| 618 | btrfs_set_file_extent_num_bytes(leaf, fi, | ||
| 619 | extent_end - split); | ||
| 715 | btrfs_mark_buffer_dirty(leaf); | 620 | btrfs_mark_buffer_dirty(leaf); |
| 716 | 621 | ||
| 717 | ret = btrfs_del_items(trans, root, path, del_slot, del_nr); | 622 | ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0, |
| 623 | root->root_key.objectid, | ||
| 624 | inode->i_ino, orig_offset); | ||
| 718 | BUG_ON(ret); | 625 | BUG_ON(ret); |
| 719 | goto release; | ||
| 720 | } else if (split == start) { | ||
| 721 | if (locked_end < extent_end) { | ||
| 722 | ret = try_lock_extent(&BTRFS_I(inode)->io_tree, | ||
| 723 | locked_end, extent_end - 1, GFP_NOFS); | ||
| 724 | if (!ret) { | ||
| 725 | btrfs_release_path(root, path); | ||
| 726 | lock_extent(&BTRFS_I(inode)->io_tree, | ||
| 727 | locked_end, extent_end - 1, GFP_NOFS); | ||
| 728 | locked_end = extent_end; | ||
| 729 | goto again; | ||
| 730 | } | ||
| 731 | locked_end = extent_end; | ||
| 732 | } | ||
| 733 | btrfs_set_file_extent_num_bytes(leaf, fi, split - key.offset); | ||
| 734 | } else { | ||
| 735 | BUG_ON(key.offset != start); | ||
| 736 | key.offset = split; | ||
| 737 | btrfs_set_file_extent_offset(leaf, fi, key.offset - | ||
| 738 | orig_offset); | ||
| 739 | btrfs_set_file_extent_num_bytes(leaf, fi, extent_end - split); | ||
| 740 | btrfs_set_item_key_safe(trans, root, path, &key); | ||
| 741 | extent_end = split; | ||
| 742 | } | ||
| 743 | 626 | ||
| 744 | if (extent_end == end) { | 627 | if (split == start) { |
| 745 | split_end = 0; | 628 | key.offset = start; |
| 746 | extent_type = BTRFS_FILE_EXTENT_REG; | 629 | } else { |
| 747 | } | 630 | BUG_ON(start != key.offset); |
| 748 | if (extent_end == end && split == start) { | ||
| 749 | other_start = end; | ||
| 750 | other_end = 0; | ||
| 751 | if (extent_mergeable(leaf, path->slots[0] + 1, inode->i_ino, | ||
| 752 | bytenr, &other_start, &other_end)) { | ||
| 753 | path->slots[0]++; | ||
| 754 | fi = btrfs_item_ptr(leaf, path->slots[0], | ||
| 755 | struct btrfs_file_extent_item); | ||
| 756 | key.offset = split; | ||
| 757 | btrfs_set_item_key_safe(trans, root, path, &key); | ||
| 758 | btrfs_set_file_extent_offset(leaf, fi, key.offset - | ||
| 759 | orig_offset); | ||
| 760 | btrfs_set_file_extent_num_bytes(leaf, fi, | ||
| 761 | other_end - split); | ||
| 762 | goto done; | ||
| 763 | } | ||
| 764 | } | ||
| 765 | if (extent_end == end && split == end) { | ||
| 766 | other_start = 0; | ||
| 767 | other_end = start; | ||
| 768 | if (extent_mergeable(leaf, path->slots[0] - 1 , inode->i_ino, | ||
| 769 | bytenr, &other_start, &other_end)) { | ||
| 770 | path->slots[0]--; | 631 | path->slots[0]--; |
| 771 | fi = btrfs_item_ptr(leaf, path->slots[0], | 632 | extent_end = end; |
| 772 | struct btrfs_file_extent_item); | ||
| 773 | btrfs_set_file_extent_num_bytes(leaf, fi, extent_end - | ||
| 774 | other_start); | ||
| 775 | goto done; | ||
| 776 | } | 633 | } |
| 777 | } | 634 | } |
| 778 | 635 | ||
| 779 | btrfs_mark_buffer_dirty(leaf); | ||
| 780 | |||
| 781 | ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0, | ||
| 782 | root->root_key.objectid, | ||
| 783 | inode->i_ino, orig_offset); | ||
| 784 | BUG_ON(ret); | ||
| 785 | btrfs_release_path(root, path); | ||
| 786 | |||
| 787 | key.offset = start; | ||
| 788 | ret = btrfs_insert_empty_item(trans, root, path, &key, sizeof(*fi)); | ||
| 789 | BUG_ON(ret); | ||
| 790 | |||
| 791 | leaf = path->nodes[0]; | ||
| 792 | fi = btrfs_item_ptr(leaf, path->slots[0], | 636 | fi = btrfs_item_ptr(leaf, path->slots[0], |
| 793 | struct btrfs_file_extent_item); | 637 | struct btrfs_file_extent_item); |
| 794 | btrfs_set_file_extent_generation(leaf, fi, trans->transid); | ||
| 795 | btrfs_set_file_extent_type(leaf, fi, extent_type); | ||
| 796 | btrfs_set_file_extent_disk_bytenr(leaf, fi, bytenr); | ||
| 797 | btrfs_set_file_extent_disk_num_bytes(leaf, fi, num_bytes); | ||
| 798 | btrfs_set_file_extent_offset(leaf, fi, key.offset - orig_offset); | ||
| 799 | btrfs_set_file_extent_num_bytes(leaf, fi, extent_end - key.offset); | ||
| 800 | btrfs_set_file_extent_ram_bytes(leaf, fi, num_bytes); | ||
| 801 | btrfs_set_file_extent_compression(leaf, fi, 0); | ||
| 802 | btrfs_set_file_extent_encryption(leaf, fi, 0); | ||
| 803 | btrfs_set_file_extent_other_encoding(leaf, fi, 0); | ||
| 804 | done: | ||
| 805 | btrfs_mark_buffer_dirty(leaf); | ||
| 806 | 638 | ||
| 807 | release: | 639 | other_start = end; |
| 808 | btrfs_release_path(root, path); | 640 | other_end = 0; |
| 809 | if (split_end && split == start) { | 641 | if (extent_mergeable(leaf, path->slots[0] + 1, inode->i_ino, |
| 810 | split = end; | 642 | bytenr, &other_start, &other_end)) { |
| 811 | goto again; | 643 | extent_end = other_end; |
| 644 | del_slot = path->slots[0] + 1; | ||
| 645 | del_nr++; | ||
| 646 | ret = btrfs_free_extent(trans, root, bytenr, num_bytes, | ||
| 647 | 0, root->root_key.objectid, | ||
| 648 | inode->i_ino, orig_offset); | ||
| 649 | BUG_ON(ret); | ||
| 812 | } | 650 | } |
| 813 | if (locked_end > end) { | 651 | other_start = 0; |
| 814 | unlock_extent(&BTRFS_I(inode)->io_tree, end, locked_end - 1, | 652 | other_end = start; |
| 815 | GFP_NOFS); | 653 | if (extent_mergeable(leaf, path->slots[0] - 1, inode->i_ino, |
| 654 | bytenr, &other_start, &other_end)) { | ||
| 655 | key.offset = other_start; | ||
| 656 | del_slot = path->slots[0]; | ||
| 657 | del_nr++; | ||
| 658 | ret = btrfs_free_extent(trans, root, bytenr, num_bytes, | ||
| 659 | 0, root->root_key.objectid, | ||
| 660 | inode->i_ino, orig_offset); | ||
| 661 | BUG_ON(ret); | ||
| 816 | } | 662 | } |
| 663 | if (del_nr == 0) { | ||
| 664 | btrfs_set_file_extent_type(leaf, fi, | ||
| 665 | BTRFS_FILE_EXTENT_REG); | ||
| 666 | btrfs_mark_buffer_dirty(leaf); | ||
| 667 | goto out; | ||
| 668 | } | ||
| 669 | |||
| 670 | fi = btrfs_item_ptr(leaf, del_slot - 1, | ||
| 671 | struct btrfs_file_extent_item); | ||
| 672 | btrfs_set_file_extent_type(leaf, fi, BTRFS_FILE_EXTENT_REG); | ||
| 673 | btrfs_set_file_extent_num_bytes(leaf, fi, | ||
| 674 | extent_end - key.offset); | ||
| 675 | btrfs_mark_buffer_dirty(leaf); | ||
| 676 | |||
| 677 | ret = btrfs_del_items(trans, root, path, del_slot, del_nr); | ||
| 678 | BUG_ON(ret); | ||
| 679 | out: | ||
| 817 | btrfs_free_path(path); | 680 | btrfs_free_path(path); |
| 818 | return 0; | 681 | return 0; |
| 819 | } | 682 | } |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index b3ad168a0bfc..5440bab23635 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
| @@ -88,13 +88,14 @@ static noinline int cow_file_range(struct inode *inode, | |||
| 88 | u64 start, u64 end, int *page_started, | 88 | u64 start, u64 end, int *page_started, |
| 89 | unsigned long *nr_written, int unlock); | 89 | unsigned long *nr_written, int unlock); |
| 90 | 90 | ||
| 91 | static int btrfs_init_inode_security(struct inode *inode, struct inode *dir) | 91 | static int btrfs_init_inode_security(struct btrfs_trans_handle *trans, |
| 92 | struct inode *inode, struct inode *dir) | ||
| 92 | { | 93 | { |
| 93 | int err; | 94 | int err; |
| 94 | 95 | ||
| 95 | err = btrfs_init_acl(inode, dir); | 96 | err = btrfs_init_acl(trans, inode, dir); |
| 96 | if (!err) | 97 | if (!err) |
| 97 | err = btrfs_xattr_security_init(inode, dir); | 98 | err = btrfs_xattr_security_init(trans, inode, dir); |
| 98 | return err; | 99 | return err; |
| 99 | } | 100 | } |
| 100 | 101 | ||
| @@ -188,8 +189,18 @@ static noinline int insert_inline_extent(struct btrfs_trans_handle *trans, | |||
| 188 | btrfs_mark_buffer_dirty(leaf); | 189 | btrfs_mark_buffer_dirty(leaf); |
| 189 | btrfs_free_path(path); | 190 | btrfs_free_path(path); |
| 190 | 191 | ||
| 192 | /* | ||
| 193 | * we're an inline extent, so nobody can | ||
| 194 | * extend the file past i_size without locking | ||
| 195 | * a page we already have locked. | ||
| 196 | * | ||
| 197 | * We must do any isize and inode updates | ||
| 198 | * before we unlock the pages. Otherwise we | ||
| 199 | * could end up racing with unlink. | ||
| 200 | */ | ||
| 191 | BTRFS_I(inode)->disk_i_size = inode->i_size; | 201 | BTRFS_I(inode)->disk_i_size = inode->i_size; |
| 192 | btrfs_update_inode(trans, root, inode); | 202 | btrfs_update_inode(trans, root, inode); |
| 203 | |||
| 193 | return 0; | 204 | return 0; |
| 194 | fail: | 205 | fail: |
| 195 | btrfs_free_path(path); | 206 | btrfs_free_path(path); |
| @@ -230,8 +241,7 @@ static noinline int cow_file_range_inline(struct btrfs_trans_handle *trans, | |||
| 230 | return 1; | 241 | return 1; |
| 231 | } | 242 | } |
| 232 | 243 | ||
| 233 | ret = btrfs_drop_extents(trans, root, inode, start, | 244 | ret = btrfs_drop_extents(trans, inode, start, aligned_end, |
| 234 | aligned_end, aligned_end, start, | ||
| 235 | &hint_byte, 1); | 245 | &hint_byte, 1); |
| 236 | BUG_ON(ret); | 246 | BUG_ON(ret); |
| 237 | 247 | ||
| @@ -416,7 +426,6 @@ again: | |||
| 416 | start, end, | 426 | start, end, |
| 417 | total_compressed, pages); | 427 | total_compressed, pages); |
| 418 | } | 428 | } |
| 419 | btrfs_end_transaction(trans, root); | ||
| 420 | if (ret == 0) { | 429 | if (ret == 0) { |
| 421 | /* | 430 | /* |
| 422 | * inline extent creation worked, we don't need | 431 | * inline extent creation worked, we don't need |
| @@ -430,9 +439,11 @@ again: | |||
| 430 | EXTENT_CLEAR_DELALLOC | | 439 | EXTENT_CLEAR_DELALLOC | |
| 431 | EXTENT_CLEAR_ACCOUNTING | | 440 | EXTENT_CLEAR_ACCOUNTING | |
| 432 | EXTENT_SET_WRITEBACK | EXTENT_END_WRITEBACK); | 441 | EXTENT_SET_WRITEBACK | EXTENT_END_WRITEBACK); |
| 433 | ret = 0; | 442 | |
| 443 | btrfs_end_transaction(trans, root); | ||
| 434 | goto free_pages_out; | 444 | goto free_pages_out; |
| 435 | } | 445 | } |
| 446 | btrfs_end_transaction(trans, root); | ||
| 436 | } | 447 | } |
| 437 | 448 | ||
| 438 | if (will_compress) { | 449 | if (will_compress) { |
| @@ -543,7 +554,6 @@ static noinline int submit_compressed_extents(struct inode *inode, | |||
| 543 | if (list_empty(&async_cow->extents)) | 554 | if (list_empty(&async_cow->extents)) |
| 544 | return 0; | 555 | return 0; |
| 545 | 556 | ||
| 546 | trans = btrfs_join_transaction(root, 1); | ||
| 547 | 557 | ||
| 548 | while (!list_empty(&async_cow->extents)) { | 558 | while (!list_empty(&async_cow->extents)) { |
| 549 | async_extent = list_entry(async_cow->extents.next, | 559 | async_extent = list_entry(async_cow->extents.next, |
| @@ -590,19 +600,15 @@ retry: | |||
| 590 | lock_extent(io_tree, async_extent->start, | 600 | lock_extent(io_tree, async_extent->start, |
| 591 | async_extent->start + async_extent->ram_size - 1, | 601 | async_extent->start + async_extent->ram_size - 1, |
| 592 | GFP_NOFS); | 602 | GFP_NOFS); |
| 593 | /* | ||
| 594 | * here we're doing allocation and writeback of the | ||
| 595 | * compressed pages | ||
| 596 | */ | ||
| 597 | btrfs_drop_extent_cache(inode, async_extent->start, | ||
| 598 | async_extent->start + | ||
| 599 | async_extent->ram_size - 1, 0); | ||
| 600 | 603 | ||
| 604 | trans = btrfs_join_transaction(root, 1); | ||
| 601 | ret = btrfs_reserve_extent(trans, root, | 605 | ret = btrfs_reserve_extent(trans, root, |
| 602 | async_extent->compressed_size, | 606 | async_extent->compressed_size, |
| 603 | async_extent->compressed_size, | 607 | async_extent->compressed_size, |
| 604 | 0, alloc_hint, | 608 | 0, alloc_hint, |
| 605 | (u64)-1, &ins, 1); | 609 | (u64)-1, &ins, 1); |
| 610 | btrfs_end_transaction(trans, root); | ||
| 611 | |||
| 606 | if (ret) { | 612 | if (ret) { |
| 607 | int i; | 613 | int i; |
| 608 | for (i = 0; i < async_extent->nr_pages; i++) { | 614 | for (i = 0; i < async_extent->nr_pages; i++) { |
| @@ -618,6 +624,14 @@ retry: | |||
| 618 | goto retry; | 624 | goto retry; |
| 619 | } | 625 | } |
| 620 | 626 | ||
| 627 | /* | ||
| 628 | * here we're doing allocation and writeback of the | ||
| 629 | * compressed pages | ||
| 630 | */ | ||
| 631 | btrfs_drop_extent_cache(inode, async_extent->start, | ||
| 632 | async_extent->start + | ||
| 633 | async_extent->ram_size - 1, 0); | ||
| 634 | |||
| 621 | em = alloc_extent_map(GFP_NOFS); | 635 | em = alloc_extent_map(GFP_NOFS); |
| 622 | em->start = async_extent->start; | 636 | em->start = async_extent->start; |
| 623 | em->len = async_extent->ram_size; | 637 | em->len = async_extent->ram_size; |
| @@ -649,8 +663,6 @@ retry: | |||
| 649 | BTRFS_ORDERED_COMPRESSED); | 663 | BTRFS_ORDERED_COMPRESSED); |
| 650 | BUG_ON(ret); | 664 | BUG_ON(ret); |
| 651 | 665 | ||
| 652 | btrfs_end_transaction(trans, root); | ||
| 653 | |||
| 654 | /* | 666 | /* |
| 655 | * clear dirty, set writeback and unlock the pages. | 667 | * clear dirty, set writeback and unlock the pages. |
| 656 | */ | 668 | */ |
| @@ -672,13 +684,11 @@ retry: | |||
| 672 | async_extent->nr_pages); | 684 | async_extent->nr_pages); |
| 673 | 685 | ||
| 674 | BUG_ON(ret); | 686 | BUG_ON(ret); |
| 675 | trans = btrfs_join_transaction(root, 1); | ||
| 676 | alloc_hint = ins.objectid + ins.offset; | 687 | alloc_hint = ins.objectid + ins.offset; |
| 677 | kfree(async_extent); | 688 | kfree(async_extent); |
| 678 | cond_resched(); | 689 | cond_resched(); |
| 679 | } | 690 | } |
| 680 | 691 | ||
| 681 | btrfs_end_transaction(trans, root); | ||
| 682 | return 0; | 692 | return 0; |
| 683 | } | 693 | } |
| 684 | 694 | ||
| @@ -742,6 +752,7 @@ static noinline int cow_file_range(struct inode *inode, | |||
| 742 | EXTENT_CLEAR_DIRTY | | 752 | EXTENT_CLEAR_DIRTY | |
| 743 | EXTENT_SET_WRITEBACK | | 753 | EXTENT_SET_WRITEBACK | |
| 744 | EXTENT_END_WRITEBACK); | 754 | EXTENT_END_WRITEBACK); |
| 755 | |||
| 745 | *nr_written = *nr_written + | 756 | *nr_written = *nr_written + |
| 746 | (end - start + PAGE_CACHE_SIZE) / PAGE_CACHE_SIZE; | 757 | (end - start + PAGE_CACHE_SIZE) / PAGE_CACHE_SIZE; |
| 747 | *page_started = 1; | 758 | *page_started = 1; |
| @@ -1596,7 +1607,6 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans, | |||
| 1596 | struct inode *inode, u64 file_pos, | 1607 | struct inode *inode, u64 file_pos, |
| 1597 | u64 disk_bytenr, u64 disk_num_bytes, | 1608 | u64 disk_bytenr, u64 disk_num_bytes, |
| 1598 | u64 num_bytes, u64 ram_bytes, | 1609 | u64 num_bytes, u64 ram_bytes, |
| 1599 | u64 locked_end, | ||
| 1600 | u8 compression, u8 encryption, | 1610 | u8 compression, u8 encryption, |
| 1601 | u16 other_encoding, int extent_type) | 1611 | u16 other_encoding, int extent_type) |
| 1602 | { | 1612 | { |
| @@ -1622,9 +1632,8 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans, | |||
| 1622 | * the caller is expected to unpin it and allow it to be merged | 1632 | * the caller is expected to unpin it and allow it to be merged |
| 1623 | * with the others. | 1633 | * with the others. |
| 1624 | */ | 1634 | */ |
| 1625 | ret = btrfs_drop_extents(trans, root, inode, file_pos, | 1635 | ret = btrfs_drop_extents(trans, inode, file_pos, file_pos + num_bytes, |
| 1626 | file_pos + num_bytes, locked_end, | 1636 | &hint, 0); |
| 1627 | file_pos, &hint, 0); | ||
| 1628 | BUG_ON(ret); | 1637 | BUG_ON(ret); |
| 1629 | 1638 | ||
| 1630 | ins.objectid = inode->i_ino; | 1639 | ins.objectid = inode->i_ino; |
| @@ -1730,23 +1739,32 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) | |||
| 1730 | } | 1739 | } |
| 1731 | } | 1740 | } |
| 1732 | 1741 | ||
| 1733 | trans = btrfs_join_transaction(root, 1); | ||
| 1734 | |||
| 1735 | if (!ordered_extent) | 1742 | if (!ordered_extent) |
| 1736 | ordered_extent = btrfs_lookup_ordered_extent(inode, start); | 1743 | ordered_extent = btrfs_lookup_ordered_extent(inode, start); |
| 1737 | BUG_ON(!ordered_extent); | 1744 | BUG_ON(!ordered_extent); |
| 1738 | if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) | 1745 | if (test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags)) { |
| 1739 | goto nocow; | 1746 | BUG_ON(!list_empty(&ordered_extent->list)); |
| 1747 | ret = btrfs_ordered_update_i_size(inode, 0, ordered_extent); | ||
| 1748 | if (!ret) { | ||
| 1749 | trans = btrfs_join_transaction(root, 1); | ||
| 1750 | ret = btrfs_update_inode(trans, root, inode); | ||
| 1751 | BUG_ON(ret); | ||
| 1752 | btrfs_end_transaction(trans, root); | ||
| 1753 | } | ||
| 1754 | goto out; | ||
| 1755 | } | ||
| 1740 | 1756 | ||
| 1741 | lock_extent(io_tree, ordered_extent->file_offset, | 1757 | lock_extent(io_tree, ordered_extent->file_offset, |
| 1742 | ordered_extent->file_offset + ordered_extent->len - 1, | 1758 | ordered_extent->file_offset + ordered_extent->len - 1, |
| 1743 | GFP_NOFS); | 1759 | GFP_NOFS); |
| 1744 | 1760 | ||
| 1761 | trans = btrfs_join_transaction(root, 1); | ||
| 1762 | |||
| 1745 | if (test_bit(BTRFS_ORDERED_COMPRESSED, &ordered_extent->flags)) | 1763 | if (test_bit(BTRFS_ORDERED_COMPRESSED, &ordered_extent->flags)) |
| 1746 | compressed = 1; | 1764 | compressed = 1; |
| 1747 | if (test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) { | 1765 | if (test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) { |
| 1748 | BUG_ON(compressed); | 1766 | BUG_ON(compressed); |
| 1749 | ret = btrfs_mark_extent_written(trans, root, inode, | 1767 | ret = btrfs_mark_extent_written(trans, inode, |
| 1750 | ordered_extent->file_offset, | 1768 | ordered_extent->file_offset, |
| 1751 | ordered_extent->file_offset + | 1769 | ordered_extent->file_offset + |
| 1752 | ordered_extent->len); | 1770 | ordered_extent->len); |
| @@ -1758,8 +1776,6 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) | |||
| 1758 | ordered_extent->disk_len, | 1776 | ordered_extent->disk_len, |
| 1759 | ordered_extent->len, | 1777 | ordered_extent->len, |
| 1760 | ordered_extent->len, | 1778 | ordered_extent->len, |
| 1761 | ordered_extent->file_offset + | ||
| 1762 | ordered_extent->len, | ||
| 1763 | compressed, 0, 0, | 1779 | compressed, 0, 0, |
| 1764 | BTRFS_FILE_EXTENT_REG); | 1780 | BTRFS_FILE_EXTENT_REG); |
| 1765 | unpin_extent_cache(&BTRFS_I(inode)->extent_tree, | 1781 | unpin_extent_cache(&BTRFS_I(inode)->extent_tree, |
| @@ -1770,22 +1786,20 @@ static int btrfs_finish_ordered_io(struct inode *inode, u64 start, u64 end) | |||
| 1770 | unlock_extent(io_tree, ordered_extent->file_offset, | 1786 | unlock_extent(io_tree, ordered_extent->file_offset, |
| 1771 | ordered_extent->file_offset + ordered_extent->len - 1, | 1787 | ordered_extent->file_offset + ordered_extent->len - 1, |
| 1772 | GFP_NOFS); | 1788 | GFP_NOFS); |
| 1773 | nocow: | ||
| 1774 | add_pending_csums(trans, inode, ordered_extent->file_offset, | 1789 | add_pending_csums(trans, inode, ordered_extent->file_offset, |
| 1775 | &ordered_extent->list); | 1790 | &ordered_extent->list); |
| 1776 | 1791 | ||
| 1777 | mutex_lock(&BTRFS_I(inode)->extent_mutex); | 1792 | /* this also removes the ordered extent from the tree */ |
| 1778 | btrfs_ordered_update_i_size(inode, ordered_extent); | 1793 | btrfs_ordered_update_i_size(inode, 0, ordered_extent); |
| 1779 | btrfs_update_inode(trans, root, inode); | 1794 | ret = btrfs_update_inode(trans, root, inode); |
| 1780 | btrfs_remove_ordered_extent(inode, ordered_extent); | 1795 | BUG_ON(ret); |
| 1781 | mutex_unlock(&BTRFS_I(inode)->extent_mutex); | 1796 | btrfs_end_transaction(trans, root); |
| 1782 | 1797 | out: | |
| 1783 | /* once for us */ | 1798 | /* once for us */ |
| 1784 | btrfs_put_ordered_extent(ordered_extent); | 1799 | btrfs_put_ordered_extent(ordered_extent); |
| 1785 | /* once for the tree */ | 1800 | /* once for the tree */ |
| 1786 | btrfs_put_ordered_extent(ordered_extent); | 1801 | btrfs_put_ordered_extent(ordered_extent); |
| 1787 | 1802 | ||
| 1788 | btrfs_end_transaction(trans, root); | ||
| 1789 | return 0; | 1803 | return 0; |
| 1790 | } | 1804 | } |
| 1791 | 1805 | ||
| @@ -2008,6 +2022,54 @@ zeroit: | |||
| 2008 | return -EIO; | 2022 | return -EIO; |
| 2009 | } | 2023 | } |
| 2010 | 2024 | ||
| 2025 | struct delayed_iput { | ||
| 2026 | struct list_head list; | ||
| 2027 | struct inode *inode; | ||
| 2028 | }; | ||
| 2029 | |||
| 2030 | void btrfs_add_delayed_iput(struct inode *inode) | ||
| 2031 | { | ||
| 2032 | struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info; | ||
| 2033 | struct delayed_iput *delayed; | ||
| 2034 | |||
| 2035 | if (atomic_add_unless(&inode->i_count, -1, 1)) | ||
| 2036 | return; | ||
| 2037 | |||
| 2038 | delayed = kmalloc(sizeof(*delayed), GFP_NOFS | __GFP_NOFAIL); | ||
| 2039 | delayed->inode = inode; | ||
| 2040 | |||
| 2041 | spin_lock(&fs_info->delayed_iput_lock); | ||
| 2042 | list_add_tail(&delayed->list, &fs_info->delayed_iputs); | ||
| 2043 | spin_unlock(&fs_info->delayed_iput_lock); | ||
| 2044 | } | ||
| 2045 | |||
| 2046 | void btrfs_run_delayed_iputs(struct btrfs_root *root) | ||
| 2047 | { | ||
| 2048 | LIST_HEAD(list); | ||
| 2049 | struct btrfs_fs_info *fs_info = root->fs_info; | ||
| 2050 | struct delayed_iput *delayed; | ||
| 2051 | int empty; | ||
| 2052 | |||
| 2053 | spin_lock(&fs_info->delayed_iput_lock); | ||
| 2054 | empty = list_empty(&fs_info->delayed_iputs); | ||
| 2055 | spin_unlock(&fs_info->delayed_iput_lock); | ||
| 2056 | if (empty) | ||
| 2057 | return; | ||
| 2058 | |||
| 2059 | down_read(&root->fs_info->cleanup_work_sem); | ||
| 2060 | spin_lock(&fs_info->delayed_iput_lock); | ||
| 2061 | list_splice_init(&fs_info->delayed_iputs, &list); | ||
| 2062 | spin_unlock(&fs_info->delayed_iput_lock); | ||
| 2063 | |||
| 2064 | while (!list_empty(&list)) { | ||
| 2065 | delayed = list_entry(list.next, struct delayed_iput, list); | ||
| 2066 | list_del(&delayed->list); | ||
| 2067 | iput(delayed->inode); | ||
| 2068 | kfree(delayed); | ||
| 2069 | } | ||
| 2070 | up_read(&root->fs_info->cleanup_work_sem); | ||
| 2071 | } | ||
| 2072 | |||
| 2011 | /* | 2073 | /* |
| 2012 | * This creates an orphan entry for the given inode in case something goes | 2074 | * This creates an orphan entry for the given inode in case something goes |
| 2013 | * wrong in the middle of an unlink/truncate. | 2075 | * wrong in the middle of an unlink/truncate. |
| @@ -2080,16 +2142,17 @@ void btrfs_orphan_cleanup(struct btrfs_root *root) | |||
| 2080 | struct inode *inode; | 2142 | struct inode *inode; |
| 2081 | int ret = 0, nr_unlink = 0, nr_truncate = 0; | 2143 | int ret = 0, nr_unlink = 0, nr_truncate = 0; |
| 2082 | 2144 | ||
| 2083 | path = btrfs_alloc_path(); | 2145 | if (!xchg(&root->clean_orphans, 0)) |
| 2084 | if (!path) | ||
| 2085 | return; | 2146 | return; |
| 2147 | |||
| 2148 | path = btrfs_alloc_path(); | ||
| 2149 | BUG_ON(!path); | ||
| 2086 | path->reada = -1; | 2150 | path->reada = -1; |
| 2087 | 2151 | ||
| 2088 | key.objectid = BTRFS_ORPHAN_OBJECTID; | 2152 | key.objectid = BTRFS_ORPHAN_OBJECTID; |
| 2089 | btrfs_set_key_type(&key, BTRFS_ORPHAN_ITEM_KEY); | 2153 | btrfs_set_key_type(&key, BTRFS_ORPHAN_ITEM_KEY); |
| 2090 | key.offset = (u64)-1; | 2154 | key.offset = (u64)-1; |
| 2091 | 2155 | ||
| 2092 | |||
| 2093 | while (1) { | 2156 | while (1) { |
| 2094 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); | 2157 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); |
| 2095 | if (ret < 0) { | 2158 | if (ret < 0) { |
| @@ -2834,37 +2897,40 @@ out: | |||
| 2834 | * min_type is the minimum key type to truncate down to. If set to 0, this | 2897 | * min_type is the minimum key type to truncate down to. If set to 0, this |
| 2835 | * will kill all the items on this inode, including the INODE_ITEM_KEY. | 2898 | * will kill all the items on this inode, including the INODE_ITEM_KEY. |
| 2836 | */ | 2899 | */ |
| 2837 | noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, | 2900 | int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, |
| 2838 | struct btrfs_root *root, | 2901 | struct btrfs_root *root, |
| 2839 | struct inode *inode, | 2902 | struct inode *inode, |
| 2840 | u64 new_size, u32 min_type) | 2903 | u64 new_size, u32 min_type) |
| 2841 | { | 2904 | { |
| 2842 | int ret; | ||
| 2843 | struct btrfs_path *path; | 2905 | struct btrfs_path *path; |
| 2844 | struct btrfs_key key; | ||
| 2845 | struct btrfs_key found_key; | ||
| 2846 | u32 found_type = (u8)-1; | ||
| 2847 | struct extent_buffer *leaf; | 2906 | struct extent_buffer *leaf; |
| 2848 | struct btrfs_file_extent_item *fi; | 2907 | struct btrfs_file_extent_item *fi; |
| 2908 | struct btrfs_key key; | ||
| 2909 | struct btrfs_key found_key; | ||
| 2849 | u64 extent_start = 0; | 2910 | u64 extent_start = 0; |
| 2850 | u64 extent_num_bytes = 0; | 2911 | u64 extent_num_bytes = 0; |
| 2851 | u64 extent_offset = 0; | 2912 | u64 extent_offset = 0; |
| 2852 | u64 item_end = 0; | 2913 | u64 item_end = 0; |
| 2914 | u64 mask = root->sectorsize - 1; | ||
| 2915 | u32 found_type = (u8)-1; | ||
| 2853 | int found_extent; | 2916 | int found_extent; |
| 2854 | int del_item; | 2917 | int del_item; |
| 2855 | int pending_del_nr = 0; | 2918 | int pending_del_nr = 0; |
| 2856 | int pending_del_slot = 0; | 2919 | int pending_del_slot = 0; |
| 2857 | int extent_type = -1; | 2920 | int extent_type = -1; |
| 2858 | int encoding; | 2921 | int encoding; |
| 2859 | u64 mask = root->sectorsize - 1; | 2922 | int ret; |
| 2923 | int err = 0; | ||
| 2924 | |||
| 2925 | BUG_ON(new_size > 0 && min_type != BTRFS_EXTENT_DATA_KEY); | ||
| 2860 | 2926 | ||
| 2861 | if (root->ref_cows) | 2927 | if (root->ref_cows) |
| 2862 | btrfs_drop_extent_cache(inode, new_size & (~mask), (u64)-1, 0); | 2928 | btrfs_drop_extent_cache(inode, new_size & (~mask), (u64)-1, 0); |
| 2929 | |||
| 2863 | path = btrfs_alloc_path(); | 2930 | path = btrfs_alloc_path(); |
| 2864 | BUG_ON(!path); | 2931 | BUG_ON(!path); |
| 2865 | path->reada = -1; | 2932 | path->reada = -1; |
| 2866 | 2933 | ||
| 2867 | /* FIXME, add redo link to tree so we don't leak on crash */ | ||
| 2868 | key.objectid = inode->i_ino; | 2934 | key.objectid = inode->i_ino; |
| 2869 | key.offset = (u64)-1; | 2935 | key.offset = (u64)-1; |
| 2870 | key.type = (u8)-1; | 2936 | key.type = (u8)-1; |
| @@ -2872,17 +2938,17 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, | |||
| 2872 | search_again: | 2938 | search_again: |
| 2873 | path->leave_spinning = 1; | 2939 | path->leave_spinning = 1; |
| 2874 | ret = btrfs_search_slot(trans, root, &key, path, -1, 1); | 2940 | ret = btrfs_search_slot(trans, root, &key, path, -1, 1); |
| 2875 | if (ret < 0) | 2941 | if (ret < 0) { |
| 2876 | goto error; | 2942 | err = ret; |
| 2943 | goto out; | ||
| 2944 | } | ||
| 2877 | 2945 | ||
| 2878 | if (ret > 0) { | 2946 | if (ret > 0) { |
| 2879 | /* there are no items in the tree for us to truncate, we're | 2947 | /* there are no items in the tree for us to truncate, we're |
| 2880 | * done | 2948 | * done |
| 2881 | */ | 2949 | */ |
| 2882 | if (path->slots[0] == 0) { | 2950 | if (path->slots[0] == 0) |
| 2883 | ret = 0; | 2951 | goto out; |
| 2884 | goto error; | ||
| 2885 | } | ||
| 2886 | path->slots[0]--; | 2952 | path->slots[0]--; |
| 2887 | } | 2953 | } |
| 2888 | 2954 | ||
| @@ -2917,28 +2983,17 @@ search_again: | |||
| 2917 | } | 2983 | } |
| 2918 | item_end--; | 2984 | item_end--; |
| 2919 | } | 2985 | } |
| 2920 | if (item_end < new_size) { | 2986 | if (found_type > min_type) { |
| 2921 | if (found_type == BTRFS_DIR_ITEM_KEY) | 2987 | del_item = 1; |
| 2922 | found_type = BTRFS_INODE_ITEM_KEY; | 2988 | } else { |
| 2923 | else if (found_type == BTRFS_EXTENT_ITEM_KEY) | 2989 | if (item_end < new_size) |
| 2924 | found_type = BTRFS_EXTENT_DATA_KEY; | ||
| 2925 | else if (found_type == BTRFS_EXTENT_DATA_KEY) | ||
| 2926 | found_type = BTRFS_XATTR_ITEM_KEY; | ||
| 2927 | else if (found_type == BTRFS_XATTR_ITEM_KEY) | ||
| 2928 | found_type = BTRFS_INODE_REF_KEY; | ||
| 2929 | else if (found_type) | ||
| 2930 | found_type--; | ||
| 2931 | else | ||
| 2932 | break; | 2990 | break; |
| 2933 | btrfs_set_key_type(&key, found_type); | 2991 | if (found_key.offset >= new_size) |
| 2934 | goto next; | 2992 | del_item = 1; |
| 2993 | else | ||
| 2994 | del_item = 0; | ||
| 2935 | } | 2995 | } |
| 2936 | if (found_key.offset >= new_size) | ||
| 2937 | del_item = 1; | ||
| 2938 | else | ||
| 2939 | del_item = 0; | ||
| 2940 | found_extent = 0; | 2996 | found_extent = 0; |
| 2941 | |||
| 2942 | /* FIXME, shrink the extent if the ref count is only 1 */ | 2997 | /* FIXME, shrink the extent if the ref count is only 1 */ |
| 2943 | if (found_type != BTRFS_EXTENT_DATA_KEY) | 2998 | if (found_type != BTRFS_EXTENT_DATA_KEY) |
| 2944 | goto delete; | 2999 | goto delete; |
| @@ -3025,42 +3080,36 @@ delete: | |||
| 3025 | inode->i_ino, extent_offset); | 3080 | inode->i_ino, extent_offset); |
| 3026 | BUG_ON(ret); | 3081 | BUG_ON(ret); |
| 3027 | } | 3082 | } |
| 3028 | next: | ||
| 3029 | if (path->slots[0] == 0) { | ||
| 3030 | if (pending_del_nr) | ||
| 3031 | goto del_pending; | ||
| 3032 | btrfs_release_path(root, path); | ||
| 3033 | if (found_type == BTRFS_INODE_ITEM_KEY) | ||
| 3034 | break; | ||
| 3035 | goto search_again; | ||
| 3036 | } | ||
| 3037 | 3083 | ||
| 3038 | path->slots[0]--; | 3084 | if (found_type == BTRFS_INODE_ITEM_KEY) |
| 3039 | if (pending_del_nr && | 3085 | break; |
| 3040 | path->slots[0] + 1 != pending_del_slot) { | 3086 | |
| 3041 | struct btrfs_key debug; | 3087 | if (path->slots[0] == 0 || |
| 3042 | del_pending: | 3088 | path->slots[0] != pending_del_slot) { |
| 3043 | btrfs_item_key_to_cpu(path->nodes[0], &debug, | 3089 | if (root->ref_cows) { |
| 3044 | pending_del_slot); | 3090 | err = -EAGAIN; |
| 3045 | ret = btrfs_del_items(trans, root, path, | 3091 | goto out; |
| 3046 | pending_del_slot, | 3092 | } |
| 3047 | pending_del_nr); | 3093 | if (pending_del_nr) { |
| 3048 | BUG_ON(ret); | 3094 | ret = btrfs_del_items(trans, root, path, |
| 3049 | pending_del_nr = 0; | 3095 | pending_del_slot, |
| 3096 | pending_del_nr); | ||
| 3097 | BUG_ON(ret); | ||
| 3098 | pending_del_nr = 0; | ||
| 3099 | } | ||
| 3050 | btrfs_release_path(root, path); | 3100 | btrfs_release_path(root, path); |
| 3051 | if (found_type == BTRFS_INODE_ITEM_KEY) | ||
| 3052 | break; | ||
| 3053 | goto search_again; | 3101 | goto search_again; |
| 3102 | } else { | ||
| 3103 | path->slots[0]--; | ||
| 3054 | } | 3104 | } |
| 3055 | } | 3105 | } |
| 3056 | ret = 0; | 3106 | out: |
| 3057 | error: | ||
| 3058 | if (pending_del_nr) { | 3107 | if (pending_del_nr) { |
| 3059 | ret = btrfs_del_items(trans, root, path, pending_del_slot, | 3108 | ret = btrfs_del_items(trans, root, path, pending_del_slot, |
| 3060 | pending_del_nr); | 3109 | pending_del_nr); |
| 3061 | } | 3110 | } |
| 3062 | btrfs_free_path(path); | 3111 | btrfs_free_path(path); |
| 3063 | return ret; | 3112 | return err; |
| 3064 | } | 3113 | } |
| 3065 | 3114 | ||
| 3066 | /* | 3115 | /* |
| @@ -3180,10 +3229,6 @@ int btrfs_cont_expand(struct inode *inode, loff_t size) | |||
| 3180 | if (size <= hole_start) | 3229 | if (size <= hole_start) |
| 3181 | return 0; | 3230 | return 0; |
| 3182 | 3231 | ||
| 3183 | err = btrfs_truncate_page(inode->i_mapping, inode->i_size); | ||
| 3184 | if (err) | ||
| 3185 | return err; | ||
| 3186 | |||
| 3187 | while (1) { | 3232 | while (1) { |
| 3188 | struct btrfs_ordered_extent *ordered; | 3233 | struct btrfs_ordered_extent *ordered; |
| 3189 | btrfs_wait_ordered_range(inode, hole_start, | 3234 | btrfs_wait_ordered_range(inode, hole_start, |
| @@ -3196,9 +3241,6 @@ int btrfs_cont_expand(struct inode *inode, loff_t size) | |||
| 3196 | btrfs_put_ordered_extent(ordered); | 3241 | btrfs_put_ordered_extent(ordered); |
| 3197 | } | 3242 | } |
| 3198 | 3243 | ||
| 3199 | trans = btrfs_start_transaction(root, 1); | ||
| 3200 | btrfs_set_trans_block_group(trans, inode); | ||
| 3201 | |||
| 3202 | cur_offset = hole_start; | 3244 | cur_offset = hole_start; |
| 3203 | while (1) { | 3245 | while (1) { |
| 3204 | em = btrfs_get_extent(inode, NULL, 0, cur_offset, | 3246 | em = btrfs_get_extent(inode, NULL, 0, cur_offset, |
| @@ -3206,40 +3248,120 @@ int btrfs_cont_expand(struct inode *inode, loff_t size) | |||
| 3206 | BUG_ON(IS_ERR(em) || !em); | 3248 | BUG_ON(IS_ERR(em) || !em); |
| 3207 | last_byte = min(extent_map_end(em), block_end); | 3249 | last_byte = min(extent_map_end(em), block_end); |
| 3208 | last_byte = (last_byte + mask) & ~mask; | 3250 | last_byte = (last_byte + mask) & ~mask; |
| 3209 | if (test_bit(EXTENT_FLAG_VACANCY, &em->flags)) { | 3251 | if (!test_bit(EXTENT_FLAG_PREALLOC, &em->flags)) { |
| 3210 | u64 hint_byte = 0; | 3252 | u64 hint_byte = 0; |
| 3211 | hole_size = last_byte - cur_offset; | 3253 | hole_size = last_byte - cur_offset; |
| 3212 | err = btrfs_drop_extents(trans, root, inode, | ||
| 3213 | cur_offset, | ||
| 3214 | cur_offset + hole_size, | ||
| 3215 | block_end, | ||
| 3216 | cur_offset, &hint_byte, 1); | ||
| 3217 | if (err) | ||
| 3218 | break; | ||
| 3219 | 3254 | ||
| 3220 | err = btrfs_reserve_metadata_space(root, 1); | 3255 | err = btrfs_reserve_metadata_space(root, 2); |
| 3221 | if (err) | 3256 | if (err) |
| 3222 | break; | 3257 | break; |
| 3223 | 3258 | ||
| 3259 | trans = btrfs_start_transaction(root, 1); | ||
| 3260 | btrfs_set_trans_block_group(trans, inode); | ||
| 3261 | |||
| 3262 | err = btrfs_drop_extents(trans, inode, cur_offset, | ||
| 3263 | cur_offset + hole_size, | ||
| 3264 | &hint_byte, 1); | ||
| 3265 | BUG_ON(err); | ||
| 3266 | |||
| 3224 | err = btrfs_insert_file_extent(trans, root, | 3267 | err = btrfs_insert_file_extent(trans, root, |
| 3225 | inode->i_ino, cur_offset, 0, | 3268 | inode->i_ino, cur_offset, 0, |
| 3226 | 0, hole_size, 0, hole_size, | 3269 | 0, hole_size, 0, hole_size, |
| 3227 | 0, 0, 0); | 3270 | 0, 0, 0); |
| 3271 | BUG_ON(err); | ||
| 3272 | |||
| 3228 | btrfs_drop_extent_cache(inode, hole_start, | 3273 | btrfs_drop_extent_cache(inode, hole_start, |
| 3229 | last_byte - 1, 0); | 3274 | last_byte - 1, 0); |
| 3230 | btrfs_unreserve_metadata_space(root, 1); | 3275 | |
| 3276 | btrfs_end_transaction(trans, root); | ||
| 3277 | btrfs_unreserve_metadata_space(root, 2); | ||
| 3231 | } | 3278 | } |
| 3232 | free_extent_map(em); | 3279 | free_extent_map(em); |
| 3233 | cur_offset = last_byte; | 3280 | cur_offset = last_byte; |
| 3234 | if (err || cur_offset >= block_end) | 3281 | if (cur_offset >= block_end) |
| 3235 | break; | 3282 | break; |
| 3236 | } | 3283 | } |
| 3237 | 3284 | ||
| 3238 | btrfs_end_transaction(trans, root); | ||
| 3239 | unlock_extent(io_tree, hole_start, block_end - 1, GFP_NOFS); | 3285 | unlock_extent(io_tree, hole_start, block_end - 1, GFP_NOFS); |
| 3240 | return err; | 3286 | return err; |
| 3241 | } | 3287 | } |
| 3242 | 3288 | ||
| 3289 | static int btrfs_setattr_size(struct inode *inode, struct iattr *attr) | ||
| 3290 | { | ||
| 3291 | struct btrfs_root *root = BTRFS_I(inode)->root; | ||
| 3292 | struct btrfs_trans_handle *trans; | ||
| 3293 | unsigned long nr; | ||
| 3294 | int ret; | ||
| 3295 | |||
| 3296 | if (attr->ia_size == inode->i_size) | ||
| 3297 | return 0; | ||
| 3298 | |||
| 3299 | if (attr->ia_size > inode->i_size) { | ||
| 3300 | unsigned long limit; | ||
| 3301 | limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur; | ||
| 3302 | if (attr->ia_size > inode->i_sb->s_maxbytes) | ||
| 3303 | return -EFBIG; | ||
| 3304 | if (limit != RLIM_INFINITY && attr->ia_size > limit) { | ||
| 3305 | send_sig(SIGXFSZ, current, 0); | ||
| 3306 | return -EFBIG; | ||
| 3307 | } | ||
| 3308 | } | ||
| 3309 | |||
| 3310 | ret = btrfs_reserve_metadata_space(root, 1); | ||
| 3311 | if (ret) | ||
| 3312 | return ret; | ||
| 3313 | |||
| 3314 | trans = btrfs_start_transaction(root, 1); | ||
| 3315 | btrfs_set_trans_block_group(trans, inode); | ||
| 3316 | |||
| 3317 | ret = btrfs_orphan_add(trans, inode); | ||
| 3318 | BUG_ON(ret); | ||
| 3319 | |||
| 3320 | nr = trans->blocks_used; | ||
| 3321 | btrfs_end_transaction(trans, root); | ||
| 3322 | btrfs_unreserve_metadata_space(root, 1); | ||
| 3323 | btrfs_btree_balance_dirty(root, nr); | ||
| 3324 | |||
| 3325 | if (attr->ia_size > inode->i_size) { | ||
| 3326 | ret = btrfs_cont_expand(inode, attr->ia_size); | ||
| 3327 | if (ret) { | ||
| 3328 | btrfs_truncate(inode); | ||
| 3329 | return ret; | ||
| 3330 | } | ||
| 3331 | |||
| 3332 | i_size_write(inode, attr->ia_size); | ||
| 3333 | btrfs_ordered_update_i_size(inode, inode->i_size, NULL); | ||
| 3334 | |||
| 3335 | trans = btrfs_start_transaction(root, 1); | ||
| 3336 | btrfs_set_trans_block_group(trans, inode); | ||
| 3337 | |||
| 3338 | ret = btrfs_update_inode(trans, root, inode); | ||
| 3339 | BUG_ON(ret); | ||
| 3340 | if (inode->i_nlink > 0) { | ||
| 3341 | ret = btrfs_orphan_del(trans, inode); | ||
| 3342 | BUG_ON(ret); | ||
| 3343 | } | ||
| 3344 | nr = trans->blocks_used; | ||
| 3345 | btrfs_end_transaction(trans, root); | ||
| 3346 | btrfs_btree_balance_dirty(root, nr); | ||
| 3347 | return 0; | ||
| 3348 | } | ||
| 3349 | |||
| 3350 | /* | ||
| 3351 | * We're truncating a file that used to have good data down to | ||
| 3352 | * zero. Make sure it gets into the ordered flush list so that | ||
| 3353 | * any new writes get down to disk quickly. | ||
| 3354 | */ | ||
| 3355 | if (attr->ia_size == 0) | ||
| 3356 | BTRFS_I(inode)->ordered_data_close = 1; | ||
| 3357 | |||
| 3358 | /* we don't support swapfiles, so vmtruncate shouldn't fail */ | ||
| 3359 | ret = vmtruncate(inode, attr->ia_size); | ||
| 3360 | BUG_ON(ret); | ||
| 3361 | |||
| 3362 | return 0; | ||
| 3363 | } | ||
| 3364 | |||
| 3243 | static int btrfs_setattr(struct dentry *dentry, struct iattr *attr) | 3365 | static int btrfs_setattr(struct dentry *dentry, struct iattr *attr) |
| 3244 | { | 3366 | { |
| 3245 | struct inode *inode = dentry->d_inode; | 3367 | struct inode *inode = dentry->d_inode; |
| @@ -3250,23 +3372,14 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
| 3250 | return err; | 3372 | return err; |
| 3251 | 3373 | ||
| 3252 | if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_SIZE)) { | 3374 | if (S_ISREG(inode->i_mode) && (attr->ia_valid & ATTR_SIZE)) { |
| 3253 | if (attr->ia_size > inode->i_size) { | 3375 | err = btrfs_setattr_size(inode, attr); |
| 3254 | err = btrfs_cont_expand(inode, attr->ia_size); | 3376 | if (err) |
| 3255 | if (err) | 3377 | return err; |
| 3256 | return err; | ||
| 3257 | } else if (inode->i_size > 0 && | ||
| 3258 | attr->ia_size == 0) { | ||
| 3259 | |||
| 3260 | /* we're truncating a file that used to have good | ||
| 3261 | * data down to zero. Make sure it gets into | ||
| 3262 | * the ordered flush list so that any new writes | ||
| 3263 | * get down to disk quickly. | ||
| 3264 | */ | ||
| 3265 | BTRFS_I(inode)->ordered_data_close = 1; | ||
| 3266 | } | ||
| 3267 | } | 3378 | } |
| 3379 | attr->ia_valid &= ~ATTR_SIZE; | ||
| 3268 | 3380 | ||
| 3269 | err = inode_setattr(inode, attr); | 3381 | if (attr->ia_valid) |
| 3382 | err = inode_setattr(inode, attr); | ||
| 3270 | 3383 | ||
| 3271 | if (!err && ((attr->ia_valid & ATTR_MODE))) | 3384 | if (!err && ((attr->ia_valid & ATTR_MODE))) |
| 3272 | err = btrfs_acl_chmod(inode); | 3385 | err = btrfs_acl_chmod(inode); |
| @@ -3287,36 +3400,43 @@ void btrfs_delete_inode(struct inode *inode) | |||
| 3287 | } | 3400 | } |
| 3288 | btrfs_wait_ordered_range(inode, 0, (u64)-1); | 3401 | btrfs_wait_ordered_range(inode, 0, (u64)-1); |
| 3289 | 3402 | ||
| 3403 | if (root->fs_info->log_root_recovering) { | ||
| 3404 | BUG_ON(!list_empty(&BTRFS_I(inode)->i_orphan)); | ||
| 3405 | goto no_delete; | ||
| 3406 | } | ||
| 3407 | |||
| 3290 | if (inode->i_nlink > 0) { | 3408 | if (inode->i_nlink > 0) { |
| 3291 | BUG_ON(btrfs_root_refs(&root->root_item) != 0); | 3409 | BUG_ON(btrfs_root_refs(&root->root_item) != 0); |
| 3292 | goto no_delete; | 3410 | goto no_delete; |
| 3293 | } | 3411 | } |
| 3294 | 3412 | ||
| 3295 | btrfs_i_size_write(inode, 0); | 3413 | btrfs_i_size_write(inode, 0); |
| 3296 | trans = btrfs_join_transaction(root, 1); | ||
| 3297 | 3414 | ||
| 3298 | btrfs_set_trans_block_group(trans, inode); | 3415 | while (1) { |
| 3299 | ret = btrfs_truncate_inode_items(trans, root, inode, inode->i_size, 0); | 3416 | trans = btrfs_start_transaction(root, 1); |
| 3300 | if (ret) { | 3417 | btrfs_set_trans_block_group(trans, inode); |
| 3301 | btrfs_orphan_del(NULL, inode); | 3418 | ret = btrfs_truncate_inode_items(trans, root, inode, 0, 0); |
| 3302 | goto no_delete_lock; | ||
| 3303 | } | ||
| 3304 | 3419 | ||
| 3305 | btrfs_orphan_del(trans, inode); | 3420 | if (ret != -EAGAIN) |
| 3421 | break; | ||
| 3306 | 3422 | ||
| 3307 | nr = trans->blocks_used; | 3423 | nr = trans->blocks_used; |
| 3308 | clear_inode(inode); | 3424 | btrfs_end_transaction(trans, root); |
| 3425 | trans = NULL; | ||
| 3426 | btrfs_btree_balance_dirty(root, nr); | ||
| 3427 | } | ||
| 3309 | 3428 | ||
| 3310 | btrfs_end_transaction(trans, root); | 3429 | if (ret == 0) { |
| 3311 | btrfs_btree_balance_dirty(root, nr); | 3430 | ret = btrfs_orphan_del(trans, inode); |
| 3312 | return; | 3431 | BUG_ON(ret); |
| 3432 | } | ||
| 3313 | 3433 | ||
| 3314 | no_delete_lock: | ||
| 3315 | nr = trans->blocks_used; | 3434 | nr = trans->blocks_used; |
| 3316 | btrfs_end_transaction(trans, root); | 3435 | btrfs_end_transaction(trans, root); |
| 3317 | btrfs_btree_balance_dirty(root, nr); | 3436 | btrfs_btree_balance_dirty(root, nr); |
| 3318 | no_delete: | 3437 | no_delete: |
| 3319 | clear_inode(inode); | 3438 | clear_inode(inode); |
| 3439 | return; | ||
| 3320 | } | 3440 | } |
| 3321 | 3441 | ||
| 3322 | /* | 3442 | /* |
| @@ -3569,7 +3689,6 @@ static noinline void init_btrfs_i(struct inode *inode) | |||
| 3569 | INIT_LIST_HEAD(&BTRFS_I(inode)->ordered_operations); | 3689 | INIT_LIST_HEAD(&BTRFS_I(inode)->ordered_operations); |
| 3570 | RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node); | 3690 | RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node); |
| 3571 | btrfs_ordered_inode_tree_init(&BTRFS_I(inode)->ordered_tree); | 3691 | btrfs_ordered_inode_tree_init(&BTRFS_I(inode)->ordered_tree); |
| 3572 | mutex_init(&BTRFS_I(inode)->extent_mutex); | ||
| 3573 | mutex_init(&BTRFS_I(inode)->log_mutex); | 3692 | mutex_init(&BTRFS_I(inode)->log_mutex); |
| 3574 | } | 3693 | } |
| 3575 | 3694 | ||
| @@ -3695,6 +3814,13 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry) | |||
| 3695 | } | 3814 | } |
| 3696 | srcu_read_unlock(&root->fs_info->subvol_srcu, index); | 3815 | srcu_read_unlock(&root->fs_info->subvol_srcu, index); |
| 3697 | 3816 | ||
| 3817 | if (root != sub_root) { | ||
| 3818 | down_read(&root->fs_info->cleanup_work_sem); | ||
| 3819 | if (!(inode->i_sb->s_flags & MS_RDONLY)) | ||
| 3820 | btrfs_orphan_cleanup(sub_root); | ||
| 3821 | up_read(&root->fs_info->cleanup_work_sem); | ||
| 3822 | } | ||
| 3823 | |||
| 3698 | return inode; | 3824 | return inode; |
| 3699 | } | 3825 | } |
| 3700 | 3826 | ||
| @@ -4219,7 +4345,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, | |||
| 4219 | if (IS_ERR(inode)) | 4345 | if (IS_ERR(inode)) |
| 4220 | goto out_unlock; | 4346 | goto out_unlock; |
| 4221 | 4347 | ||
| 4222 | err = btrfs_init_inode_security(inode, dir); | 4348 | err = btrfs_init_inode_security(trans, inode, dir); |
| 4223 | if (err) { | 4349 | if (err) { |
| 4224 | drop_inode = 1; | 4350 | drop_inode = 1; |
| 4225 | goto out_unlock; | 4351 | goto out_unlock; |
| @@ -4290,7 +4416,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry, | |||
| 4290 | if (IS_ERR(inode)) | 4416 | if (IS_ERR(inode)) |
| 4291 | goto out_unlock; | 4417 | goto out_unlock; |
| 4292 | 4418 | ||
| 4293 | err = btrfs_init_inode_security(inode, dir); | 4419 | err = btrfs_init_inode_security(trans, inode, dir); |
| 4294 | if (err) { | 4420 | if (err) { |
| 4295 | drop_inode = 1; | 4421 | drop_inode = 1; |
| 4296 | goto out_unlock; | 4422 | goto out_unlock; |
| @@ -4336,6 +4462,10 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, | |||
| 4336 | if (inode->i_nlink == 0) | 4462 | if (inode->i_nlink == 0) |
| 4337 | return -ENOENT; | 4463 | return -ENOENT; |
| 4338 | 4464 | ||
| 4465 | /* do not allow sys_link's with other subvols of the same device */ | ||
| 4466 | if (root->objectid != BTRFS_I(inode)->root->objectid) | ||
| 4467 | return -EPERM; | ||
| 4468 | |||
| 4339 | /* | 4469 | /* |
| 4340 | * 1 item for inode ref | 4470 | * 1 item for inode ref |
| 4341 | * 2 items for dir items | 4471 | * 2 items for dir items |
| @@ -4423,7 +4553,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
| 4423 | 4553 | ||
| 4424 | drop_on_err = 1; | 4554 | drop_on_err = 1; |
| 4425 | 4555 | ||
| 4426 | err = btrfs_init_inode_security(inode, dir); | 4556 | err = btrfs_init_inode_security(trans, inode, dir); |
| 4427 | if (err) | 4557 | if (err) |
| 4428 | goto out_fail; | 4558 | goto out_fail; |
| 4429 | 4559 | ||
| @@ -5074,17 +5204,20 @@ static void btrfs_truncate(struct inode *inode) | |||
| 5074 | unsigned long nr; | 5204 | unsigned long nr; |
| 5075 | u64 mask = root->sectorsize - 1; | 5205 | u64 mask = root->sectorsize - 1; |
| 5076 | 5206 | ||
| 5077 | if (!S_ISREG(inode->i_mode)) | 5207 | if (!S_ISREG(inode->i_mode)) { |
| 5078 | return; | 5208 | WARN_ON(1); |
| 5079 | if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) | ||
| 5080 | return; | 5209 | return; |
| 5210 | } | ||
| 5081 | 5211 | ||
| 5082 | ret = btrfs_truncate_page(inode->i_mapping, inode->i_size); | 5212 | ret = btrfs_truncate_page(inode->i_mapping, inode->i_size); |
| 5083 | if (ret) | 5213 | if (ret) |
| 5084 | return; | 5214 | return; |
| 5215 | |||
| 5085 | btrfs_wait_ordered_range(inode, inode->i_size & (~mask), (u64)-1); | 5216 | btrfs_wait_ordered_range(inode, inode->i_size & (~mask), (u64)-1); |
| 5217 | btrfs_ordered_update_i_size(inode, inode->i_size, NULL); | ||
| 5086 | 5218 | ||
| 5087 | trans = btrfs_start_transaction(root, 1); | 5219 | trans = btrfs_start_transaction(root, 1); |
| 5220 | btrfs_set_trans_block_group(trans, inode); | ||
| 5088 | 5221 | ||
| 5089 | /* | 5222 | /* |
| 5090 | * setattr is responsible for setting the ordered_data_close flag, | 5223 | * setattr is responsible for setting the ordered_data_close flag, |
| @@ -5106,21 +5239,32 @@ static void btrfs_truncate(struct inode *inode) | |||
| 5106 | if (inode->i_size == 0 && BTRFS_I(inode)->ordered_data_close) | 5239 | if (inode->i_size == 0 && BTRFS_I(inode)->ordered_data_close) |
| 5107 | btrfs_add_ordered_operation(trans, root, inode); | 5240 | btrfs_add_ordered_operation(trans, root, inode); |
| 5108 | 5241 | ||
| 5109 | btrfs_set_trans_block_group(trans, inode); | 5242 | while (1) { |
| 5110 | btrfs_i_size_write(inode, inode->i_size); | 5243 | ret = btrfs_truncate_inode_items(trans, root, inode, |
| 5244 | inode->i_size, | ||
| 5245 | BTRFS_EXTENT_DATA_KEY); | ||
| 5246 | if (ret != -EAGAIN) | ||
| 5247 | break; | ||
| 5111 | 5248 | ||
| 5112 | ret = btrfs_orphan_add(trans, inode); | 5249 | ret = btrfs_update_inode(trans, root, inode); |
| 5113 | if (ret) | 5250 | BUG_ON(ret); |
| 5114 | goto out; | 5251 | |
| 5115 | /* FIXME, add redo link to tree so we don't leak on crash */ | 5252 | nr = trans->blocks_used; |
| 5116 | ret = btrfs_truncate_inode_items(trans, root, inode, inode->i_size, | 5253 | btrfs_end_transaction(trans, root); |
| 5117 | BTRFS_EXTENT_DATA_KEY); | 5254 | btrfs_btree_balance_dirty(root, nr); |
| 5118 | btrfs_update_inode(trans, root, inode); | 5255 | |
| 5256 | trans = btrfs_start_transaction(root, 1); | ||
| 5257 | btrfs_set_trans_block_group(trans, inode); | ||
| 5258 | } | ||
| 5119 | 5259 | ||
| 5120 | ret = btrfs_orphan_del(trans, inode); | 5260 | if (ret == 0 && inode->i_nlink > 0) { |
| 5261 | ret = btrfs_orphan_del(trans, inode); | ||
| 5262 | BUG_ON(ret); | ||
| 5263 | } | ||
| 5264 | |||
| 5265 | ret = btrfs_update_inode(trans, root, inode); | ||
| 5121 | BUG_ON(ret); | 5266 | BUG_ON(ret); |
| 5122 | 5267 | ||
| 5123 | out: | ||
| 5124 | nr = trans->blocks_used; | 5268 | nr = trans->blocks_used; |
| 5125 | ret = btrfs_end_transaction_throttle(trans, root); | 5269 | ret = btrfs_end_transaction_throttle(trans, root); |
| 5126 | BUG_ON(ret); | 5270 | BUG_ON(ret); |
| @@ -5217,9 +5361,9 @@ void btrfs_destroy_inode(struct inode *inode) | |||
| 5217 | 5361 | ||
| 5218 | spin_lock(&root->list_lock); | 5362 | spin_lock(&root->list_lock); |
| 5219 | if (!list_empty(&BTRFS_I(inode)->i_orphan)) { | 5363 | if (!list_empty(&BTRFS_I(inode)->i_orphan)) { |
| 5220 | printk(KERN_ERR "BTRFS: inode %lu: inode still on the orphan" | 5364 | printk(KERN_INFO "BTRFS: inode %lu still on the orphan list\n", |
| 5221 | " list\n", inode->i_ino); | 5365 | inode->i_ino); |
| 5222 | dump_stack(); | 5366 | list_del_init(&BTRFS_I(inode)->i_orphan); |
| 5223 | } | 5367 | } |
| 5224 | spin_unlock(&root->list_lock); | 5368 | spin_unlock(&root->list_lock); |
| 5225 | 5369 | ||
| @@ -5476,7 +5620,7 @@ out_fail: | |||
| 5476 | * some fairly slow code that needs optimization. This walks the list | 5620 | * some fairly slow code that needs optimization. This walks the list |
| 5477 | * of all the inodes with pending delalloc and forces them to disk. | 5621 | * of all the inodes with pending delalloc and forces them to disk. |
| 5478 | */ | 5622 | */ |
| 5479 | int btrfs_start_delalloc_inodes(struct btrfs_root *root) | 5623 | int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput) |
| 5480 | { | 5624 | { |
| 5481 | struct list_head *head = &root->fs_info->delalloc_inodes; | 5625 | struct list_head *head = &root->fs_info->delalloc_inodes; |
| 5482 | struct btrfs_inode *binode; | 5626 | struct btrfs_inode *binode; |
| @@ -5495,7 +5639,10 @@ int btrfs_start_delalloc_inodes(struct btrfs_root *root) | |||
| 5495 | spin_unlock(&root->fs_info->delalloc_lock); | 5639 | spin_unlock(&root->fs_info->delalloc_lock); |
| 5496 | if (inode) { | 5640 | if (inode) { |
| 5497 | filemap_flush(inode->i_mapping); | 5641 | filemap_flush(inode->i_mapping); |
| 5498 | iput(inode); | 5642 | if (delay_iput) |
| 5643 | btrfs_add_delayed_iput(inode); | ||
| 5644 | else | ||
| 5645 | iput(inode); | ||
| 5499 | } | 5646 | } |
| 5500 | cond_resched(); | 5647 | cond_resched(); |
| 5501 | spin_lock(&root->fs_info->delalloc_lock); | 5648 | spin_lock(&root->fs_info->delalloc_lock); |
| @@ -5569,7 +5716,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry, | |||
| 5569 | if (IS_ERR(inode)) | 5716 | if (IS_ERR(inode)) |
| 5570 | goto out_unlock; | 5717 | goto out_unlock; |
| 5571 | 5718 | ||
| 5572 | err = btrfs_init_inode_security(inode, dir); | 5719 | err = btrfs_init_inode_security(trans, inode, dir); |
| 5573 | if (err) { | 5720 | if (err) { |
| 5574 | drop_inode = 1; | 5721 | drop_inode = 1; |
| 5575 | goto out_unlock; | 5722 | goto out_unlock; |
| @@ -5641,10 +5788,10 @@ out_fail: | |||
| 5641 | return err; | 5788 | return err; |
| 5642 | } | 5789 | } |
| 5643 | 5790 | ||
| 5644 | static int prealloc_file_range(struct btrfs_trans_handle *trans, | 5791 | static int prealloc_file_range(struct inode *inode, u64 start, u64 end, |
| 5645 | struct inode *inode, u64 start, u64 end, | 5792 | u64 alloc_hint, int mode) |
| 5646 | u64 locked_end, u64 alloc_hint, int mode) | ||
| 5647 | { | 5793 | { |
| 5794 | struct btrfs_trans_handle *trans; | ||
| 5648 | struct btrfs_root *root = BTRFS_I(inode)->root; | 5795 | struct btrfs_root *root = BTRFS_I(inode)->root; |
| 5649 | struct btrfs_key ins; | 5796 | struct btrfs_key ins; |
| 5650 | u64 alloc_size; | 5797 | u64 alloc_size; |
| @@ -5655,43 +5802,56 @@ static int prealloc_file_range(struct btrfs_trans_handle *trans, | |||
| 5655 | while (num_bytes > 0) { | 5802 | while (num_bytes > 0) { |
| 5656 | alloc_size = min(num_bytes, root->fs_info->max_extent); | 5803 | alloc_size = min(num_bytes, root->fs_info->max_extent); |
| 5657 | 5804 | ||
| 5658 | ret = btrfs_reserve_metadata_space(root, 1); | 5805 | trans = btrfs_start_transaction(root, 1); |
| 5659 | if (ret) | ||
| 5660 | goto out; | ||
| 5661 | 5806 | ||
| 5662 | ret = btrfs_reserve_extent(trans, root, alloc_size, | 5807 | ret = btrfs_reserve_extent(trans, root, alloc_size, |
| 5663 | root->sectorsize, 0, alloc_hint, | 5808 | root->sectorsize, 0, alloc_hint, |
| 5664 | (u64)-1, &ins, 1); | 5809 | (u64)-1, &ins, 1); |
| 5665 | if (ret) { | 5810 | if (ret) { |
| 5666 | WARN_ON(1); | 5811 | WARN_ON(1); |
| 5667 | goto out; | 5812 | goto stop_trans; |
| 5813 | } | ||
| 5814 | |||
| 5815 | ret = btrfs_reserve_metadata_space(root, 3); | ||
| 5816 | if (ret) { | ||
| 5817 | btrfs_free_reserved_extent(root, ins.objectid, | ||
| 5818 | ins.offset); | ||
| 5819 | goto stop_trans; | ||
| 5668 | } | 5820 | } |
| 5821 | |||
| 5669 | ret = insert_reserved_file_extent(trans, inode, | 5822 | ret = insert_reserved_file_extent(trans, inode, |
| 5670 | cur_offset, ins.objectid, | 5823 | cur_offset, ins.objectid, |
| 5671 | ins.offset, ins.offset, | 5824 | ins.offset, ins.offset, |
| 5672 | ins.offset, locked_end, | 5825 | ins.offset, 0, 0, 0, |
| 5673 | 0, 0, 0, | ||
| 5674 | BTRFS_FILE_EXTENT_PREALLOC); | 5826 | BTRFS_FILE_EXTENT_PREALLOC); |
| 5675 | BUG_ON(ret); | 5827 | BUG_ON(ret); |
| 5676 | btrfs_drop_extent_cache(inode, cur_offset, | 5828 | btrfs_drop_extent_cache(inode, cur_offset, |
| 5677 | cur_offset + ins.offset -1, 0); | 5829 | cur_offset + ins.offset -1, 0); |
| 5830 | |||
| 5678 | num_bytes -= ins.offset; | 5831 | num_bytes -= ins.offset; |
| 5679 | cur_offset += ins.offset; | 5832 | cur_offset += ins.offset; |
| 5680 | alloc_hint = ins.objectid + ins.offset; | 5833 | alloc_hint = ins.objectid + ins.offset; |
| 5681 | btrfs_unreserve_metadata_space(root, 1); | 5834 | |
| 5682 | } | ||
| 5683 | out: | ||
| 5684 | if (cur_offset > start) { | ||
| 5685 | inode->i_ctime = CURRENT_TIME; | 5835 | inode->i_ctime = CURRENT_TIME; |
| 5686 | BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC; | 5836 | BTRFS_I(inode)->flags |= BTRFS_INODE_PREALLOC; |
| 5687 | if (!(mode & FALLOC_FL_KEEP_SIZE) && | 5837 | if (!(mode & FALLOC_FL_KEEP_SIZE) && |
| 5688 | cur_offset > i_size_read(inode)) | 5838 | cur_offset > inode->i_size) { |
| 5689 | btrfs_i_size_write(inode, cur_offset); | 5839 | i_size_write(inode, cur_offset); |
| 5840 | btrfs_ordered_update_i_size(inode, cur_offset, NULL); | ||
| 5841 | } | ||
| 5842 | |||
| 5690 | ret = btrfs_update_inode(trans, root, inode); | 5843 | ret = btrfs_update_inode(trans, root, inode); |
| 5691 | BUG_ON(ret); | 5844 | BUG_ON(ret); |
| 5845 | |||
| 5846 | btrfs_end_transaction(trans, root); | ||
| 5847 | btrfs_unreserve_metadata_space(root, 3); | ||
| 5692 | } | 5848 | } |
| 5849 | return ret; | ||
| 5693 | 5850 | ||
| 5851 | stop_trans: | ||
| 5852 | btrfs_end_transaction(trans, root); | ||
| 5694 | return ret; | 5853 | return ret; |
| 5854 | |||
| 5695 | } | 5855 | } |
| 5696 | 5856 | ||
| 5697 | static long btrfs_fallocate(struct inode *inode, int mode, | 5857 | static long btrfs_fallocate(struct inode *inode, int mode, |
| @@ -5705,8 +5865,6 @@ static long btrfs_fallocate(struct inode *inode, int mode, | |||
| 5705 | u64 locked_end; | 5865 | u64 locked_end; |
| 5706 | u64 mask = BTRFS_I(inode)->root->sectorsize - 1; | 5866 | u64 mask = BTRFS_I(inode)->root->sectorsize - 1; |
| 5707 | struct extent_map *em; | 5867 | struct extent_map *em; |
| 5708 | struct btrfs_trans_handle *trans; | ||
| 5709 | struct btrfs_root *root; | ||
| 5710 | int ret; | 5868 | int ret; |
| 5711 | 5869 | ||
| 5712 | alloc_start = offset & ~mask; | 5870 | alloc_start = offset & ~mask; |
| @@ -5725,9 +5883,7 @@ static long btrfs_fallocate(struct inode *inode, int mode, | |||
| 5725 | goto out; | 5883 | goto out; |
| 5726 | } | 5884 | } |
| 5727 | 5885 | ||
| 5728 | root = BTRFS_I(inode)->root; | 5886 | ret = btrfs_check_data_free_space(BTRFS_I(inode)->root, inode, |
| 5729 | |||
| 5730 | ret = btrfs_check_data_free_space(root, inode, | ||
| 5731 | alloc_end - alloc_start); | 5887 | alloc_end - alloc_start); |
| 5732 | if (ret) | 5888 | if (ret) |
| 5733 | goto out; | 5889 | goto out; |
| @@ -5736,12 +5892,6 @@ static long btrfs_fallocate(struct inode *inode, int mode, | |||
| 5736 | while (1) { | 5892 | while (1) { |
| 5737 | struct btrfs_ordered_extent *ordered; | 5893 | struct btrfs_ordered_extent *ordered; |
| 5738 | 5894 | ||
| 5739 | trans = btrfs_start_transaction(BTRFS_I(inode)->root, 1); | ||
| 5740 | if (!trans) { | ||
| 5741 | ret = -EIO; | ||
| 5742 | goto out_free; | ||
| 5743 | } | ||
| 5744 | |||
| 5745 | /* the extent lock is ordered inside the running | 5895 | /* the extent lock is ordered inside the running |
| 5746 | * transaction | 5896 | * transaction |
| 5747 | */ | 5897 | */ |
| @@ -5755,8 +5905,6 @@ static long btrfs_fallocate(struct inode *inode, int mode, | |||
| 5755 | btrfs_put_ordered_extent(ordered); | 5905 | btrfs_put_ordered_extent(ordered); |
| 5756 | unlock_extent(&BTRFS_I(inode)->io_tree, | 5906 | unlock_extent(&BTRFS_I(inode)->io_tree, |
| 5757 | alloc_start, locked_end, GFP_NOFS); | 5907 | alloc_start, locked_end, GFP_NOFS); |
| 5758 | btrfs_end_transaction(trans, BTRFS_I(inode)->root); | ||
| 5759 | |||
| 5760 | /* | 5908 | /* |
| 5761 | * we can't wait on the range with the transaction | 5909 | * we can't wait on the range with the transaction |
| 5762 | * running or with the extent lock held | 5910 | * running or with the extent lock held |
| @@ -5777,10 +5925,12 @@ static long btrfs_fallocate(struct inode *inode, int mode, | |||
| 5777 | BUG_ON(IS_ERR(em) || !em); | 5925 | BUG_ON(IS_ERR(em) || !em); |
| 5778 | last_byte = min(extent_map_end(em), alloc_end); | 5926 | last_byte = min(extent_map_end(em), alloc_end); |
| 5779 | last_byte = (last_byte + mask) & ~mask; | 5927 | last_byte = (last_byte + mask) & ~mask; |
| 5780 | if (em->block_start == EXTENT_MAP_HOLE) { | 5928 | if (em->block_start == EXTENT_MAP_HOLE || |
| 5781 | ret = prealloc_file_range(trans, inode, cur_offset, | 5929 | (cur_offset >= inode->i_size && |
| 5782 | last_byte, locked_end + 1, | 5930 | !test_bit(EXTENT_FLAG_PREALLOC, &em->flags))) { |
| 5783 | alloc_hint, mode); | 5931 | ret = prealloc_file_range(inode, |
| 5932 | cur_offset, last_byte, | ||
| 5933 | alloc_hint, mode); | ||
| 5784 | if (ret < 0) { | 5934 | if (ret < 0) { |
| 5785 | free_extent_map(em); | 5935 | free_extent_map(em); |
| 5786 | break; | 5936 | break; |
| @@ -5799,9 +5949,8 @@ static long btrfs_fallocate(struct inode *inode, int mode, | |||
| 5799 | unlock_extent(&BTRFS_I(inode)->io_tree, alloc_start, locked_end, | 5949 | unlock_extent(&BTRFS_I(inode)->io_tree, alloc_start, locked_end, |
| 5800 | GFP_NOFS); | 5950 | GFP_NOFS); |
| 5801 | 5951 | ||
| 5802 | btrfs_end_transaction(trans, BTRFS_I(inode)->root); | 5952 | btrfs_free_reserved_data_space(BTRFS_I(inode)->root, inode, |
| 5803 | out_free: | 5953 | alloc_end - alloc_start); |
| 5804 | btrfs_free_reserved_data_space(root, inode, alloc_end - alloc_start); | ||
| 5805 | out: | 5954 | out: |
| 5806 | mutex_unlock(&inode->i_mutex); | 5955 | mutex_unlock(&inode->i_mutex); |
| 5807 | return ret; | 5956 | return ret; |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index cdbb054102b9..645a17927a8f 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
| @@ -237,7 +237,6 @@ static noinline int create_subvol(struct btrfs_root *root, | |||
| 237 | u64 objectid; | 237 | u64 objectid; |
| 238 | u64 new_dirid = BTRFS_FIRST_FREE_OBJECTID; | 238 | u64 new_dirid = BTRFS_FIRST_FREE_OBJECTID; |
| 239 | u64 index = 0; | 239 | u64 index = 0; |
| 240 | unsigned long nr = 1; | ||
| 241 | 240 | ||
| 242 | /* | 241 | /* |
| 243 | * 1 - inode item | 242 | * 1 - inode item |
| @@ -290,7 +289,7 @@ static noinline int create_subvol(struct btrfs_root *root, | |||
| 290 | btrfs_set_root_generation(&root_item, trans->transid); | 289 | btrfs_set_root_generation(&root_item, trans->transid); |
| 291 | btrfs_set_root_level(&root_item, 0); | 290 | btrfs_set_root_level(&root_item, 0); |
| 292 | btrfs_set_root_refs(&root_item, 1); | 291 | btrfs_set_root_refs(&root_item, 1); |
| 293 | btrfs_set_root_used(&root_item, 0); | 292 | btrfs_set_root_used(&root_item, leaf->len); |
| 294 | btrfs_set_root_last_snapshot(&root_item, 0); | 293 | btrfs_set_root_last_snapshot(&root_item, 0); |
| 295 | 294 | ||
| 296 | memset(&root_item.drop_progress, 0, sizeof(root_item.drop_progress)); | 295 | memset(&root_item.drop_progress, 0, sizeof(root_item.drop_progress)); |
| @@ -342,24 +341,21 @@ static noinline int create_subvol(struct btrfs_root *root, | |||
| 342 | 341 | ||
| 343 | d_instantiate(dentry, btrfs_lookup_dentry(dir, dentry)); | 342 | d_instantiate(dentry, btrfs_lookup_dentry(dir, dentry)); |
| 344 | fail: | 343 | fail: |
| 345 | nr = trans->blocks_used; | ||
| 346 | err = btrfs_commit_transaction(trans, root); | 344 | err = btrfs_commit_transaction(trans, root); |
| 347 | if (err && !ret) | 345 | if (err && !ret) |
| 348 | ret = err; | 346 | ret = err; |
| 349 | 347 | ||
| 350 | btrfs_unreserve_metadata_space(root, 6); | 348 | btrfs_unreserve_metadata_space(root, 6); |
| 351 | btrfs_btree_balance_dirty(root, nr); | ||
| 352 | return ret; | 349 | return ret; |
| 353 | } | 350 | } |
| 354 | 351 | ||
| 355 | static int create_snapshot(struct btrfs_root *root, struct dentry *dentry, | 352 | static int create_snapshot(struct btrfs_root *root, struct dentry *dentry, |
| 356 | char *name, int namelen) | 353 | char *name, int namelen) |
| 357 | { | 354 | { |
| 355 | struct inode *inode; | ||
| 358 | struct btrfs_pending_snapshot *pending_snapshot; | 356 | struct btrfs_pending_snapshot *pending_snapshot; |
| 359 | struct btrfs_trans_handle *trans; | 357 | struct btrfs_trans_handle *trans; |
| 360 | int ret = 0; | 358 | int ret; |
| 361 | int err; | ||
| 362 | unsigned long nr = 0; | ||
| 363 | 359 | ||
| 364 | if (!root->ref_cows) | 360 | if (!root->ref_cows) |
| 365 | return -EINVAL; | 361 | return -EINVAL; |
| @@ -372,20 +368,20 @@ static int create_snapshot(struct btrfs_root *root, struct dentry *dentry, | |||
| 372 | */ | 368 | */ |
| 373 | ret = btrfs_reserve_metadata_space(root, 6); | 369 | ret = btrfs_reserve_metadata_space(root, 6); |
| 374 | if (ret) | 370 | if (ret) |
| 375 | goto fail_unlock; | 371 | goto fail; |
| 376 | 372 | ||
| 377 | pending_snapshot = kzalloc(sizeof(*pending_snapshot), GFP_NOFS); | 373 | pending_snapshot = kzalloc(sizeof(*pending_snapshot), GFP_NOFS); |
| 378 | if (!pending_snapshot) { | 374 | if (!pending_snapshot) { |
| 379 | ret = -ENOMEM; | 375 | ret = -ENOMEM; |
| 380 | btrfs_unreserve_metadata_space(root, 6); | 376 | btrfs_unreserve_metadata_space(root, 6); |
| 381 | goto fail_unlock; | 377 | goto fail; |
| 382 | } | 378 | } |
| 383 | pending_snapshot->name = kmalloc(namelen + 1, GFP_NOFS); | 379 | pending_snapshot->name = kmalloc(namelen + 1, GFP_NOFS); |
| 384 | if (!pending_snapshot->name) { | 380 | if (!pending_snapshot->name) { |
| 385 | ret = -ENOMEM; | 381 | ret = -ENOMEM; |
| 386 | kfree(pending_snapshot); | 382 | kfree(pending_snapshot); |
| 387 | btrfs_unreserve_metadata_space(root, 6); | 383 | btrfs_unreserve_metadata_space(root, 6); |
| 388 | goto fail_unlock; | 384 | goto fail; |
| 389 | } | 385 | } |
| 390 | memcpy(pending_snapshot->name, name, namelen); | 386 | memcpy(pending_snapshot->name, name, namelen); |
| 391 | pending_snapshot->name[namelen] = '\0'; | 387 | pending_snapshot->name[namelen] = '\0'; |
| @@ -395,10 +391,19 @@ static int create_snapshot(struct btrfs_root *root, struct dentry *dentry, | |||
| 395 | pending_snapshot->root = root; | 391 | pending_snapshot->root = root; |
| 396 | list_add(&pending_snapshot->list, | 392 | list_add(&pending_snapshot->list, |
| 397 | &trans->transaction->pending_snapshots); | 393 | &trans->transaction->pending_snapshots); |
| 398 | err = btrfs_commit_transaction(trans, root); | 394 | ret = btrfs_commit_transaction(trans, root); |
| 395 | BUG_ON(ret); | ||
| 396 | btrfs_unreserve_metadata_space(root, 6); | ||
| 399 | 397 | ||
| 400 | fail_unlock: | 398 | inode = btrfs_lookup_dentry(dentry->d_parent->d_inode, dentry); |
| 401 | btrfs_btree_balance_dirty(root, nr); | 399 | if (IS_ERR(inode)) { |
| 400 | ret = PTR_ERR(inode); | ||
| 401 | goto fail; | ||
| 402 | } | ||
| 403 | BUG_ON(!inode); | ||
| 404 | d_instantiate(dentry, inode); | ||
| 405 | ret = 0; | ||
| 406 | fail: | ||
| 402 | return ret; | 407 | return ret; |
| 403 | } | 408 | } |
| 404 | 409 | ||
| @@ -1027,8 +1032,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
| 1027 | BUG_ON(!trans); | 1032 | BUG_ON(!trans); |
| 1028 | 1033 | ||
| 1029 | /* punch hole in destination first */ | 1034 | /* punch hole in destination first */ |
| 1030 | btrfs_drop_extents(trans, root, inode, off, off + len, | 1035 | btrfs_drop_extents(trans, inode, off, off + len, &hint_byte, 1); |
| 1031 | off + len, 0, &hint_byte, 1); | ||
| 1032 | 1036 | ||
| 1033 | /* clone data */ | 1037 | /* clone data */ |
| 1034 | key.objectid = src->i_ino; | 1038 | key.objectid = src->i_ino; |
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index 5799bc46a309..b10a49d4bc6a 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c | |||
| @@ -291,16 +291,16 @@ int btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry) | |||
| 291 | 291 | ||
| 292 | /* | 292 | /* |
| 293 | * remove an ordered extent from the tree. No references are dropped | 293 | * remove an ordered extent from the tree. No references are dropped |
| 294 | * but, anyone waiting on this extent is woken up. | 294 | * and you must wake_up entry->wait. You must hold the tree mutex |
| 295 | * while you call this function. | ||
| 295 | */ | 296 | */ |
| 296 | int btrfs_remove_ordered_extent(struct inode *inode, | 297 | static int __btrfs_remove_ordered_extent(struct inode *inode, |
| 297 | struct btrfs_ordered_extent *entry) | 298 | struct btrfs_ordered_extent *entry) |
| 298 | { | 299 | { |
| 299 | struct btrfs_ordered_inode_tree *tree; | 300 | struct btrfs_ordered_inode_tree *tree; |
| 300 | struct rb_node *node; | 301 | struct rb_node *node; |
| 301 | 302 | ||
| 302 | tree = &BTRFS_I(inode)->ordered_tree; | 303 | tree = &BTRFS_I(inode)->ordered_tree; |
| 303 | mutex_lock(&tree->mutex); | ||
| 304 | node = &entry->rb_node; | 304 | node = &entry->rb_node; |
| 305 | rb_erase(node, &tree->tree); | 305 | rb_erase(node, &tree->tree); |
| 306 | tree->last = NULL; | 306 | tree->last = NULL; |
| @@ -326,16 +326,34 @@ int btrfs_remove_ordered_extent(struct inode *inode, | |||
| 326 | } | 326 | } |
| 327 | spin_unlock(&BTRFS_I(inode)->root->fs_info->ordered_extent_lock); | 327 | spin_unlock(&BTRFS_I(inode)->root->fs_info->ordered_extent_lock); |
| 328 | 328 | ||
| 329 | return 0; | ||
| 330 | } | ||
| 331 | |||
| 332 | /* | ||
| 333 | * remove an ordered extent from the tree. No references are dropped | ||
| 334 | * but any waiters are woken. | ||
| 335 | */ | ||
| 336 | int btrfs_remove_ordered_extent(struct inode *inode, | ||
| 337 | struct btrfs_ordered_extent *entry) | ||
| 338 | { | ||
| 339 | struct btrfs_ordered_inode_tree *tree; | ||
| 340 | int ret; | ||
| 341 | |||
| 342 | tree = &BTRFS_I(inode)->ordered_tree; | ||
| 343 | mutex_lock(&tree->mutex); | ||
| 344 | ret = __btrfs_remove_ordered_extent(inode, entry); | ||
| 329 | mutex_unlock(&tree->mutex); | 345 | mutex_unlock(&tree->mutex); |
| 330 | wake_up(&entry->wait); | 346 | wake_up(&entry->wait); |
| 331 | return 0; | 347 | |
| 348 | return ret; | ||
| 332 | } | 349 | } |
| 333 | 350 | ||
| 334 | /* | 351 | /* |
| 335 | * wait for all the ordered extents in a root. This is done when balancing | 352 | * wait for all the ordered extents in a root. This is done when balancing |
| 336 | * space between drives. | 353 | * space between drives. |
| 337 | */ | 354 | */ |
| 338 | int btrfs_wait_ordered_extents(struct btrfs_root *root, int nocow_only) | 355 | int btrfs_wait_ordered_extents(struct btrfs_root *root, |
| 356 | int nocow_only, int delay_iput) | ||
| 339 | { | 357 | { |
| 340 | struct list_head splice; | 358 | struct list_head splice; |
| 341 | struct list_head *cur; | 359 | struct list_head *cur; |
| @@ -372,7 +390,10 @@ int btrfs_wait_ordered_extents(struct btrfs_root *root, int nocow_only) | |||
| 372 | if (inode) { | 390 | if (inode) { |
| 373 | btrfs_start_ordered_extent(inode, ordered, 1); | 391 | btrfs_start_ordered_extent(inode, ordered, 1); |
| 374 | btrfs_put_ordered_extent(ordered); | 392 | btrfs_put_ordered_extent(ordered); |
| 375 | iput(inode); | 393 | if (delay_iput) |
| 394 | btrfs_add_delayed_iput(inode); | ||
| 395 | else | ||
| 396 | iput(inode); | ||
| 376 | } else { | 397 | } else { |
| 377 | btrfs_put_ordered_extent(ordered); | 398 | btrfs_put_ordered_extent(ordered); |
| 378 | } | 399 | } |
| @@ -430,7 +451,7 @@ again: | |||
| 430 | btrfs_wait_ordered_range(inode, 0, (u64)-1); | 451 | btrfs_wait_ordered_range(inode, 0, (u64)-1); |
| 431 | else | 452 | else |
| 432 | filemap_flush(inode->i_mapping); | 453 | filemap_flush(inode->i_mapping); |
| 433 | iput(inode); | 454 | btrfs_add_delayed_iput(inode); |
| 434 | } | 455 | } |
| 435 | 456 | ||
| 436 | cond_resched(); | 457 | cond_resched(); |
| @@ -589,7 +610,7 @@ out: | |||
| 589 | * After an extent is done, call this to conditionally update the on disk | 610 | * After an extent is done, call this to conditionally update the on disk |
| 590 | * i_size. i_size is updated to cover any fully written part of the file. | 611 | * i_size. i_size is updated to cover any fully written part of the file. |
| 591 | */ | 612 | */ |
| 592 | int btrfs_ordered_update_i_size(struct inode *inode, | 613 | int btrfs_ordered_update_i_size(struct inode *inode, u64 offset, |
| 593 | struct btrfs_ordered_extent *ordered) | 614 | struct btrfs_ordered_extent *ordered) |
| 594 | { | 615 | { |
| 595 | struct btrfs_ordered_inode_tree *tree = &BTRFS_I(inode)->ordered_tree; | 616 | struct btrfs_ordered_inode_tree *tree = &BTRFS_I(inode)->ordered_tree; |
| @@ -597,18 +618,30 @@ int btrfs_ordered_update_i_size(struct inode *inode, | |||
| 597 | u64 disk_i_size; | 618 | u64 disk_i_size; |
| 598 | u64 new_i_size; | 619 | u64 new_i_size; |
| 599 | u64 i_size_test; | 620 | u64 i_size_test; |
| 621 | u64 i_size = i_size_read(inode); | ||
| 600 | struct rb_node *node; | 622 | struct rb_node *node; |
| 623 | struct rb_node *prev = NULL; | ||
| 601 | struct btrfs_ordered_extent *test; | 624 | struct btrfs_ordered_extent *test; |
| 625 | int ret = 1; | ||
| 626 | |||
| 627 | if (ordered) | ||
| 628 | offset = entry_end(ordered); | ||
| 602 | 629 | ||
| 603 | mutex_lock(&tree->mutex); | 630 | mutex_lock(&tree->mutex); |
| 604 | disk_i_size = BTRFS_I(inode)->disk_i_size; | 631 | disk_i_size = BTRFS_I(inode)->disk_i_size; |
| 605 | 632 | ||
| 633 | /* truncate file */ | ||
| 634 | if (disk_i_size > i_size) { | ||
| 635 | BTRFS_I(inode)->disk_i_size = i_size; | ||
| 636 | ret = 0; | ||
| 637 | goto out; | ||
| 638 | } | ||
| 639 | |||
| 606 | /* | 640 | /* |
| 607 | * if the disk i_size is already at the inode->i_size, or | 641 | * if the disk i_size is already at the inode->i_size, or |
| 608 | * this ordered extent is inside the disk i_size, we're done | 642 | * this ordered extent is inside the disk i_size, we're done |
| 609 | */ | 643 | */ |
| 610 | if (disk_i_size >= inode->i_size || | 644 | if (disk_i_size == i_size || offset <= disk_i_size) { |
| 611 | ordered->file_offset + ordered->len <= disk_i_size) { | ||
| 612 | goto out; | 645 | goto out; |
| 613 | } | 646 | } |
| 614 | 647 | ||
| @@ -616,8 +649,7 @@ int btrfs_ordered_update_i_size(struct inode *inode, | |||
| 616 | * we can't update the disk_isize if there are delalloc bytes | 649 | * we can't update the disk_isize if there are delalloc bytes |
| 617 | * between disk_i_size and this ordered extent | 650 | * between disk_i_size and this ordered extent |
| 618 | */ | 651 | */ |
| 619 | if (test_range_bit(io_tree, disk_i_size, | 652 | if (test_range_bit(io_tree, disk_i_size, offset - 1, |
| 620 | ordered->file_offset + ordered->len - 1, | ||
| 621 | EXTENT_DELALLOC, 0, NULL)) { | 653 | EXTENT_DELALLOC, 0, NULL)) { |
| 622 | goto out; | 654 | goto out; |
| 623 | } | 655 | } |
| @@ -626,20 +658,32 @@ int btrfs_ordered_update_i_size(struct inode *inode, | |||
| 626 | * if we find an ordered extent then we can't update disk i_size | 658 | * if we find an ordered extent then we can't update disk i_size |
| 627 | * yet | 659 | * yet |
| 628 | */ | 660 | */ |
| 629 | node = &ordered->rb_node; | 661 | if (ordered) { |
| 630 | while (1) { | 662 | node = rb_prev(&ordered->rb_node); |
| 631 | node = rb_prev(node); | 663 | } else { |
| 632 | if (!node) | 664 | prev = tree_search(tree, offset); |
| 633 | break; | 665 | /* |
| 666 | * we insert file extents without involving ordered struct, | ||
| 667 | * so there should be no ordered struct cover this offset | ||
| 668 | */ | ||
| 669 | if (prev) { | ||
| 670 | test = rb_entry(prev, struct btrfs_ordered_extent, | ||
| 671 | rb_node); | ||
| 672 | BUG_ON(offset_in_entry(test, offset)); | ||
| 673 | } | ||
| 674 | node = prev; | ||
| 675 | } | ||
| 676 | while (node) { | ||
| 634 | test = rb_entry(node, struct btrfs_ordered_extent, rb_node); | 677 | test = rb_entry(node, struct btrfs_ordered_extent, rb_node); |
| 635 | if (test->file_offset + test->len <= disk_i_size) | 678 | if (test->file_offset + test->len <= disk_i_size) |
| 636 | break; | 679 | break; |
| 637 | if (test->file_offset >= inode->i_size) | 680 | if (test->file_offset >= i_size) |
| 638 | break; | 681 | break; |
| 639 | if (test->file_offset >= disk_i_size) | 682 | if (test->file_offset >= disk_i_size) |
| 640 | goto out; | 683 | goto out; |
| 684 | node = rb_prev(node); | ||
| 641 | } | 685 | } |
| 642 | new_i_size = min_t(u64, entry_end(ordered), i_size_read(inode)); | 686 | new_i_size = min_t(u64, offset, i_size); |
| 643 | 687 | ||
| 644 | /* | 688 | /* |
| 645 | * at this point, we know we can safely update i_size to at least | 689 | * at this point, we know we can safely update i_size to at least |
| @@ -647,7 +691,14 @@ int btrfs_ordered_update_i_size(struct inode *inode, | |||
| 647 | * walk forward and see if ios from higher up in the file have | 691 | * walk forward and see if ios from higher up in the file have |
| 648 | * finished. | 692 | * finished. |
| 649 | */ | 693 | */ |
| 650 | node = rb_next(&ordered->rb_node); | 694 | if (ordered) { |
| 695 | node = rb_next(&ordered->rb_node); | ||
| 696 | } else { | ||
| 697 | if (prev) | ||
| 698 | node = rb_next(prev); | ||
| 699 | else | ||
| 700 | node = rb_first(&tree->tree); | ||
| 701 | } | ||
| 651 | i_size_test = 0; | 702 | i_size_test = 0; |
| 652 | if (node) { | 703 | if (node) { |
| 653 | /* | 704 | /* |
| @@ -655,10 +706,10 @@ int btrfs_ordered_update_i_size(struct inode *inode, | |||
| 655 | * between our ordered extent and the next one. | 706 | * between our ordered extent and the next one. |
| 656 | */ | 707 | */ |
| 657 | test = rb_entry(node, struct btrfs_ordered_extent, rb_node); | 708 | test = rb_entry(node, struct btrfs_ordered_extent, rb_node); |
| 658 | if (test->file_offset > entry_end(ordered)) | 709 | if (test->file_offset > offset) |
| 659 | i_size_test = test->file_offset; | 710 | i_size_test = test->file_offset; |
| 660 | } else { | 711 | } else { |
| 661 | i_size_test = i_size_read(inode); | 712 | i_size_test = i_size; |
| 662 | } | 713 | } |
| 663 | 714 | ||
| 664 | /* | 715 | /* |
| @@ -667,15 +718,25 @@ int btrfs_ordered_update_i_size(struct inode *inode, | |||
| 667 | * are no delalloc bytes in this area, it is safe to update | 718 | * are no delalloc bytes in this area, it is safe to update |
| 668 | * disk_i_size to the end of the region. | 719 | * disk_i_size to the end of the region. |
| 669 | */ | 720 | */ |
| 670 | if (i_size_test > entry_end(ordered) && | 721 | if (i_size_test > offset && |
| 671 | !test_range_bit(io_tree, entry_end(ordered), i_size_test - 1, | 722 | !test_range_bit(io_tree, offset, i_size_test - 1, |
| 672 | EXTENT_DELALLOC, 0, NULL)) { | 723 | EXTENT_DELALLOC, 0, NULL)) { |
| 673 | new_i_size = min_t(u64, i_size_test, i_size_read(inode)); | 724 | new_i_size = min_t(u64, i_size_test, i_size); |
| 674 | } | 725 | } |
| 675 | BTRFS_I(inode)->disk_i_size = new_i_size; | 726 | BTRFS_I(inode)->disk_i_size = new_i_size; |
| 727 | ret = 0; | ||
| 676 | out: | 728 | out: |
| 729 | /* | ||
| 730 | * we need to remove the ordered extent with the tree lock held | ||
| 731 | * so that other people calling this function don't find our fully | ||
| 732 | * processed ordered entry and skip updating the i_size | ||
| 733 | */ | ||
| 734 | if (ordered) | ||
| 735 | __btrfs_remove_ordered_extent(inode, ordered); | ||
| 677 | mutex_unlock(&tree->mutex); | 736 | mutex_unlock(&tree->mutex); |
| 678 | return 0; | 737 | if (ordered) |
| 738 | wake_up(&ordered->wait); | ||
| 739 | return ret; | ||
| 679 | } | 740 | } |
| 680 | 741 | ||
| 681 | /* | 742 | /* |
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h index f82e87488ca8..1fe1282ef47c 100644 --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h | |||
| @@ -150,12 +150,13 @@ void btrfs_start_ordered_extent(struct inode *inode, | |||
| 150 | int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len); | 150 | int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len); |
| 151 | struct btrfs_ordered_extent * | 151 | struct btrfs_ordered_extent * |
| 152 | btrfs_lookup_first_ordered_extent(struct inode * inode, u64 file_offset); | 152 | btrfs_lookup_first_ordered_extent(struct inode * inode, u64 file_offset); |
| 153 | int btrfs_ordered_update_i_size(struct inode *inode, | 153 | int btrfs_ordered_update_i_size(struct inode *inode, u64 offset, |
| 154 | struct btrfs_ordered_extent *ordered); | 154 | struct btrfs_ordered_extent *ordered); |
| 155 | int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr, u32 *sum); | 155 | int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr, u32 *sum); |
| 156 | int btrfs_wait_ordered_extents(struct btrfs_root *root, int nocow_only); | ||
| 157 | int btrfs_run_ordered_operations(struct btrfs_root *root, int wait); | 156 | int btrfs_run_ordered_operations(struct btrfs_root *root, int wait); |
| 158 | int btrfs_add_ordered_operation(struct btrfs_trans_handle *trans, | 157 | int btrfs_add_ordered_operation(struct btrfs_trans_handle *trans, |
| 159 | struct btrfs_root *root, | 158 | struct btrfs_root *root, |
| 160 | struct inode *inode); | 159 | struct inode *inode); |
| 160 | int btrfs_wait_ordered_extents(struct btrfs_root *root, | ||
| 161 | int nocow_only, int delay_iput); | ||
| 161 | #endif | 162 | #endif |
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index cfcc93c93a7b..a9728680eca8 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c | |||
| @@ -1561,6 +1561,20 @@ static int invalidate_extent_cache(struct btrfs_root *root, | |||
| 1561 | return 0; | 1561 | return 0; |
| 1562 | } | 1562 | } |
| 1563 | 1563 | ||
| 1564 | static void put_inodes(struct list_head *list) | ||
| 1565 | { | ||
| 1566 | struct inodevec *ivec; | ||
| 1567 | while (!list_empty(list)) { | ||
| 1568 | ivec = list_entry(list->next, struct inodevec, list); | ||
| 1569 | list_del(&ivec->list); | ||
| 1570 | while (ivec->nr > 0) { | ||
| 1571 | ivec->nr--; | ||
| 1572 | iput(ivec->inode[ivec->nr]); | ||
| 1573 | } | ||
| 1574 | kfree(ivec); | ||
| 1575 | } | ||
| 1576 | } | ||
| 1577 | |||
| 1564 | static int find_next_key(struct btrfs_path *path, int level, | 1578 | static int find_next_key(struct btrfs_path *path, int level, |
| 1565 | struct btrfs_key *key) | 1579 | struct btrfs_key *key) |
| 1566 | 1580 | ||
| @@ -1723,6 +1737,11 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc, | |||
| 1723 | 1737 | ||
| 1724 | btrfs_btree_balance_dirty(root, nr); | 1738 | btrfs_btree_balance_dirty(root, nr); |
| 1725 | 1739 | ||
| 1740 | /* | ||
| 1741 | * put inodes outside transaction, otherwise we may deadlock. | ||
| 1742 | */ | ||
| 1743 | put_inodes(&inode_list); | ||
| 1744 | |||
| 1726 | if (replaced && rc->stage == UPDATE_DATA_PTRS) | 1745 | if (replaced && rc->stage == UPDATE_DATA_PTRS) |
| 1727 | invalidate_extent_cache(root, &key, &next_key); | 1746 | invalidate_extent_cache(root, &key, &next_key); |
| 1728 | } | 1747 | } |
| @@ -1752,19 +1771,7 @@ out: | |||
| 1752 | 1771 | ||
| 1753 | btrfs_btree_balance_dirty(root, nr); | 1772 | btrfs_btree_balance_dirty(root, nr); |
| 1754 | 1773 | ||
| 1755 | /* | 1774 | put_inodes(&inode_list); |
| 1756 | * put inodes while we aren't holding the tree locks | ||
| 1757 | */ | ||
| 1758 | while (!list_empty(&inode_list)) { | ||
| 1759 | struct inodevec *ivec; | ||
| 1760 | ivec = list_entry(inode_list.next, struct inodevec, list); | ||
| 1761 | list_del(&ivec->list); | ||
| 1762 | while (ivec->nr > 0) { | ||
| 1763 | ivec->nr--; | ||
| 1764 | iput(ivec->inode[ivec->nr]); | ||
| 1765 | } | ||
| 1766 | kfree(ivec); | ||
| 1767 | } | ||
| 1768 | 1775 | ||
| 1769 | if (replaced && rc->stage == UPDATE_DATA_PTRS) | 1776 | if (replaced && rc->stage == UPDATE_DATA_PTRS) |
| 1770 | invalidate_extent_cache(root, &key, &next_key); | 1777 | invalidate_extent_cache(root, &key, &next_key); |
| @@ -3534,8 +3541,8 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start) | |||
| 3534 | (unsigned long long)rc->block_group->key.objectid, | 3541 | (unsigned long long)rc->block_group->key.objectid, |
| 3535 | (unsigned long long)rc->block_group->flags); | 3542 | (unsigned long long)rc->block_group->flags); |
| 3536 | 3543 | ||
| 3537 | btrfs_start_delalloc_inodes(fs_info->tree_root); | 3544 | btrfs_start_delalloc_inodes(fs_info->tree_root, 0); |
| 3538 | btrfs_wait_ordered_extents(fs_info->tree_root, 0); | 3545 | btrfs_wait_ordered_extents(fs_info->tree_root, 0, 0); |
| 3539 | 3546 | ||
| 3540 | while (1) { | 3547 | while (1) { |
| 3541 | rc->extents_found = 0; | 3548 | rc->extents_found = 0; |
| @@ -3755,6 +3762,7 @@ out: | |||
| 3755 | BTRFS_DATA_RELOC_TREE_OBJECTID); | 3762 | BTRFS_DATA_RELOC_TREE_OBJECTID); |
| 3756 | if (IS_ERR(fs_root)) | 3763 | if (IS_ERR(fs_root)) |
| 3757 | err = PTR_ERR(fs_root); | 3764 | err = PTR_ERR(fs_root); |
| 3765 | btrfs_orphan_cleanup(fs_root); | ||
| 3758 | } | 3766 | } |
| 3759 | return err; | 3767 | return err; |
| 3760 | } | 3768 | } |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 752a5463bf53..3f9b45704fcd 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
| @@ -128,6 +128,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
| 128 | substring_t args[MAX_OPT_ARGS]; | 128 | substring_t args[MAX_OPT_ARGS]; |
| 129 | char *p, *num; | 129 | char *p, *num; |
| 130 | int intarg; | 130 | int intarg; |
| 131 | int ret = 0; | ||
| 131 | 132 | ||
| 132 | if (!options) | 133 | if (!options) |
| 133 | return 0; | 134 | return 0; |
| @@ -262,12 +263,18 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
| 262 | case Opt_discard: | 263 | case Opt_discard: |
| 263 | btrfs_set_opt(info->mount_opt, DISCARD); | 264 | btrfs_set_opt(info->mount_opt, DISCARD); |
| 264 | break; | 265 | break; |
| 266 | case Opt_err: | ||
| 267 | printk(KERN_INFO "btrfs: unrecognized mount option " | ||
| 268 | "'%s'\n", p); | ||
| 269 | ret = -EINVAL; | ||
| 270 | goto out; | ||
| 265 | default: | 271 | default: |
| 266 | break; | 272 | break; |
| 267 | } | 273 | } |
| 268 | } | 274 | } |
| 275 | out: | ||
| 269 | kfree(options); | 276 | kfree(options); |
| 270 | return 0; | 277 | return ret; |
| 271 | } | 278 | } |
| 272 | 279 | ||
| 273 | /* | 280 | /* |
| @@ -405,8 +412,8 @@ int btrfs_sync_fs(struct super_block *sb, int wait) | |||
| 405 | return 0; | 412 | return 0; |
| 406 | } | 413 | } |
| 407 | 414 | ||
| 408 | btrfs_start_delalloc_inodes(root); | 415 | btrfs_start_delalloc_inodes(root, 0); |
| 409 | btrfs_wait_ordered_extents(root, 0); | 416 | btrfs_wait_ordered_extents(root, 0, 0); |
| 410 | 417 | ||
| 411 | trans = btrfs_start_transaction(root, 1); | 418 | trans = btrfs_start_transaction(root, 1); |
| 412 | ret = btrfs_commit_transaction(trans, root); | 419 | ret = btrfs_commit_transaction(trans, root); |
| @@ -450,6 +457,8 @@ static int btrfs_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
| 450 | seq_puts(seq, ",notreelog"); | 457 | seq_puts(seq, ",notreelog"); |
| 451 | if (btrfs_test_opt(root, FLUSHONCOMMIT)) | 458 | if (btrfs_test_opt(root, FLUSHONCOMMIT)) |
| 452 | seq_puts(seq, ",flushoncommit"); | 459 | seq_puts(seq, ",flushoncommit"); |
| 460 | if (btrfs_test_opt(root, DISCARD)) | ||
| 461 | seq_puts(seq, ",discard"); | ||
| 453 | if (!(root->fs_info->sb->s_flags & MS_POSIXACL)) | 462 | if (!(root->fs_info->sb->s_flags & MS_POSIXACL)) |
| 454 | seq_puts(seq, ",noacl"); | 463 | seq_puts(seq, ",noacl"); |
| 455 | return 0; | 464 | return 0; |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index c207e8c32c9b..b2acc79f1b34 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
| @@ -333,6 +333,9 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, | |||
| 333 | memset(trans, 0, sizeof(*trans)); | 333 | memset(trans, 0, sizeof(*trans)); |
| 334 | kmem_cache_free(btrfs_trans_handle_cachep, trans); | 334 | kmem_cache_free(btrfs_trans_handle_cachep, trans); |
| 335 | 335 | ||
| 336 | if (throttle) | ||
| 337 | btrfs_run_delayed_iputs(root); | ||
| 338 | |||
| 336 | return 0; | 339 | return 0; |
| 337 | } | 340 | } |
| 338 | 341 | ||
| @@ -354,7 +357,7 @@ int btrfs_end_transaction_throttle(struct btrfs_trans_handle *trans, | |||
| 354 | * those extents are sent to disk but does not wait on them | 357 | * those extents are sent to disk but does not wait on them |
| 355 | */ | 358 | */ |
| 356 | int btrfs_write_marked_extents(struct btrfs_root *root, | 359 | int btrfs_write_marked_extents(struct btrfs_root *root, |
| 357 | struct extent_io_tree *dirty_pages) | 360 | struct extent_io_tree *dirty_pages, int mark) |
| 358 | { | 361 | { |
| 359 | int ret; | 362 | int ret; |
| 360 | int err = 0; | 363 | int err = 0; |
| @@ -367,7 +370,7 @@ int btrfs_write_marked_extents(struct btrfs_root *root, | |||
| 367 | 370 | ||
| 368 | while (1) { | 371 | while (1) { |
| 369 | ret = find_first_extent_bit(dirty_pages, start, &start, &end, | 372 | ret = find_first_extent_bit(dirty_pages, start, &start, &end, |
| 370 | EXTENT_DIRTY); | 373 | mark); |
| 371 | if (ret) | 374 | if (ret) |
| 372 | break; | 375 | break; |
| 373 | while (start <= end) { | 376 | while (start <= end) { |
| @@ -413,7 +416,7 @@ int btrfs_write_marked_extents(struct btrfs_root *root, | |||
| 413 | * on all the pages and clear them from the dirty pages state tree | 416 | * on all the pages and clear them from the dirty pages state tree |
| 414 | */ | 417 | */ |
| 415 | int btrfs_wait_marked_extents(struct btrfs_root *root, | 418 | int btrfs_wait_marked_extents(struct btrfs_root *root, |
| 416 | struct extent_io_tree *dirty_pages) | 419 | struct extent_io_tree *dirty_pages, int mark) |
| 417 | { | 420 | { |
| 418 | int ret; | 421 | int ret; |
| 419 | int err = 0; | 422 | int err = 0; |
| @@ -425,12 +428,12 @@ int btrfs_wait_marked_extents(struct btrfs_root *root, | |||
| 425 | unsigned long index; | 428 | unsigned long index; |
| 426 | 429 | ||
| 427 | while (1) { | 430 | while (1) { |
| 428 | ret = find_first_extent_bit(dirty_pages, 0, &start, &end, | 431 | ret = find_first_extent_bit(dirty_pages, start, &start, &end, |
| 429 | EXTENT_DIRTY); | 432 | mark); |
| 430 | if (ret) | 433 | if (ret) |
| 431 | break; | 434 | break; |
| 432 | 435 | ||
| 433 | clear_extent_dirty(dirty_pages, start, end, GFP_NOFS); | 436 | clear_extent_bits(dirty_pages, start, end, mark, GFP_NOFS); |
| 434 | while (start <= end) { | 437 | while (start <= end) { |
| 435 | index = start >> PAGE_CACHE_SHIFT; | 438 | index = start >> PAGE_CACHE_SHIFT; |
| 436 | start = (u64)(index + 1) << PAGE_CACHE_SHIFT; | 439 | start = (u64)(index + 1) << PAGE_CACHE_SHIFT; |
| @@ -460,13 +463,13 @@ int btrfs_wait_marked_extents(struct btrfs_root *root, | |||
| 460 | * those extents are on disk for transaction or log commit | 463 | * those extents are on disk for transaction or log commit |
| 461 | */ | 464 | */ |
| 462 | int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, | 465 | int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, |
| 463 | struct extent_io_tree *dirty_pages) | 466 | struct extent_io_tree *dirty_pages, int mark) |
| 464 | { | 467 | { |
| 465 | int ret; | 468 | int ret; |
| 466 | int ret2; | 469 | int ret2; |
| 467 | 470 | ||
| 468 | ret = btrfs_write_marked_extents(root, dirty_pages); | 471 | ret = btrfs_write_marked_extents(root, dirty_pages, mark); |
| 469 | ret2 = btrfs_wait_marked_extents(root, dirty_pages); | 472 | ret2 = btrfs_wait_marked_extents(root, dirty_pages, mark); |
| 470 | return ret || ret2; | 473 | return ret || ret2; |
| 471 | } | 474 | } |
| 472 | 475 | ||
| @@ -479,7 +482,8 @@ int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans, | |||
| 479 | return filemap_write_and_wait(btree_inode->i_mapping); | 482 | return filemap_write_and_wait(btree_inode->i_mapping); |
| 480 | } | 483 | } |
| 481 | return btrfs_write_and_wait_marked_extents(root, | 484 | return btrfs_write_and_wait_marked_extents(root, |
| 482 | &trans->transaction->dirty_pages); | 485 | &trans->transaction->dirty_pages, |
| 486 | EXTENT_DIRTY); | ||
| 483 | } | 487 | } |
| 484 | 488 | ||
| 485 | /* | 489 | /* |
| @@ -497,13 +501,16 @@ static int update_cowonly_root(struct btrfs_trans_handle *trans, | |||
| 497 | { | 501 | { |
| 498 | int ret; | 502 | int ret; |
| 499 | u64 old_root_bytenr; | 503 | u64 old_root_bytenr; |
| 504 | u64 old_root_used; | ||
| 500 | struct btrfs_root *tree_root = root->fs_info->tree_root; | 505 | struct btrfs_root *tree_root = root->fs_info->tree_root; |
| 501 | 506 | ||
| 507 | old_root_used = btrfs_root_used(&root->root_item); | ||
| 502 | btrfs_write_dirty_block_groups(trans, root); | 508 | btrfs_write_dirty_block_groups(trans, root); |
| 503 | 509 | ||
| 504 | while (1) { | 510 | while (1) { |
| 505 | old_root_bytenr = btrfs_root_bytenr(&root->root_item); | 511 | old_root_bytenr = btrfs_root_bytenr(&root->root_item); |
| 506 | if (old_root_bytenr == root->node->start) | 512 | if (old_root_bytenr == root->node->start && |
| 513 | old_root_used == btrfs_root_used(&root->root_item)) | ||
| 507 | break; | 514 | break; |
| 508 | 515 | ||
| 509 | btrfs_set_root_node(&root->root_item, root->node); | 516 | btrfs_set_root_node(&root->root_item, root->node); |
| @@ -512,6 +519,7 @@ static int update_cowonly_root(struct btrfs_trans_handle *trans, | |||
| 512 | &root->root_item); | 519 | &root->root_item); |
| 513 | BUG_ON(ret); | 520 | BUG_ON(ret); |
| 514 | 521 | ||
| 522 | old_root_used = btrfs_root_used(&root->root_item); | ||
| 515 | ret = btrfs_write_dirty_block_groups(trans, root); | 523 | ret = btrfs_write_dirty_block_groups(trans, root); |
| 516 | BUG_ON(ret); | 524 | BUG_ON(ret); |
| 517 | } | 525 | } |
| @@ -795,7 +803,6 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, | |||
| 795 | memcpy(&pending->root_key, &key, sizeof(key)); | 803 | memcpy(&pending->root_key, &key, sizeof(key)); |
| 796 | fail: | 804 | fail: |
| 797 | kfree(new_root_item); | 805 | kfree(new_root_item); |
| 798 | btrfs_unreserve_metadata_space(root, 6); | ||
| 799 | return ret; | 806 | return ret; |
| 800 | } | 807 | } |
| 801 | 808 | ||
| @@ -807,7 +814,6 @@ static noinline int finish_pending_snapshot(struct btrfs_fs_info *fs_info, | |||
| 807 | u64 index = 0; | 814 | u64 index = 0; |
| 808 | struct btrfs_trans_handle *trans; | 815 | struct btrfs_trans_handle *trans; |
| 809 | struct inode *parent_inode; | 816 | struct inode *parent_inode; |
| 810 | struct inode *inode; | ||
| 811 | struct btrfs_root *parent_root; | 817 | struct btrfs_root *parent_root; |
| 812 | 818 | ||
| 813 | parent_inode = pending->dentry->d_parent->d_inode; | 819 | parent_inode = pending->dentry->d_parent->d_inode; |
| @@ -839,8 +845,6 @@ static noinline int finish_pending_snapshot(struct btrfs_fs_info *fs_info, | |||
| 839 | 845 | ||
| 840 | BUG_ON(ret); | 846 | BUG_ON(ret); |
| 841 | 847 | ||
| 842 | inode = btrfs_lookup_dentry(parent_inode, pending->dentry); | ||
| 843 | d_instantiate(pending->dentry, inode); | ||
| 844 | fail: | 848 | fail: |
| 845 | btrfs_end_transaction(trans, fs_info->fs_root); | 849 | btrfs_end_transaction(trans, fs_info->fs_root); |
| 846 | return ret; | 850 | return ret; |
| @@ -994,11 +998,11 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
| 994 | mutex_unlock(&root->fs_info->trans_mutex); | 998 | mutex_unlock(&root->fs_info->trans_mutex); |
| 995 | 999 | ||
| 996 | if (flush_on_commit) { | 1000 | if (flush_on_commit) { |
| 997 | btrfs_start_delalloc_inodes(root); | 1001 | btrfs_start_delalloc_inodes(root, 1); |
| 998 | ret = btrfs_wait_ordered_extents(root, 0); | 1002 | ret = btrfs_wait_ordered_extents(root, 0, 1); |
| 999 | BUG_ON(ret); | 1003 | BUG_ON(ret); |
| 1000 | } else if (snap_pending) { | 1004 | } else if (snap_pending) { |
| 1001 | ret = btrfs_wait_ordered_extents(root, 1); | 1005 | ret = btrfs_wait_ordered_extents(root, 0, 1); |
| 1002 | BUG_ON(ret); | 1006 | BUG_ON(ret); |
| 1003 | } | 1007 | } |
| 1004 | 1008 | ||
| @@ -1116,6 +1120,10 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
| 1116 | current->journal_info = NULL; | 1120 | current->journal_info = NULL; |
| 1117 | 1121 | ||
| 1118 | kmem_cache_free(btrfs_trans_handle_cachep, trans); | 1122 | kmem_cache_free(btrfs_trans_handle_cachep, trans); |
| 1123 | |||
| 1124 | if (current != root->fs_info->transaction_kthread) | ||
| 1125 | btrfs_run_delayed_iputs(root); | ||
| 1126 | |||
| 1119 | return ret; | 1127 | return ret; |
| 1120 | } | 1128 | } |
| 1121 | 1129 | ||
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index d4e3e7a6938c..93c7ccb33118 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h | |||
| @@ -107,10 +107,10 @@ void btrfs_throttle(struct btrfs_root *root); | |||
| 107 | int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans, | 107 | int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans, |
| 108 | struct btrfs_root *root); | 108 | struct btrfs_root *root); |
| 109 | int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, | 109 | int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, |
| 110 | struct extent_io_tree *dirty_pages); | 110 | struct extent_io_tree *dirty_pages, int mark); |
| 111 | int btrfs_write_marked_extents(struct btrfs_root *root, | 111 | int btrfs_write_marked_extents(struct btrfs_root *root, |
| 112 | struct extent_io_tree *dirty_pages); | 112 | struct extent_io_tree *dirty_pages, int mark); |
| 113 | int btrfs_wait_marked_extents(struct btrfs_root *root, | 113 | int btrfs_wait_marked_extents(struct btrfs_root *root, |
| 114 | struct extent_io_tree *dirty_pages); | 114 | struct extent_io_tree *dirty_pages, int mark); |
| 115 | int btrfs_transaction_in_commit(struct btrfs_fs_info *info); | 115 | int btrfs_transaction_in_commit(struct btrfs_fs_info *info); |
| 116 | #endif | 116 | #endif |
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 741666a7676a..4a9434b622ec 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
| @@ -542,8 +542,8 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans, | |||
| 542 | 542 | ||
| 543 | saved_nbytes = inode_get_bytes(inode); | 543 | saved_nbytes = inode_get_bytes(inode); |
| 544 | /* drop any overlapping extents */ | 544 | /* drop any overlapping extents */ |
| 545 | ret = btrfs_drop_extents(trans, root, inode, | 545 | ret = btrfs_drop_extents(trans, inode, start, extent_end, |
| 546 | start, extent_end, extent_end, start, &alloc_hint, 1); | 546 | &alloc_hint, 1); |
| 547 | BUG_ON(ret); | 547 | BUG_ON(ret); |
| 548 | 548 | ||
| 549 | if (found_type == BTRFS_FILE_EXTENT_REG || | 549 | if (found_type == BTRFS_FILE_EXTENT_REG || |
| @@ -930,6 +930,17 @@ out_nowrite: | |||
| 930 | return 0; | 930 | return 0; |
| 931 | } | 931 | } |
| 932 | 932 | ||
| 933 | static int insert_orphan_item(struct btrfs_trans_handle *trans, | ||
| 934 | struct btrfs_root *root, u64 offset) | ||
| 935 | { | ||
| 936 | int ret; | ||
| 937 | ret = btrfs_find_orphan_item(root, offset); | ||
| 938 | if (ret > 0) | ||
| 939 | ret = btrfs_insert_orphan_item(trans, root, offset); | ||
| 940 | return ret; | ||
| 941 | } | ||
| 942 | |||
| 943 | |||
| 933 | /* | 944 | /* |
| 934 | * There are a few corners where the link count of the file can't | 945 | * There are a few corners where the link count of the file can't |
| 935 | * be properly maintained during replay. So, instead of adding | 946 | * be properly maintained during replay. So, instead of adding |
| @@ -997,9 +1008,13 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, | |||
| 997 | } | 1008 | } |
| 998 | BTRFS_I(inode)->index_cnt = (u64)-1; | 1009 | BTRFS_I(inode)->index_cnt = (u64)-1; |
| 999 | 1010 | ||
| 1000 | if (inode->i_nlink == 0 && S_ISDIR(inode->i_mode)) { | 1011 | if (inode->i_nlink == 0) { |
| 1001 | ret = replay_dir_deletes(trans, root, NULL, path, | 1012 | if (S_ISDIR(inode->i_mode)) { |
| 1002 | inode->i_ino, 1); | 1013 | ret = replay_dir_deletes(trans, root, NULL, path, |
| 1014 | inode->i_ino, 1); | ||
| 1015 | BUG_ON(ret); | ||
| 1016 | } | ||
| 1017 | ret = insert_orphan_item(trans, root, inode->i_ino); | ||
| 1003 | BUG_ON(ret); | 1018 | BUG_ON(ret); |
| 1004 | } | 1019 | } |
| 1005 | btrfs_free_path(path); | 1020 | btrfs_free_path(path); |
| @@ -1587,7 +1602,6 @@ static int replay_one_buffer(struct btrfs_root *log, struct extent_buffer *eb, | |||
| 1587 | /* inode keys are done during the first stage */ | 1602 | /* inode keys are done during the first stage */ |
| 1588 | if (key.type == BTRFS_INODE_ITEM_KEY && | 1603 | if (key.type == BTRFS_INODE_ITEM_KEY && |
| 1589 | wc->stage == LOG_WALK_REPLAY_INODES) { | 1604 | wc->stage == LOG_WALK_REPLAY_INODES) { |
| 1590 | struct inode *inode; | ||
| 1591 | struct btrfs_inode_item *inode_item; | 1605 | struct btrfs_inode_item *inode_item; |
| 1592 | u32 mode; | 1606 | u32 mode; |
| 1593 | 1607 | ||
| @@ -1603,31 +1617,16 @@ static int replay_one_buffer(struct btrfs_root *log, struct extent_buffer *eb, | |||
| 1603 | eb, i, &key); | 1617 | eb, i, &key); |
| 1604 | BUG_ON(ret); | 1618 | BUG_ON(ret); |
| 1605 | 1619 | ||
| 1606 | /* for regular files, truncate away | 1620 | /* for regular files, make sure corresponding |
| 1607 | * extents past the new EOF | 1621 | * orhpan item exist. extents past the new EOF |
| 1622 | * will be truncated later by orphan cleanup. | ||
| 1608 | */ | 1623 | */ |
| 1609 | if (S_ISREG(mode)) { | 1624 | if (S_ISREG(mode)) { |
| 1610 | inode = read_one_inode(root, | 1625 | ret = insert_orphan_item(wc->trans, root, |
| 1611 | key.objectid); | 1626 | key.objectid); |
| 1612 | BUG_ON(!inode); | ||
| 1613 | |||
| 1614 | ret = btrfs_truncate_inode_items(wc->trans, | ||
| 1615 | root, inode, inode->i_size, | ||
| 1616 | BTRFS_EXTENT_DATA_KEY); | ||
| 1617 | BUG_ON(ret); | 1627 | BUG_ON(ret); |
| 1618 | |||
| 1619 | /* if the nlink count is zero here, the iput | ||
| 1620 | * will free the inode. We bump it to make | ||
| 1621 | * sure it doesn't get freed until the link | ||
| 1622 | * count fixup is done | ||
| 1623 | */ | ||
| 1624 | if (inode->i_nlink == 0) { | ||
| 1625 | btrfs_inc_nlink(inode); | ||
| 1626 | btrfs_update_inode(wc->trans, | ||
| 1627 | root, inode); | ||
| 1628 | } | ||
| 1629 | iput(inode); | ||
| 1630 | } | 1628 | } |
| 1629 | |||
| 1631 | ret = link_to_fixup_dir(wc->trans, root, | 1630 | ret = link_to_fixup_dir(wc->trans, root, |
| 1632 | path, key.objectid); | 1631 | path, key.objectid); |
| 1633 | BUG_ON(ret); | 1632 | BUG_ON(ret); |
| @@ -1977,10 +1976,11 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, | |||
| 1977 | { | 1976 | { |
| 1978 | int index1; | 1977 | int index1; |
| 1979 | int index2; | 1978 | int index2; |
| 1979 | int mark; | ||
| 1980 | int ret; | 1980 | int ret; |
| 1981 | struct btrfs_root *log = root->log_root; | 1981 | struct btrfs_root *log = root->log_root; |
| 1982 | struct btrfs_root *log_root_tree = root->fs_info->log_root_tree; | 1982 | struct btrfs_root *log_root_tree = root->fs_info->log_root_tree; |
| 1983 | u64 log_transid = 0; | 1983 | unsigned long log_transid = 0; |
| 1984 | 1984 | ||
| 1985 | mutex_lock(&root->log_mutex); | 1985 | mutex_lock(&root->log_mutex); |
| 1986 | index1 = root->log_transid % 2; | 1986 | index1 = root->log_transid % 2; |
| @@ -2014,24 +2014,29 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, | |||
| 2014 | goto out; | 2014 | goto out; |
| 2015 | } | 2015 | } |
| 2016 | 2016 | ||
| 2017 | log_transid = root->log_transid; | ||
| 2018 | if (log_transid % 2 == 0) | ||
| 2019 | mark = EXTENT_DIRTY; | ||
| 2020 | else | ||
| 2021 | mark = EXTENT_NEW; | ||
| 2022 | |||
| 2017 | /* we start IO on all the marked extents here, but we don't actually | 2023 | /* we start IO on all the marked extents here, but we don't actually |
| 2018 | * wait for them until later. | 2024 | * wait for them until later. |
| 2019 | */ | 2025 | */ |
| 2020 | ret = btrfs_write_marked_extents(log, &log->dirty_log_pages); | 2026 | ret = btrfs_write_marked_extents(log, &log->dirty_log_pages, mark); |
| 2021 | BUG_ON(ret); | 2027 | BUG_ON(ret); |
| 2022 | 2028 | ||
| 2023 | btrfs_set_root_node(&log->root_item, log->node); | 2029 | btrfs_set_root_node(&log->root_item, log->node); |
| 2024 | 2030 | ||
| 2025 | root->log_batch = 0; | 2031 | root->log_batch = 0; |
| 2026 | log_transid = root->log_transid; | ||
| 2027 | root->log_transid++; | 2032 | root->log_transid++; |
| 2028 | log->log_transid = root->log_transid; | 2033 | log->log_transid = root->log_transid; |
| 2029 | root->log_start_pid = 0; | 2034 | root->log_start_pid = 0; |
| 2030 | smp_mb(); | 2035 | smp_mb(); |
| 2031 | /* | 2036 | /* |
| 2032 | * log tree has been flushed to disk, new modifications of | 2037 | * IO has been started, blocks of the log tree have WRITTEN flag set |
| 2033 | * the log will be written to new positions. so it's safe to | 2038 | * in their headers. new modifications of the log will be written to |
| 2034 | * allow log writers to go in. | 2039 | * new positions. so it's safe to allow log writers to go in. |
| 2035 | */ | 2040 | */ |
| 2036 | mutex_unlock(&root->log_mutex); | 2041 | mutex_unlock(&root->log_mutex); |
| 2037 | 2042 | ||
| @@ -2052,7 +2057,7 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, | |||
| 2052 | 2057 | ||
| 2053 | index2 = log_root_tree->log_transid % 2; | 2058 | index2 = log_root_tree->log_transid % 2; |
| 2054 | if (atomic_read(&log_root_tree->log_commit[index2])) { | 2059 | if (atomic_read(&log_root_tree->log_commit[index2])) { |
| 2055 | btrfs_wait_marked_extents(log, &log->dirty_log_pages); | 2060 | btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark); |
| 2056 | wait_log_commit(trans, log_root_tree, | 2061 | wait_log_commit(trans, log_root_tree, |
| 2057 | log_root_tree->log_transid); | 2062 | log_root_tree->log_transid); |
| 2058 | mutex_unlock(&log_root_tree->log_mutex); | 2063 | mutex_unlock(&log_root_tree->log_mutex); |
| @@ -2072,16 +2077,17 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, | |||
| 2072 | * check the full commit flag again | 2077 | * check the full commit flag again |
| 2073 | */ | 2078 | */ |
| 2074 | if (root->fs_info->last_trans_log_full_commit == trans->transid) { | 2079 | if (root->fs_info->last_trans_log_full_commit == trans->transid) { |
| 2075 | btrfs_wait_marked_extents(log, &log->dirty_log_pages); | 2080 | btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark); |
| 2076 | mutex_unlock(&log_root_tree->log_mutex); | 2081 | mutex_unlock(&log_root_tree->log_mutex); |
| 2077 | ret = -EAGAIN; | 2082 | ret = -EAGAIN; |
| 2078 | goto out_wake_log_root; | 2083 | goto out_wake_log_root; |
| 2079 | } | 2084 | } |
| 2080 | 2085 | ||
| 2081 | ret = btrfs_write_and_wait_marked_extents(log_root_tree, | 2086 | ret = btrfs_write_and_wait_marked_extents(log_root_tree, |
| 2082 | &log_root_tree->dirty_log_pages); | 2087 | &log_root_tree->dirty_log_pages, |
| 2088 | EXTENT_DIRTY | EXTENT_NEW); | ||
| 2083 | BUG_ON(ret); | 2089 | BUG_ON(ret); |
| 2084 | btrfs_wait_marked_extents(log, &log->dirty_log_pages); | 2090 | btrfs_wait_marked_extents(log, &log->dirty_log_pages, mark); |
| 2085 | 2091 | ||
| 2086 | btrfs_set_super_log_root(&root->fs_info->super_for_commit, | 2092 | btrfs_set_super_log_root(&root->fs_info->super_for_commit, |
| 2087 | log_root_tree->node->start); | 2093 | log_root_tree->node->start); |
| @@ -2147,12 +2153,12 @@ int btrfs_free_log(struct btrfs_trans_handle *trans, struct btrfs_root *root) | |||
| 2147 | 2153 | ||
| 2148 | while (1) { | 2154 | while (1) { |
| 2149 | ret = find_first_extent_bit(&log->dirty_log_pages, | 2155 | ret = find_first_extent_bit(&log->dirty_log_pages, |
| 2150 | 0, &start, &end, EXTENT_DIRTY); | 2156 | 0, &start, &end, EXTENT_DIRTY | EXTENT_NEW); |
| 2151 | if (ret) | 2157 | if (ret) |
| 2152 | break; | 2158 | break; |
| 2153 | 2159 | ||
| 2154 | clear_extent_dirty(&log->dirty_log_pages, | 2160 | clear_extent_bits(&log->dirty_log_pages, start, end, |
| 2155 | start, end, GFP_NOFS); | 2161 | EXTENT_DIRTY | EXTENT_NEW, GFP_NOFS); |
| 2156 | } | 2162 | } |
| 2157 | 2163 | ||
| 2158 | if (log->log_transid > 0) { | 2164 | if (log->log_transid > 0) { |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 7eda483d7b5a..198cff28766d 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
| @@ -2209,7 +2209,7 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, | |||
| 2209 | max_chunk_size = 10 * calc_size; | 2209 | max_chunk_size = 10 * calc_size; |
| 2210 | min_stripe_size = 64 * 1024 * 1024; | 2210 | min_stripe_size = 64 * 1024 * 1024; |
| 2211 | } else if (type & BTRFS_BLOCK_GROUP_METADATA) { | 2211 | } else if (type & BTRFS_BLOCK_GROUP_METADATA) { |
| 2212 | max_chunk_size = 4 * calc_size; | 2212 | max_chunk_size = 256 * 1024 * 1024; |
| 2213 | min_stripe_size = 32 * 1024 * 1024; | 2213 | min_stripe_size = 32 * 1024 * 1024; |
| 2214 | } else if (type & BTRFS_BLOCK_GROUP_SYSTEM) { | 2214 | } else if (type & BTRFS_BLOCK_GROUP_SYSTEM) { |
| 2215 | calc_size = 8 * 1024 * 1024; | 2215 | calc_size = 8 * 1024 * 1024; |
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index b6dd5967c48a..193b58f7d3f3 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c | |||
| @@ -85,22 +85,23 @@ out: | |||
| 85 | return ret; | 85 | return ret; |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | int __btrfs_setxattr(struct inode *inode, const char *name, | 88 | static int do_setxattr(struct btrfs_trans_handle *trans, |
| 89 | const void *value, size_t size, int flags) | 89 | struct inode *inode, const char *name, |
| 90 | const void *value, size_t size, int flags) | ||
| 90 | { | 91 | { |
| 91 | struct btrfs_dir_item *di; | 92 | struct btrfs_dir_item *di; |
| 92 | struct btrfs_root *root = BTRFS_I(inode)->root; | 93 | struct btrfs_root *root = BTRFS_I(inode)->root; |
| 93 | struct btrfs_trans_handle *trans; | ||
| 94 | struct btrfs_path *path; | 94 | struct btrfs_path *path; |
| 95 | int ret = 0, mod = 0; | 95 | size_t name_len = strlen(name); |
| 96 | int ret = 0; | ||
| 97 | |||
| 98 | if (name_len + size > BTRFS_MAX_XATTR_SIZE(root)) | ||
| 99 | return -ENOSPC; | ||
| 96 | 100 | ||
| 97 | path = btrfs_alloc_path(); | 101 | path = btrfs_alloc_path(); |
| 98 | if (!path) | 102 | if (!path) |
| 99 | return -ENOMEM; | 103 | return -ENOMEM; |
| 100 | 104 | ||
| 101 | trans = btrfs_join_transaction(root, 1); | ||
| 102 | btrfs_set_trans_block_group(trans, inode); | ||
| 103 | |||
| 104 | /* first lets see if we already have this xattr */ | 105 | /* first lets see if we already have this xattr */ |
| 105 | di = btrfs_lookup_xattr(trans, root, path, inode->i_ino, name, | 106 | di = btrfs_lookup_xattr(trans, root, path, inode->i_ino, name, |
| 106 | strlen(name), -1); | 107 | strlen(name), -1); |
| @@ -118,15 +119,12 @@ int __btrfs_setxattr(struct inode *inode, const char *name, | |||
| 118 | } | 119 | } |
| 119 | 120 | ||
| 120 | ret = btrfs_delete_one_dir_name(trans, root, path, di); | 121 | ret = btrfs_delete_one_dir_name(trans, root, path, di); |
| 121 | if (ret) | 122 | BUG_ON(ret); |
| 122 | goto out; | ||
| 123 | btrfs_release_path(root, path); | 123 | btrfs_release_path(root, path); |
| 124 | 124 | ||
| 125 | /* if we don't have a value then we are removing the xattr */ | 125 | /* if we don't have a value then we are removing the xattr */ |
| 126 | if (!value) { | 126 | if (!value) |
| 127 | mod = 1; | ||
| 128 | goto out; | 127 | goto out; |
| 129 | } | ||
| 130 | } else { | 128 | } else { |
| 131 | btrfs_release_path(root, path); | 129 | btrfs_release_path(root, path); |
| 132 | 130 | ||
| @@ -138,20 +136,45 @@ int __btrfs_setxattr(struct inode *inode, const char *name, | |||
| 138 | } | 136 | } |
| 139 | 137 | ||
| 140 | /* ok we have to create a completely new xattr */ | 138 | /* ok we have to create a completely new xattr */ |
| 141 | ret = btrfs_insert_xattr_item(trans, root, name, strlen(name), | 139 | ret = btrfs_insert_xattr_item(trans, root, path, inode->i_ino, |
| 142 | value, size, inode->i_ino); | 140 | name, name_len, value, size); |
| 141 | BUG_ON(ret); | ||
| 142 | out: | ||
| 143 | btrfs_free_path(path); | ||
| 144 | return ret; | ||
| 145 | } | ||
| 146 | |||
| 147 | int __btrfs_setxattr(struct btrfs_trans_handle *trans, | ||
| 148 | struct inode *inode, const char *name, | ||
| 149 | const void *value, size_t size, int flags) | ||
| 150 | { | ||
| 151 | struct btrfs_root *root = BTRFS_I(inode)->root; | ||
| 152 | int ret; | ||
| 153 | |||
| 154 | if (trans) | ||
| 155 | return do_setxattr(trans, inode, name, value, size, flags); | ||
| 156 | |||
| 157 | ret = btrfs_reserve_metadata_space(root, 2); | ||
| 143 | if (ret) | 158 | if (ret) |
| 144 | goto out; | 159 | return ret; |
| 145 | mod = 1; | ||
| 146 | 160 | ||
| 147 | out: | 161 | trans = btrfs_start_transaction(root, 1); |
| 148 | if (mod) { | 162 | if (!trans) { |
| 149 | inode->i_ctime = CURRENT_TIME; | 163 | ret = -ENOMEM; |
| 150 | ret = btrfs_update_inode(trans, root, inode); | 164 | goto out; |
| 151 | } | 165 | } |
| 166 | btrfs_set_trans_block_group(trans, inode); | ||
| 152 | 167 | ||
| 153 | btrfs_end_transaction(trans, root); | 168 | ret = do_setxattr(trans, inode, name, value, size, flags); |
| 154 | btrfs_free_path(path); | 169 | if (ret) |
| 170 | goto out; | ||
| 171 | |||
| 172 | inode->i_ctime = CURRENT_TIME; | ||
| 173 | ret = btrfs_update_inode(trans, root, inode); | ||
| 174 | BUG_ON(ret); | ||
| 175 | out: | ||
| 176 | btrfs_end_transaction_throttle(trans, root); | ||
| 177 | btrfs_unreserve_metadata_space(root, 2); | ||
| 155 | return ret; | 178 | return ret; |
| 156 | } | 179 | } |
| 157 | 180 | ||
| @@ -314,7 +337,9 @@ int btrfs_setxattr(struct dentry *dentry, const char *name, const void *value, | |||
| 314 | 337 | ||
| 315 | if (size == 0) | 338 | if (size == 0) |
| 316 | value = ""; /* empty EA, do not remove */ | 339 | value = ""; /* empty EA, do not remove */ |
| 317 | return __btrfs_setxattr(dentry->d_inode, name, value, size, flags); | 340 | |
| 341 | return __btrfs_setxattr(NULL, dentry->d_inode, name, value, size, | ||
| 342 | flags); | ||
| 318 | } | 343 | } |
| 319 | 344 | ||
| 320 | int btrfs_removexattr(struct dentry *dentry, const char *name) | 345 | int btrfs_removexattr(struct dentry *dentry, const char *name) |
| @@ -329,10 +354,13 @@ int btrfs_removexattr(struct dentry *dentry, const char *name) | |||
| 329 | 354 | ||
| 330 | if (!btrfs_is_valid_xattr(name)) | 355 | if (!btrfs_is_valid_xattr(name)) |
| 331 | return -EOPNOTSUPP; | 356 | return -EOPNOTSUPP; |
| 332 | return __btrfs_setxattr(dentry->d_inode, name, NULL, 0, XATTR_REPLACE); | 357 | |
| 358 | return __btrfs_setxattr(NULL, dentry->d_inode, name, NULL, 0, | ||
| 359 | XATTR_REPLACE); | ||
| 333 | } | 360 | } |
| 334 | 361 | ||
| 335 | int btrfs_xattr_security_init(struct inode *inode, struct inode *dir) | 362 | int btrfs_xattr_security_init(struct btrfs_trans_handle *trans, |
| 363 | struct inode *inode, struct inode *dir) | ||
| 336 | { | 364 | { |
| 337 | int err; | 365 | int err; |
| 338 | size_t len; | 366 | size_t len; |
| @@ -354,7 +382,7 @@ int btrfs_xattr_security_init(struct inode *inode, struct inode *dir) | |||
| 354 | } else { | 382 | } else { |
| 355 | strcpy(name, XATTR_SECURITY_PREFIX); | 383 | strcpy(name, XATTR_SECURITY_PREFIX); |
| 356 | strcpy(name + XATTR_SECURITY_PREFIX_LEN, suffix); | 384 | strcpy(name + XATTR_SECURITY_PREFIX_LEN, suffix); |
| 357 | err = __btrfs_setxattr(inode, name, value, len, 0); | 385 | err = __btrfs_setxattr(trans, inode, name, value, len, 0); |
| 358 | kfree(name); | 386 | kfree(name); |
| 359 | } | 387 | } |
| 360 | 388 | ||
diff --git a/fs/btrfs/xattr.h b/fs/btrfs/xattr.h index c71e9c3cf3f7..721efa0346e0 100644 --- a/fs/btrfs/xattr.h +++ b/fs/btrfs/xattr.h | |||
| @@ -27,15 +27,16 @@ extern struct xattr_handler *btrfs_xattr_handlers[]; | |||
| 27 | 27 | ||
| 28 | extern ssize_t __btrfs_getxattr(struct inode *inode, const char *name, | 28 | extern ssize_t __btrfs_getxattr(struct inode *inode, const char *name, |
| 29 | void *buffer, size_t size); | 29 | void *buffer, size_t size); |
| 30 | extern int __btrfs_setxattr(struct inode *inode, const char *name, | 30 | extern int __btrfs_setxattr(struct btrfs_trans_handle *trans, |
| 31 | const void *value, size_t size, int flags); | 31 | struct inode *inode, const char *name, |
| 32 | 32 | const void *value, size_t size, int flags); | |
| 33 | extern ssize_t btrfs_getxattr(struct dentry *dentry, const char *name, | 33 | extern ssize_t btrfs_getxattr(struct dentry *dentry, const char *name, |
| 34 | void *buffer, size_t size); | 34 | void *buffer, size_t size); |
| 35 | extern int btrfs_setxattr(struct dentry *dentry, const char *name, | 35 | extern int btrfs_setxattr(struct dentry *dentry, const char *name, |
| 36 | const void *value, size_t size, int flags); | 36 | const void *value, size_t size, int flags); |
| 37 | extern int btrfs_removexattr(struct dentry *dentry, const char *name); | 37 | extern int btrfs_removexattr(struct dentry *dentry, const char *name); |
| 38 | 38 | ||
| 39 | extern int btrfs_xattr_security_init(struct inode *inode, struct inode *dir); | 39 | extern int btrfs_xattr_security_init(struct btrfs_trans_handle *trans, |
| 40 | struct inode *inode, struct inode *dir); | ||
| 40 | 41 | ||
| 41 | #endif /* __XATTR__ */ | 42 | #endif /* __XATTR__ */ |
diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c index 3797e0077b35..2906077ac798 100644 --- a/fs/cachefiles/bind.c +++ b/fs/cachefiles/bind.c | |||
| @@ -84,7 +84,7 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args) | |||
| 84 | static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache) | 84 | static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache) |
| 85 | { | 85 | { |
| 86 | struct cachefiles_object *fsdef; | 86 | struct cachefiles_object *fsdef; |
| 87 | struct nameidata nd; | 87 | struct path path; |
| 88 | struct kstatfs stats; | 88 | struct kstatfs stats; |
| 89 | struct dentry *graveyard, *cachedir, *root; | 89 | struct dentry *graveyard, *cachedir, *root; |
| 90 | const struct cred *saved_cred; | 90 | const struct cred *saved_cred; |
| @@ -114,15 +114,12 @@ static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache) | |||
| 114 | _debug("- fsdef %p", fsdef); | 114 | _debug("- fsdef %p", fsdef); |
| 115 | 115 | ||
| 116 | /* look up the directory at the root of the cache */ | 116 | /* look up the directory at the root of the cache */ |
| 117 | memset(&nd, 0, sizeof(nd)); | 117 | ret = kern_path(cache->rootdirname, LOOKUP_DIRECTORY, &path); |
| 118 | |||
| 119 | ret = path_lookup(cache->rootdirname, LOOKUP_DIRECTORY, &nd); | ||
| 120 | if (ret < 0) | 118 | if (ret < 0) |
| 121 | goto error_open_root; | 119 | goto error_open_root; |
| 122 | 120 | ||
| 123 | cache->mnt = mntget(nd.path.mnt); | 121 | cache->mnt = path.mnt; |
| 124 | root = dget(nd.path.dentry); | 122 | root = path.dentry; |
| 125 | path_put(&nd.path); | ||
| 126 | 123 | ||
| 127 | /* check parameters */ | 124 | /* check parameters */ |
| 128 | ret = -EOPNOTSUPP; | 125 | ret = -EOPNOTSUPP; |
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c index 4618516dd994..c2413561ea75 100644 --- a/fs/cachefiles/daemon.c +++ b/fs/cachefiles/daemon.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include <linux/mount.h> | 21 | #include <linux/mount.h> |
| 22 | #include <linux/statfs.h> | 22 | #include <linux/statfs.h> |
| 23 | #include <linux/ctype.h> | 23 | #include <linux/ctype.h> |
| 24 | #include <linux/string.h> | ||
| 24 | #include <linux/fs_struct.h> | 25 | #include <linux/fs_struct.h> |
| 25 | #include "internal.h" | 26 | #include "internal.h" |
| 26 | 27 | ||
| @@ -257,8 +258,7 @@ static ssize_t cachefiles_daemon_write(struct file *file, | |||
| 257 | if (args == data) | 258 | if (args == data) |
| 258 | goto error; | 259 | goto error; |
| 259 | *args = '\0'; | 260 | *args = '\0'; |
| 260 | for (args++; isspace(*args); args++) | 261 | args = skip_spaces(++args); |
| 261 | continue; | ||
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | /* run the appropriate command handler */ | 264 | /* run the appropriate command handler */ |
diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c index a6c8c6fe8df9..1d8332563863 100644 --- a/fs/cachefiles/rdwr.c +++ b/fs/cachefiles/rdwr.c | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | 11 | ||
| 12 | #include <linux/mount.h> | 12 | #include <linux/mount.h> |
| 13 | #include <linux/file.h> | 13 | #include <linux/file.h> |
| 14 | #include <linux/ima.h> | ||
| 15 | #include "internal.h" | 14 | #include "internal.h" |
| 16 | 15 | ||
| 17 | /* | 16 | /* |
| @@ -923,7 +922,6 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page) | |||
| 923 | if (IS_ERR(file)) { | 922 | if (IS_ERR(file)) { |
| 924 | ret = PTR_ERR(file); | 923 | ret = PTR_ERR(file); |
| 925 | } else { | 924 | } else { |
| 926 | ima_counts_get(file); | ||
| 927 | ret = -EIO; | 925 | ret = -EIO; |
| 928 | if (file->f_op->write) { | 926 | if (file->f_op->write) { |
| 929 | pos = (loff_t) page->index << PAGE_SHIFT; | 927 | pos = (loff_t) page->index << PAGE_SHIFT; |
diff --git a/fs/cifs/export.c b/fs/cifs/export.c index 75949d6a5f1b..6177f7cca16a 100644 --- a/fs/cifs/export.c +++ b/fs/cifs/export.c | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | */ | 24 | */ |
| 25 | 25 | ||
| 26 | /* | 26 | /* |
| 27 | * See Documentation/filesystems/Exporting | 27 | * See Documentation/filesystems/nfs/Exporting |
| 28 | * and examples in fs/exportfs | 28 | * and examples in fs/exportfs |
| 29 | * | 29 | * |
| 30 | * Since cifs is a network file system, an "fsid" must be included for | 30 | * Since cifs is a network file system, an "fsid" must be included for |
diff --git a/fs/compat.c b/fs/compat.c index 6c19040ffeef..00d90c2e66f0 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
| @@ -38,8 +38,6 @@ | |||
| 38 | #include <linux/dirent.h> | 38 | #include <linux/dirent.h> |
| 39 | #include <linux/fsnotify.h> | 39 | #include <linux/fsnotify.h> |
| 40 | #include <linux/highuid.h> | 40 | #include <linux/highuid.h> |
| 41 | #include <linux/sunrpc/svc.h> | ||
| 42 | #include <linux/nfsd/nfsd.h> | ||
| 43 | #include <linux/nfsd/syscall.h> | 41 | #include <linux/nfsd/syscall.h> |
| 44 | #include <linux/personality.h> | 42 | #include <linux/personality.h> |
| 45 | #include <linux/rwsem.h> | 43 | #include <linux/rwsem.h> |
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 278020d2449c..14cbc831422a 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
| @@ -979,24 +979,6 @@ COMPATIBLE_IOCTL(FIGETBSZ) | |||
| 979 | /* 'X' - originally XFS but some now in the VFS */ | 979 | /* 'X' - originally XFS but some now in the VFS */ |
| 980 | COMPATIBLE_IOCTL(FIFREEZE) | 980 | COMPATIBLE_IOCTL(FIFREEZE) |
| 981 | COMPATIBLE_IOCTL(FITHAW) | 981 | COMPATIBLE_IOCTL(FITHAW) |
| 982 | /* RAID */ | ||
| 983 | COMPATIBLE_IOCTL(RAID_VERSION) | ||
| 984 | COMPATIBLE_IOCTL(GET_ARRAY_INFO) | ||
| 985 | COMPATIBLE_IOCTL(GET_DISK_INFO) | ||
| 986 | COMPATIBLE_IOCTL(PRINT_RAID_DEBUG) | ||
| 987 | COMPATIBLE_IOCTL(RAID_AUTORUN) | ||
| 988 | COMPATIBLE_IOCTL(CLEAR_ARRAY) | ||
| 989 | COMPATIBLE_IOCTL(ADD_NEW_DISK) | ||
| 990 | COMPATIBLE_IOCTL(SET_ARRAY_INFO) | ||
| 991 | COMPATIBLE_IOCTL(SET_DISK_INFO) | ||
| 992 | COMPATIBLE_IOCTL(WRITE_RAID_INFO) | ||
| 993 | COMPATIBLE_IOCTL(UNPROTECT_ARRAY) | ||
| 994 | COMPATIBLE_IOCTL(PROTECT_ARRAY) | ||
| 995 | COMPATIBLE_IOCTL(RUN_ARRAY) | ||
| 996 | COMPATIBLE_IOCTL(STOP_ARRAY) | ||
| 997 | COMPATIBLE_IOCTL(STOP_ARRAY_RO) | ||
| 998 | COMPATIBLE_IOCTL(RESTART_ARRAY_RW) | ||
| 999 | COMPATIBLE_IOCTL(GET_BITMAP_FILE) | ||
| 1000 | COMPATIBLE_IOCTL(KDGETKEYCODE) | 982 | COMPATIBLE_IOCTL(KDGETKEYCODE) |
| 1001 | COMPATIBLE_IOCTL(KDSETKEYCODE) | 983 | COMPATIBLE_IOCTL(KDSETKEYCODE) |
| 1002 | COMPATIBLE_IOCTL(KDGKBTYPE) | 984 | COMPATIBLE_IOCTL(KDGKBTYPE) |
diff --git a/fs/dcache.c b/fs/dcache.c index a100fa35a48f..953173a293a9 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
| @@ -978,6 +978,7 @@ struct dentry *d_alloc_name(struct dentry *parent, const char *name) | |||
| 978 | q.hash = full_name_hash(q.name, q.len); | 978 | q.hash = full_name_hash(q.name, q.len); |
| 979 | return d_alloc(parent, &q); | 979 | return d_alloc(parent, &q); |
| 980 | } | 980 | } |
| 981 | EXPORT_SYMBOL(d_alloc_name); | ||
| 981 | 982 | ||
| 982 | /* the caller must hold dcache_lock */ | 983 | /* the caller must hold dcache_lock */ |
| 983 | static void __d_instantiate(struct dentry *dentry, struct inode *inode) | 984 | static void __d_instantiate(struct dentry *dentry, struct inode *inode) |
diff --git a/fs/direct-io.c b/fs/direct-io.c index b912270942fa..e82adc2debb7 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c | |||
| @@ -53,13 +53,6 @@ | |||
| 53 | * | 53 | * |
| 54 | * If blkfactor is zero then the user's request was aligned to the filesystem's | 54 | * If blkfactor is zero then the user's request was aligned to the filesystem's |
| 55 | * blocksize. | 55 | * blocksize. |
| 56 | * | ||
| 57 | * lock_type is DIO_LOCKING for regular files on direct-IO-naive filesystems. | ||
| 58 | * This determines whether we need to do the fancy locking which prevents | ||
| 59 | * direct-IO from being able to read uninitialised disk blocks. If its zero | ||
| 60 | * (blockdev) this locking is not done, and if it is DIO_OWN_LOCKING i_mutex is | ||
| 61 | * not held for the entire direct write (taken briefly, initially, during a | ||
| 62 | * direct read though, but its never held for the duration of a direct-IO). | ||
| 63 | */ | 56 | */ |
| 64 | 57 | ||
| 65 | struct dio { | 58 | struct dio { |
| @@ -68,7 +61,7 @@ struct dio { | |||
| 68 | struct inode *inode; | 61 | struct inode *inode; |
| 69 | int rw; | 62 | int rw; |
| 70 | loff_t i_size; /* i_size when submitted */ | 63 | loff_t i_size; /* i_size when submitted */ |
| 71 | int lock_type; /* doesn't change */ | 64 | int flags; /* doesn't change */ |
| 72 | unsigned blkbits; /* doesn't change */ | 65 | unsigned blkbits; /* doesn't change */ |
| 73 | unsigned blkfactor; /* When we're using an alignment which | 66 | unsigned blkfactor; /* When we're using an alignment which |
| 74 | is finer than the filesystem's soft | 67 | is finer than the filesystem's soft |
| @@ -104,6 +97,18 @@ struct dio { | |||
| 104 | unsigned cur_page_len; /* Nr of bytes at cur_page_offset */ | 97 | unsigned cur_page_len; /* Nr of bytes at cur_page_offset */ |
| 105 | sector_t cur_page_block; /* Where it starts */ | 98 | sector_t cur_page_block; /* Where it starts */ |
| 106 | 99 | ||
| 100 | /* BIO completion state */ | ||
| 101 | spinlock_t bio_lock; /* protects BIO fields below */ | ||
| 102 | unsigned long refcount; /* direct_io_worker() and bios */ | ||
| 103 | struct bio *bio_list; /* singly linked via bi_private */ | ||
| 104 | struct task_struct *waiter; /* waiting task (NULL if none) */ | ||
| 105 | |||
| 106 | /* AIO related stuff */ | ||
| 107 | struct kiocb *iocb; /* kiocb */ | ||
| 108 | int is_async; /* is IO async ? */ | ||
| 109 | int io_error; /* IO error in completion path */ | ||
| 110 | ssize_t result; /* IO result */ | ||
| 111 | |||
| 107 | /* | 112 | /* |
| 108 | * Page fetching state. These variables belong to dio_refill_pages(). | 113 | * Page fetching state. These variables belong to dio_refill_pages(). |
| 109 | */ | 114 | */ |
| @@ -115,22 +120,16 @@ struct dio { | |||
| 115 | * Page queue. These variables belong to dio_refill_pages() and | 120 | * Page queue. These variables belong to dio_refill_pages() and |
| 116 | * dio_get_page(). | 121 | * dio_get_page(). |
| 117 | */ | 122 | */ |
| 118 | struct page *pages[DIO_PAGES]; /* page buffer */ | ||
| 119 | unsigned head; /* next page to process */ | 123 | unsigned head; /* next page to process */ |
| 120 | unsigned tail; /* last valid page + 1 */ | 124 | unsigned tail; /* last valid page + 1 */ |
| 121 | int page_errors; /* errno from get_user_pages() */ | 125 | int page_errors; /* errno from get_user_pages() */ |
| 122 | 126 | ||
| 123 | /* BIO completion state */ | 127 | /* |
| 124 | spinlock_t bio_lock; /* protects BIO fields below */ | 128 | * pages[] (and any fields placed after it) are not zeroed out at |
| 125 | unsigned long refcount; /* direct_io_worker() and bios */ | 129 | * allocation time. Don't add new fields after pages[] unless you |
| 126 | struct bio *bio_list; /* singly linked via bi_private */ | 130 | * wish that they not be zeroed. |
| 127 | struct task_struct *waiter; /* waiting task (NULL if none) */ | 131 | */ |
| 128 | 132 | struct page *pages[DIO_PAGES]; /* page buffer */ | |
| 129 | /* AIO related stuff */ | ||
| 130 | struct kiocb *iocb; /* kiocb */ | ||
| 131 | int is_async; /* is IO async ? */ | ||
| 132 | int io_error; /* IO error in completion path */ | ||
| 133 | ssize_t result; /* IO result */ | ||
| 134 | }; | 133 | }; |
| 135 | 134 | ||
| 136 | /* | 135 | /* |
| @@ -240,7 +239,8 @@ static int dio_complete(struct dio *dio, loff_t offset, int ret) | |||
| 240 | if (dio->end_io && dio->result) | 239 | if (dio->end_io && dio->result) |
| 241 | dio->end_io(dio->iocb, offset, transferred, | 240 | dio->end_io(dio->iocb, offset, transferred, |
| 242 | dio->map_bh.b_private); | 241 | dio->map_bh.b_private); |
| 243 | if (dio->lock_type == DIO_LOCKING) | 242 | |
| 243 | if (dio->flags & DIO_LOCKING) | ||
| 244 | /* lockdep: non-owner release */ | 244 | /* lockdep: non-owner release */ |
| 245 | up_read_non_owner(&dio->inode->i_alloc_sem); | 245 | up_read_non_owner(&dio->inode->i_alloc_sem); |
| 246 | 246 | ||
| @@ -515,21 +515,24 @@ static int get_more_blocks(struct dio *dio) | |||
| 515 | map_bh->b_state = 0; | 515 | map_bh->b_state = 0; |
| 516 | map_bh->b_size = fs_count << dio->inode->i_blkbits; | 516 | map_bh->b_size = fs_count << dio->inode->i_blkbits; |
| 517 | 517 | ||
| 518 | /* | ||
| 519 | * For writes inside i_size on a DIO_SKIP_HOLES filesystem we | ||
| 520 | * forbid block creations: only overwrites are permitted. | ||
| 521 | * We will return early to the caller once we see an | ||
| 522 | * unmapped buffer head returned, and the caller will fall | ||
| 523 | * back to buffered I/O. | ||
| 524 | * | ||
| 525 | * Otherwise the decision is left to the get_blocks method, | ||
| 526 | * which may decide to handle it or also return an unmapped | ||
| 527 | * buffer head. | ||
| 528 | */ | ||
| 518 | create = dio->rw & WRITE; | 529 | create = dio->rw & WRITE; |
| 519 | if (dio->lock_type == DIO_LOCKING) { | 530 | if (dio->flags & DIO_SKIP_HOLES) { |
| 520 | if (dio->block_in_file < (i_size_read(dio->inode) >> | 531 | if (dio->block_in_file < (i_size_read(dio->inode) >> |
| 521 | dio->blkbits)) | 532 | dio->blkbits)) |
| 522 | create = 0; | 533 | create = 0; |
| 523 | } else if (dio->lock_type == DIO_NO_LOCKING) { | ||
| 524 | create = 0; | ||
| 525 | } | 534 | } |
| 526 | 535 | ||
| 527 | /* | ||
| 528 | * For writes inside i_size we forbid block creations: only | ||
| 529 | * overwrites are permitted. We fall back to buffered writes | ||
| 530 | * at a higher level for inside-i_size block-instantiating | ||
| 531 | * writes. | ||
| 532 | */ | ||
| 533 | ret = (*dio->get_block)(dio->inode, fs_startblk, | 536 | ret = (*dio->get_block)(dio->inode, fs_startblk, |
| 534 | map_bh, create); | 537 | map_bh, create); |
| 535 | } | 538 | } |
| @@ -1039,7 +1042,7 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode, | |||
| 1039 | * we can let i_mutex go now that its achieved its purpose | 1042 | * we can let i_mutex go now that its achieved its purpose |
| 1040 | * of protecting us from looking up uninitialized blocks. | 1043 | * of protecting us from looking up uninitialized blocks. |
| 1041 | */ | 1044 | */ |
| 1042 | if ((rw == READ) && (dio->lock_type == DIO_LOCKING)) | 1045 | if (rw == READ && (dio->flags & DIO_LOCKING)) |
| 1043 | mutex_unlock(&dio->inode->i_mutex); | 1046 | mutex_unlock(&dio->inode->i_mutex); |
| 1044 | 1047 | ||
| 1045 | /* | 1048 | /* |
| @@ -1086,30 +1089,28 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode, | |||
| 1086 | 1089 | ||
| 1087 | /* | 1090 | /* |
| 1088 | * This is a library function for use by filesystem drivers. | 1091 | * This is a library function for use by filesystem drivers. |
| 1089 | * The locking rules are governed by the dio_lock_type parameter. | ||
| 1090 | * | 1092 | * |
| 1091 | * DIO_NO_LOCKING (no locking, for raw block device access) | 1093 | * The locking rules are governed by the flags parameter: |
| 1092 | * For writes, i_mutex is not held on entry; it is never taken. | 1094 | * - if the flags value contains DIO_LOCKING we use a fancy locking |
| 1095 | * scheme for dumb filesystems. | ||
| 1096 | * For writes this function is called under i_mutex and returns with | ||
| 1097 | * i_mutex held, for reads, i_mutex is not held on entry, but it is | ||
| 1098 | * taken and dropped again before returning. | ||
| 1099 | * For reads and writes i_alloc_sem is taken in shared mode and released | ||
| 1100 | * on I/O completion (which may happen asynchronously after returning to | ||
| 1101 | * the caller). | ||
| 1093 | * | 1102 | * |
| 1094 | * DIO_LOCKING (simple locking for regular files) | 1103 | * - if the flags value does NOT contain DIO_LOCKING we don't use any |
| 1095 | * For writes we are called under i_mutex and return with i_mutex held, even | 1104 | * internal locking but rather rely on the filesystem to synchronize |
| 1096 | * though it is internally dropped. | 1105 | * direct I/O reads/writes versus each other and truncate. |
| 1097 | * For reads, i_mutex is not held on entry, but it is taken and dropped before | 1106 | * For reads and writes both i_mutex and i_alloc_sem are not held on |
| 1098 | * returning. | 1107 | * entry and are never taken. |
| 1099 | * | ||
| 1100 | * DIO_OWN_LOCKING (filesystem provides synchronisation and handling of | ||
| 1101 | * uninitialised data, allowing parallel direct readers and writers) | ||
| 1102 | * For writes we are called without i_mutex, return without it, never touch it. | ||
| 1103 | * For reads we are called under i_mutex and return with i_mutex held, even | ||
| 1104 | * though it may be internally dropped. | ||
| 1105 | * | ||
| 1106 | * Additional i_alloc_sem locking requirements described inline below. | ||
| 1107 | */ | 1108 | */ |
| 1108 | ssize_t | 1109 | ssize_t |
| 1109 | __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, | 1110 | __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, |
| 1110 | struct block_device *bdev, const struct iovec *iov, loff_t offset, | 1111 | struct block_device *bdev, const struct iovec *iov, loff_t offset, |
| 1111 | unsigned long nr_segs, get_block_t get_block, dio_iodone_t end_io, | 1112 | unsigned long nr_segs, get_block_t get_block, dio_iodone_t end_io, |
| 1112 | int dio_lock_type) | 1113 | int flags) |
| 1113 | { | 1114 | { |
| 1114 | int seg; | 1115 | int seg; |
| 1115 | size_t size; | 1116 | size_t size; |
| @@ -1120,8 +1121,6 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, | |||
| 1120 | ssize_t retval = -EINVAL; | 1121 | ssize_t retval = -EINVAL; |
| 1121 | loff_t end = offset; | 1122 | loff_t end = offset; |
| 1122 | struct dio *dio; | 1123 | struct dio *dio; |
| 1123 | int release_i_mutex = 0; | ||
| 1124 | int acquire_i_mutex = 0; | ||
| 1125 | 1124 | ||
| 1126 | if (rw & WRITE) | 1125 | if (rw & WRITE) |
| 1127 | rw = WRITE_ODIRECT_PLUG; | 1126 | rw = WRITE_ODIRECT_PLUG; |
| @@ -1151,48 +1150,41 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, | |||
| 1151 | } | 1150 | } |
| 1152 | } | 1151 | } |
| 1153 | 1152 | ||
| 1154 | dio = kzalloc(sizeof(*dio), GFP_KERNEL); | 1153 | dio = kmalloc(sizeof(*dio), GFP_KERNEL); |
| 1155 | retval = -ENOMEM; | 1154 | retval = -ENOMEM; |
| 1156 | if (!dio) | 1155 | if (!dio) |
| 1157 | goto out; | 1156 | goto out; |
| 1158 | |||
| 1159 | /* | 1157 | /* |
| 1160 | * For block device access DIO_NO_LOCKING is used, | 1158 | * Believe it or not, zeroing out the page array caused a .5% |
| 1161 | * neither readers nor writers do any locking at all | 1159 | * performance regression in a database benchmark. So, we take |
| 1162 | * For regular files using DIO_LOCKING, | 1160 | * care to only zero out what's needed. |
| 1163 | * readers need to grab i_mutex and i_alloc_sem | ||
| 1164 | * writers need to grab i_alloc_sem only (i_mutex is already held) | ||
| 1165 | * For regular files using DIO_OWN_LOCKING, | ||
| 1166 | * neither readers nor writers take any locks here | ||
| 1167 | */ | 1161 | */ |
| 1168 | dio->lock_type = dio_lock_type; | 1162 | memset(dio, 0, offsetof(struct dio, pages)); |
| 1169 | if (dio_lock_type != DIO_NO_LOCKING) { | 1163 | |
| 1164 | dio->flags = flags; | ||
| 1165 | if (dio->flags & DIO_LOCKING) { | ||
| 1170 | /* watch out for a 0 len io from a tricksy fs */ | 1166 | /* watch out for a 0 len io from a tricksy fs */ |
| 1171 | if (rw == READ && end > offset) { | 1167 | if (rw == READ && end > offset) { |
| 1172 | struct address_space *mapping; | 1168 | struct address_space *mapping = |
| 1169 | iocb->ki_filp->f_mapping; | ||
| 1173 | 1170 | ||
| 1174 | mapping = iocb->ki_filp->f_mapping; | 1171 | /* will be released by direct_io_worker */ |
| 1175 | if (dio_lock_type != DIO_OWN_LOCKING) { | 1172 | mutex_lock(&inode->i_mutex); |
| 1176 | mutex_lock(&inode->i_mutex); | ||
| 1177 | release_i_mutex = 1; | ||
| 1178 | } | ||
| 1179 | 1173 | ||
| 1180 | retval = filemap_write_and_wait_range(mapping, offset, | 1174 | retval = filemap_write_and_wait_range(mapping, offset, |
| 1181 | end - 1); | 1175 | end - 1); |
| 1182 | if (retval) { | 1176 | if (retval) { |
| 1177 | mutex_unlock(&inode->i_mutex); | ||
| 1183 | kfree(dio); | 1178 | kfree(dio); |
| 1184 | goto out; | 1179 | goto out; |
| 1185 | } | 1180 | } |
| 1186 | |||
| 1187 | if (dio_lock_type == DIO_OWN_LOCKING) { | ||
| 1188 | mutex_unlock(&inode->i_mutex); | ||
| 1189 | acquire_i_mutex = 1; | ||
| 1190 | } | ||
| 1191 | } | 1181 | } |
| 1192 | 1182 | ||
| 1193 | if (dio_lock_type == DIO_LOCKING) | 1183 | /* |
| 1194 | /* lockdep: not the owner will release it */ | 1184 | * Will be released at I/O completion, possibly in a |
| 1195 | down_read_non_owner(&inode->i_alloc_sem); | 1185 | * different thread. |
| 1186 | */ | ||
| 1187 | down_read_non_owner(&inode->i_alloc_sem); | ||
| 1196 | } | 1188 | } |
| 1197 | 1189 | ||
| 1198 | /* | 1190 | /* |
| @@ -1210,24 +1202,19 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, | |||
| 1210 | /* | 1202 | /* |
| 1211 | * In case of error extending write may have instantiated a few | 1203 | * In case of error extending write may have instantiated a few |
| 1212 | * blocks outside i_size. Trim these off again for DIO_LOCKING. | 1204 | * blocks outside i_size. Trim these off again for DIO_LOCKING. |
| 1213 | * NOTE: DIO_NO_LOCK/DIO_OWN_LOCK callers have to handle this by | 1205 | * |
| 1214 | * it's own meaner. | 1206 | * NOTE: filesystems with their own locking have to handle this |
| 1207 | * on their own. | ||
| 1215 | */ | 1208 | */ |
| 1216 | if (unlikely(retval < 0 && (rw & WRITE))) { | 1209 | if (flags & DIO_LOCKING) { |
| 1217 | loff_t isize = i_size_read(inode); | 1210 | if (unlikely((rw & WRITE) && retval < 0)) { |
| 1218 | 1211 | loff_t isize = i_size_read(inode); | |
| 1219 | if (end > isize && dio_lock_type == DIO_LOCKING) | 1212 | if (end > isize) |
| 1220 | vmtruncate(inode, isize); | 1213 | vmtruncate(inode, isize); |
| 1214 | } | ||
| 1221 | } | 1215 | } |
| 1222 | 1216 | ||
| 1223 | if (rw == READ && dio_lock_type == DIO_LOCKING) | ||
| 1224 | release_i_mutex = 0; | ||
| 1225 | |||
| 1226 | out: | 1217 | out: |
| 1227 | if (release_i_mutex) | ||
| 1228 | mutex_unlock(&inode->i_mutex); | ||
| 1229 | else if (acquire_i_mutex) | ||
| 1230 | mutex_lock(&inode->i_mutex); | ||
| 1231 | return retval; | 1218 | return retval; |
| 1232 | } | 1219 | } |
| 1233 | EXPORT_SYMBOL(__blockdev_direct_IO); | 1220 | EXPORT_SYMBOL(__blockdev_direct_IO); |
diff --git a/fs/ecryptfs/dentry.c b/fs/ecryptfs/dentry.c index 2dda5ade75bc..8f006a0d6076 100644 --- a/fs/ecryptfs/dentry.c +++ b/fs/ecryptfs/dentry.c | |||
| @@ -62,7 +62,7 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
| 62 | struct inode *lower_inode = | 62 | struct inode *lower_inode = |
| 63 | ecryptfs_inode_to_lower(dentry->d_inode); | 63 | ecryptfs_inode_to_lower(dentry->d_inode); |
| 64 | 64 | ||
| 65 | fsstack_copy_attr_all(dentry->d_inode, lower_inode, NULL); | 65 | fsstack_copy_attr_all(dentry->d_inode, lower_inode); |
| 66 | } | 66 | } |
| 67 | out: | 67 | out: |
| 68 | return rc; | 68 | return rc; |
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 056fed62d0de..429ca0b3ba08 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
| @@ -626,9 +626,9 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 626 | lower_new_dir_dentry->d_inode, lower_new_dentry); | 626 | lower_new_dir_dentry->d_inode, lower_new_dentry); |
| 627 | if (rc) | 627 | if (rc) |
| 628 | goto out_lock; | 628 | goto out_lock; |
| 629 | fsstack_copy_attr_all(new_dir, lower_new_dir_dentry->d_inode, NULL); | 629 | fsstack_copy_attr_all(new_dir, lower_new_dir_dentry->d_inode); |
| 630 | if (new_dir != old_dir) | 630 | if (new_dir != old_dir) |
| 631 | fsstack_copy_attr_all(old_dir, lower_old_dir_dentry->d_inode, NULL); | 631 | fsstack_copy_attr_all(old_dir, lower_old_dir_dentry->d_inode); |
| 632 | out_lock: | 632 | out_lock: |
| 633 | unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry); | 633 | unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry); |
| 634 | dput(lower_new_dentry->d_parent); | 634 | dput(lower_new_dentry->d_parent); |
| @@ -967,7 +967,7 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia) | |||
| 967 | rc = notify_change(lower_dentry, ia); | 967 | rc = notify_change(lower_dentry, ia); |
| 968 | mutex_unlock(&lower_dentry->d_inode->i_mutex); | 968 | mutex_unlock(&lower_dentry->d_inode->i_mutex); |
| 969 | out: | 969 | out: |
| 970 | fsstack_copy_attr_all(inode, lower_inode, NULL); | 970 | fsstack_copy_attr_all(inode, lower_inode); |
| 971 | return rc; | 971 | return rc; |
| 972 | } | 972 | } |
| 973 | 973 | ||
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index c6ac85d6c701..567bc4b9f70a 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
| @@ -35,7 +35,6 @@ | |||
| 35 | #include <linux/key.h> | 35 | #include <linux/key.h> |
| 36 | #include <linux/parser.h> | 36 | #include <linux/parser.h> |
| 37 | #include <linux/fs_stack.h> | 37 | #include <linux/fs_stack.h> |
| 38 | #include <linux/ima.h> | ||
| 39 | #include "ecryptfs_kernel.h" | 38 | #include "ecryptfs_kernel.h" |
| 40 | 39 | ||
| 41 | /** | 40 | /** |
| @@ -119,7 +118,6 @@ int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) | |||
| 119 | const struct cred *cred = current_cred(); | 118 | const struct cred *cred = current_cred(); |
| 120 | struct ecryptfs_inode_info *inode_info = | 119 | struct ecryptfs_inode_info *inode_info = |
| 121 | ecryptfs_inode_to_private(ecryptfs_dentry->d_inode); | 120 | ecryptfs_inode_to_private(ecryptfs_dentry->d_inode); |
| 122 | int opened_lower_file = 0; | ||
| 123 | int rc = 0; | 121 | int rc = 0; |
| 124 | 122 | ||
| 125 | mutex_lock(&inode_info->lower_file_mutex); | 123 | mutex_lock(&inode_info->lower_file_mutex); |
| @@ -136,12 +134,9 @@ int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) | |||
| 136 | "for lower_dentry [0x%p] and lower_mnt [0x%p]; " | 134 | "for lower_dentry [0x%p] and lower_mnt [0x%p]; " |
| 137 | "rc = [%d]\n", lower_dentry, lower_mnt, rc); | 135 | "rc = [%d]\n", lower_dentry, lower_mnt, rc); |
| 138 | inode_info->lower_file = NULL; | 136 | inode_info->lower_file = NULL; |
| 139 | } else | 137 | } |
| 140 | opened_lower_file = 1; | ||
| 141 | } | 138 | } |
| 142 | mutex_unlock(&inode_info->lower_file_mutex); | 139 | mutex_unlock(&inode_info->lower_file_mutex); |
| 143 | if (opened_lower_file) | ||
| 144 | ima_counts_get(inode_info->lower_file); | ||
| 145 | return rc; | 140 | return rc; |
| 146 | } | 141 | } |
| 147 | 142 | ||
| @@ -194,7 +189,7 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry, | |||
| 194 | init_special_inode(inode, lower_inode->i_mode, | 189 | init_special_inode(inode, lower_inode->i_mode, |
| 195 | lower_inode->i_rdev); | 190 | lower_inode->i_rdev); |
| 196 | dentry->d_op = &ecryptfs_dops; | 191 | dentry->d_op = &ecryptfs_dops; |
| 197 | fsstack_copy_attr_all(inode, lower_inode, NULL); | 192 | fsstack_copy_attr_all(inode, lower_inode); |
| 198 | /* This size will be overwritten for real files w/ headers and | 193 | /* This size will be overwritten for real files w/ headers and |
| 199 | * other metadata */ | 194 | * other metadata */ |
| 200 | fsstack_copy_inode_size(inode, lower_inode); | 195 | fsstack_copy_inode_size(inode, lower_inode); |
| @@ -826,7 +826,9 @@ static int de_thread(struct task_struct *tsk) | |||
| 826 | attach_pid(tsk, PIDTYPE_PID, task_pid(leader)); | 826 | attach_pid(tsk, PIDTYPE_PID, task_pid(leader)); |
| 827 | transfer_pid(leader, tsk, PIDTYPE_PGID); | 827 | transfer_pid(leader, tsk, PIDTYPE_PGID); |
| 828 | transfer_pid(leader, tsk, PIDTYPE_SID); | 828 | transfer_pid(leader, tsk, PIDTYPE_SID); |
| 829 | |||
| 829 | list_replace_rcu(&leader->tasks, &tsk->tasks); | 830 | list_replace_rcu(&leader->tasks, &tsk->tasks); |
| 831 | list_replace_init(&leader->sibling, &tsk->sibling); | ||
| 830 | 832 | ||
| 831 | tsk->group_leader = tsk; | 833 | tsk->group_leader = tsk; |
| 832 | leader->group_leader = tsk; | 834 | leader->group_leader = tsk; |
| @@ -923,6 +925,15 @@ char *get_task_comm(char *buf, struct task_struct *tsk) | |||
| 923 | void set_task_comm(struct task_struct *tsk, char *buf) | 925 | void set_task_comm(struct task_struct *tsk, char *buf) |
| 924 | { | 926 | { |
| 925 | task_lock(tsk); | 927 | task_lock(tsk); |
| 928 | |||
| 929 | /* | ||
| 930 | * Threads may access current->comm without holding | ||
| 931 | * the task lock, so write the string carefully. | ||
| 932 | * Readers without a lock may see incomplete new | ||
| 933 | * names but are safe from non-terminating string reads. | ||
| 934 | */ | ||
| 935 | memset(tsk->comm, 0, TASK_COMM_LEN); | ||
| 936 | wmb(); | ||
| 926 | strlcpy(tsk->comm, buf, sizeof(tsk->comm)); | 937 | strlcpy(tsk->comm, buf, sizeof(tsk->comm)); |
| 927 | task_unlock(tsk); | 938 | task_unlock(tsk); |
| 928 | perf_event_comm(tsk); | 939 | perf_event_comm(tsk); |
| @@ -1752,17 +1763,20 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
| 1752 | struct mm_struct *mm = current->mm; | 1763 | struct mm_struct *mm = current->mm; |
| 1753 | struct linux_binfmt * binfmt; | 1764 | struct linux_binfmt * binfmt; |
| 1754 | struct inode * inode; | 1765 | struct inode * inode; |
| 1755 | struct file * file; | ||
| 1756 | const struct cred *old_cred; | 1766 | const struct cred *old_cred; |
| 1757 | struct cred *cred; | 1767 | struct cred *cred; |
| 1758 | int retval = 0; | 1768 | int retval = 0; |
| 1759 | int flag = 0; | 1769 | int flag = 0; |
| 1760 | int ispipe = 0; | 1770 | int ispipe = 0; |
| 1761 | unsigned long core_limit = current->signal->rlim[RLIMIT_CORE].rlim_cur; | ||
| 1762 | char **helper_argv = NULL; | 1771 | char **helper_argv = NULL; |
| 1763 | int helper_argc = 0; | 1772 | int helper_argc = 0; |
| 1764 | int dump_count = 0; | 1773 | int dump_count = 0; |
| 1765 | static atomic_t core_dump_count = ATOMIC_INIT(0); | 1774 | static atomic_t core_dump_count = ATOMIC_INIT(0); |
| 1775 | struct coredump_params cprm = { | ||
| 1776 | .signr = signr, | ||
| 1777 | .regs = regs, | ||
| 1778 | .limit = current->signal->rlim[RLIMIT_CORE].rlim_cur, | ||
| 1779 | }; | ||
| 1766 | 1780 | ||
| 1767 | audit_core_dumps(signr); | 1781 | audit_core_dumps(signr); |
| 1768 | 1782 | ||
| @@ -1818,15 +1832,15 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
| 1818 | ispipe = format_corename(corename, signr); | 1832 | ispipe = format_corename(corename, signr); |
| 1819 | unlock_kernel(); | 1833 | unlock_kernel(); |
| 1820 | 1834 | ||
| 1821 | if ((!ispipe) && (core_limit < binfmt->min_coredump)) | 1835 | if ((!ispipe) && (cprm.limit < binfmt->min_coredump)) |
| 1822 | goto fail_unlock; | 1836 | goto fail_unlock; |
| 1823 | 1837 | ||
| 1824 | if (ispipe) { | 1838 | if (ispipe) { |
| 1825 | if (core_limit == 0) { | 1839 | if (cprm.limit == 0) { |
| 1826 | /* | 1840 | /* |
| 1827 | * Normally core limits are irrelevant to pipes, since | 1841 | * Normally core limits are irrelevant to pipes, since |
| 1828 | * we're not writing to the file system, but we use | 1842 | * we're not writing to the file system, but we use |
| 1829 | * core_limit of 0 here as a speacial value. Any | 1843 | * cprm.limit of 0 here as a speacial value. Any |
| 1830 | * non-zero limit gets set to RLIM_INFINITY below, but | 1844 | * non-zero limit gets set to RLIM_INFINITY below, but |
| 1831 | * a limit of 0 skips the dump. This is a consistent | 1845 | * a limit of 0 skips the dump. This is a consistent |
| 1832 | * way to catch recursive crashes. We can still crash | 1846 | * way to catch recursive crashes. We can still crash |
| @@ -1859,25 +1873,25 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
| 1859 | goto fail_dropcount; | 1873 | goto fail_dropcount; |
| 1860 | } | 1874 | } |
| 1861 | 1875 | ||
| 1862 | core_limit = RLIM_INFINITY; | 1876 | cprm.limit = RLIM_INFINITY; |
| 1863 | 1877 | ||
| 1864 | /* SIGPIPE can happen, but it's just never processed */ | 1878 | /* SIGPIPE can happen, but it's just never processed */ |
| 1865 | if (call_usermodehelper_pipe(helper_argv[0], helper_argv, NULL, | 1879 | if (call_usermodehelper_pipe(helper_argv[0], helper_argv, NULL, |
| 1866 | &file)) { | 1880 | &cprm.file)) { |
| 1867 | printk(KERN_INFO "Core dump to %s pipe failed\n", | 1881 | printk(KERN_INFO "Core dump to %s pipe failed\n", |
| 1868 | corename); | 1882 | corename); |
| 1869 | goto fail_dropcount; | 1883 | goto fail_dropcount; |
| 1870 | } | 1884 | } |
| 1871 | } else | 1885 | } else |
| 1872 | file = filp_open(corename, | 1886 | cprm.file = filp_open(corename, |
| 1873 | O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag, | 1887 | O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag, |
| 1874 | 0600); | 1888 | 0600); |
| 1875 | if (IS_ERR(file)) | 1889 | if (IS_ERR(cprm.file)) |
| 1876 | goto fail_dropcount; | 1890 | goto fail_dropcount; |
| 1877 | inode = file->f_path.dentry->d_inode; | 1891 | inode = cprm.file->f_path.dentry->d_inode; |
| 1878 | if (inode->i_nlink > 1) | 1892 | if (inode->i_nlink > 1) |
| 1879 | goto close_fail; /* multiple links - don't dump */ | 1893 | goto close_fail; /* multiple links - don't dump */ |
| 1880 | if (!ispipe && d_unhashed(file->f_path.dentry)) | 1894 | if (!ispipe && d_unhashed(cprm.file->f_path.dentry)) |
| 1881 | goto close_fail; | 1895 | goto close_fail; |
| 1882 | 1896 | ||
| 1883 | /* AK: actually i see no reason to not allow this for named pipes etc., | 1897 | /* AK: actually i see no reason to not allow this for named pipes etc., |
| @@ -1890,21 +1904,22 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
| 1890 | */ | 1904 | */ |
| 1891 | if (inode->i_uid != current_fsuid()) | 1905 | if (inode->i_uid != current_fsuid()) |
| 1892 | goto close_fail; | 1906 | goto close_fail; |
| 1893 | if (!file->f_op) | 1907 | if (!cprm.file->f_op) |
| 1894 | goto close_fail; | 1908 | goto close_fail; |
| 1895 | if (!file->f_op->write) | 1909 | if (!cprm.file->f_op->write) |
| 1896 | goto close_fail; | 1910 | goto close_fail; |
| 1897 | if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0) | 1911 | if (!ispipe && |
| 1912 | do_truncate(cprm.file->f_path.dentry, 0, 0, cprm.file) != 0) | ||
| 1898 | goto close_fail; | 1913 | goto close_fail; |
| 1899 | 1914 | ||
| 1900 | retval = binfmt->core_dump(signr, regs, file, core_limit); | 1915 | retval = binfmt->core_dump(&cprm); |
| 1901 | 1916 | ||
| 1902 | if (retval) | 1917 | if (retval) |
| 1903 | current->signal->group_exit_code |= 0x80; | 1918 | current->signal->group_exit_code |= 0x80; |
| 1904 | close_fail: | 1919 | close_fail: |
| 1905 | if (ispipe && core_pipe_limit) | 1920 | if (ispipe && core_pipe_limit) |
| 1906 | wait_for_dump_helpers(file); | 1921 | wait_for_dump_helpers(cprm.file); |
| 1907 | filp_close(file, NULL); | 1922 | filp_close(cprm.file, NULL); |
| 1908 | fail_dropcount: | 1923 | fail_dropcount: |
| 1909 | if (dump_count) | 1924 | if (dump_count) |
| 1910 | atomic_dec(&core_dump_count); | 1925 | atomic_dec(&core_dump_count); |
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c index 197c7db583c7..e9e175949a63 100644 --- a/fs/exportfs/expfs.c +++ b/fs/exportfs/expfs.c | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | * and for mapping back from file handles to dentries. | 6 | * and for mapping back from file handles to dentries. |
| 7 | * | 7 | * |
| 8 | * For details on why we do all the strange and hairy things in here | 8 | * For details on why we do all the strange and hairy things in here |
| 9 | * take a look at Documentation/filesystems/Exporting. | 9 | * take a look at Documentation/filesystems/nfs/Exporting. |
| 10 | */ | 10 | */ |
| 11 | #include <linux/exportfs.h> | 11 | #include <linux/exportfs.h> |
| 12 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c index a63d44256a70..a99e54318c3d 100644 --- a/fs/ext2/acl.c +++ b/fs/ext2/acl.c | |||
| @@ -339,12 +339,12 @@ ext2_acl_chmod(struct inode *inode) | |||
| 339 | * Extended attribut handlers | 339 | * Extended attribut handlers |
| 340 | */ | 340 | */ |
| 341 | static size_t | 341 | static size_t |
| 342 | ext2_xattr_list_acl_access(struct inode *inode, char *list, size_t list_size, | 342 | ext2_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_size, |
| 343 | const char *name, size_t name_len) | 343 | const char *name, size_t name_len, int type) |
| 344 | { | 344 | { |
| 345 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); | 345 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); |
| 346 | 346 | ||
| 347 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 347 | if (!test_opt(dentry->d_sb, POSIX_ACL)) |
| 348 | return 0; | 348 | return 0; |
| 349 | if (list && size <= list_size) | 349 | if (list && size <= list_size) |
| 350 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); | 350 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); |
| @@ -352,12 +352,12 @@ ext2_xattr_list_acl_access(struct inode *inode, char *list, size_t list_size, | |||
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | static size_t | 354 | static size_t |
| 355 | ext2_xattr_list_acl_default(struct inode *inode, char *list, size_t list_size, | 355 | ext2_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_size, |
| 356 | const char *name, size_t name_len) | 356 | const char *name, size_t name_len, int type) |
| 357 | { | 357 | { |
| 358 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); | 358 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); |
| 359 | 359 | ||
| 360 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 360 | if (!test_opt(dentry->d_sb, POSIX_ACL)) |
| 361 | return 0; | 361 | return 0; |
| 362 | if (list && size <= list_size) | 362 | if (list && size <= list_size) |
| 363 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); | 363 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); |
| @@ -365,15 +365,18 @@ ext2_xattr_list_acl_default(struct inode *inode, char *list, size_t list_size, | |||
| 365 | } | 365 | } |
| 366 | 366 | ||
| 367 | static int | 367 | static int |
| 368 | ext2_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) | 368 | ext2_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, |
| 369 | size_t size, int type) | ||
| 369 | { | 370 | { |
| 370 | struct posix_acl *acl; | 371 | struct posix_acl *acl; |
| 371 | int error; | 372 | int error; |
| 372 | 373 | ||
| 373 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 374 | if (strcmp(name, "") != 0) |
| 375 | return -EINVAL; | ||
| 376 | if (!test_opt(dentry->d_sb, POSIX_ACL)) | ||
| 374 | return -EOPNOTSUPP; | 377 | return -EOPNOTSUPP; |
| 375 | 378 | ||
| 376 | acl = ext2_get_acl(inode, type); | 379 | acl = ext2_get_acl(dentry->d_inode, type); |
| 377 | if (IS_ERR(acl)) | 380 | if (IS_ERR(acl)) |
| 378 | return PTR_ERR(acl); | 381 | return PTR_ERR(acl); |
| 379 | if (acl == NULL) | 382 | if (acl == NULL) |
| @@ -385,33 +388,17 @@ ext2_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) | |||
| 385 | } | 388 | } |
| 386 | 389 | ||
| 387 | static int | 390 | static int |
| 388 | ext2_xattr_get_acl_access(struct inode *inode, const char *name, | 391 | ext2_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, |
| 389 | void *buffer, size_t size) | 392 | size_t size, int flags, int type) |
| 390 | { | ||
| 391 | if (strcmp(name, "") != 0) | ||
| 392 | return -EINVAL; | ||
| 393 | return ext2_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); | ||
| 394 | } | ||
| 395 | |||
| 396 | static int | ||
| 397 | ext2_xattr_get_acl_default(struct inode *inode, const char *name, | ||
| 398 | void *buffer, size_t size) | ||
| 399 | { | ||
| 400 | if (strcmp(name, "") != 0) | ||
| 401 | return -EINVAL; | ||
| 402 | return ext2_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); | ||
| 403 | } | ||
| 404 | |||
| 405 | static int | ||
| 406 | ext2_xattr_set_acl(struct inode *inode, int type, const void *value, | ||
| 407 | size_t size) | ||
| 408 | { | 393 | { |
| 409 | struct posix_acl *acl; | 394 | struct posix_acl *acl; |
| 410 | int error; | 395 | int error; |
| 411 | 396 | ||
| 412 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 397 | if (strcmp(name, "") != 0) |
| 398 | return -EINVAL; | ||
| 399 | if (!test_opt(dentry->d_sb, POSIX_ACL)) | ||
| 413 | return -EOPNOTSUPP; | 400 | return -EOPNOTSUPP; |
| 414 | if (!is_owner_or_cap(inode)) | 401 | if (!is_owner_or_cap(dentry->d_inode)) |
| 415 | return -EPERM; | 402 | return -EPERM; |
| 416 | 403 | ||
| 417 | if (value) { | 404 | if (value) { |
| @@ -426,41 +413,25 @@ ext2_xattr_set_acl(struct inode *inode, int type, const void *value, | |||
| 426 | } else | 413 | } else |
| 427 | acl = NULL; | 414 | acl = NULL; |
| 428 | 415 | ||
| 429 | error = ext2_set_acl(inode, type, acl); | 416 | error = ext2_set_acl(dentry->d_inode, type, acl); |
| 430 | 417 | ||
| 431 | release_and_out: | 418 | release_and_out: |
| 432 | posix_acl_release(acl); | 419 | posix_acl_release(acl); |
| 433 | return error; | 420 | return error; |
| 434 | } | 421 | } |
| 435 | 422 | ||
| 436 | static int | ||
| 437 | ext2_xattr_set_acl_access(struct inode *inode, const char *name, | ||
| 438 | const void *value, size_t size, int flags) | ||
| 439 | { | ||
| 440 | if (strcmp(name, "") != 0) | ||
| 441 | return -EINVAL; | ||
| 442 | return ext2_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
| 443 | } | ||
| 444 | |||
| 445 | static int | ||
| 446 | ext2_xattr_set_acl_default(struct inode *inode, const char *name, | ||
| 447 | const void *value, size_t size, int flags) | ||
| 448 | { | ||
| 449 | if (strcmp(name, "") != 0) | ||
| 450 | return -EINVAL; | ||
| 451 | return ext2_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
| 452 | } | ||
| 453 | |||
| 454 | struct xattr_handler ext2_xattr_acl_access_handler = { | 423 | struct xattr_handler ext2_xattr_acl_access_handler = { |
| 455 | .prefix = POSIX_ACL_XATTR_ACCESS, | 424 | .prefix = POSIX_ACL_XATTR_ACCESS, |
| 425 | .flags = ACL_TYPE_ACCESS, | ||
| 456 | .list = ext2_xattr_list_acl_access, | 426 | .list = ext2_xattr_list_acl_access, |
| 457 | .get = ext2_xattr_get_acl_access, | 427 | .get = ext2_xattr_get_acl, |
| 458 | .set = ext2_xattr_set_acl_access, | 428 | .set = ext2_xattr_set_acl, |
| 459 | }; | 429 | }; |
| 460 | 430 | ||
| 461 | struct xattr_handler ext2_xattr_acl_default_handler = { | 431 | struct xattr_handler ext2_xattr_acl_default_handler = { |
| 462 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 432 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
| 433 | .flags = ACL_TYPE_DEFAULT, | ||
| 463 | .list = ext2_xattr_list_acl_default, | 434 | .list = ext2_xattr_list_acl_default, |
| 464 | .get = ext2_xattr_get_acl_default, | 435 | .get = ext2_xattr_get_acl, |
| 465 | .set = ext2_xattr_set_acl_default, | 436 | .set = ext2_xattr_set_acl, |
| 466 | }; | 437 | }; |
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c index fc2bd05d3559..7516957273ed 100644 --- a/fs/ext2/dir.c +++ b/fs/ext2/dir.c | |||
| @@ -721,5 +721,5 @@ const struct file_operations ext2_dir_operations = { | |||
| 721 | #ifdef CONFIG_COMPAT | 721 | #ifdef CONFIG_COMPAT |
| 722 | .compat_ioctl = ext2_compat_ioctl, | 722 | .compat_ioctl = ext2_compat_ioctl, |
| 723 | #endif | 723 | #endif |
| 724 | .fsync = simple_fsync, | 724 | .fsync = ext2_fsync, |
| 725 | }; | 725 | }; |
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index da318b0fa637..061914add3cf 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h | |||
| @@ -155,6 +155,7 @@ extern void ext2_write_super (struct super_block *); | |||
| 155 | extern const struct file_operations ext2_dir_operations; | 155 | extern const struct file_operations ext2_dir_operations; |
| 156 | 156 | ||
| 157 | /* file.c */ | 157 | /* file.c */ |
| 158 | extern int ext2_fsync(struct file *file, struct dentry *dentry, int datasync); | ||
| 158 | extern const struct inode_operations ext2_file_inode_operations; | 159 | extern const struct inode_operations ext2_file_inode_operations; |
| 159 | extern const struct file_operations ext2_file_operations; | 160 | extern const struct file_operations ext2_file_operations; |
| 160 | extern const struct file_operations ext2_xip_file_operations; | 161 | extern const struct file_operations ext2_xip_file_operations; |
diff --git a/fs/ext2/file.c b/fs/ext2/file.c index a2f3afd1a1c1..586e3589d4c2 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | */ | 19 | */ |
| 20 | 20 | ||
| 21 | #include <linux/time.h> | 21 | #include <linux/time.h> |
| 22 | #include <linux/pagemap.h> | ||
| 22 | #include "ext2.h" | 23 | #include "ext2.h" |
| 23 | #include "xattr.h" | 24 | #include "xattr.h" |
| 24 | #include "acl.h" | 25 | #include "acl.h" |
| @@ -38,6 +39,22 @@ static int ext2_release_file (struct inode * inode, struct file * filp) | |||
| 38 | return 0; | 39 | return 0; |
| 39 | } | 40 | } |
| 40 | 41 | ||
| 42 | int ext2_fsync(struct file *file, struct dentry *dentry, int datasync) | ||
| 43 | { | ||
| 44 | int ret; | ||
| 45 | struct super_block *sb = dentry->d_inode->i_sb; | ||
| 46 | struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping; | ||
| 47 | |||
| 48 | ret = simple_fsync(file, dentry, datasync); | ||
| 49 | if (ret == -EIO || test_and_clear_bit(AS_EIO, &mapping->flags)) { | ||
| 50 | /* We don't really know where the IO error happened... */ | ||
| 51 | ext2_error(sb, __func__, | ||
| 52 | "detected IO error when writing metadata buffers"); | ||
| 53 | ret = -EIO; | ||
| 54 | } | ||
| 55 | return ret; | ||
| 56 | } | ||
| 57 | |||
| 41 | /* | 58 | /* |
| 42 | * We have mostly NULL's here: the current defaults are ok for | 59 | * We have mostly NULL's here: the current defaults are ok for |
| 43 | * the ext2 filesystem. | 60 | * the ext2 filesystem. |
| @@ -55,7 +72,7 @@ const struct file_operations ext2_file_operations = { | |||
| 55 | .mmap = generic_file_mmap, | 72 | .mmap = generic_file_mmap, |
| 56 | .open = generic_file_open, | 73 | .open = generic_file_open, |
| 57 | .release = ext2_release_file, | 74 | .release = ext2_release_file, |
| 58 | .fsync = simple_fsync, | 75 | .fsync = ext2_fsync, |
| 59 | .splice_read = generic_file_splice_read, | 76 | .splice_read = generic_file_splice_read, |
| 60 | .splice_write = generic_file_splice_write, | 77 | .splice_write = generic_file_splice_write, |
| 61 | }; | 78 | }; |
| @@ -72,7 +89,7 @@ const struct file_operations ext2_xip_file_operations = { | |||
| 72 | .mmap = xip_file_mmap, | 89 | .mmap = xip_file_mmap, |
| 73 | .open = generic_file_open, | 90 | .open = generic_file_open, |
| 74 | .release = ext2_release_file, | 91 | .release = ext2_release_file, |
| 75 | .fsync = simple_fsync, | 92 | .fsync = ext2_fsync, |
| 76 | }; | 93 | }; |
| 77 | #endif | 94 | #endif |
| 78 | 95 | ||
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 1388802b7803..f9cb54a585ce 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
| @@ -1105,9 +1105,30 @@ failed_sbi: | |||
| 1105 | return ret; | 1105 | return ret; |
| 1106 | } | 1106 | } |
| 1107 | 1107 | ||
| 1108 | static void ext2_clear_super_error(struct super_block *sb) | ||
| 1109 | { | ||
| 1110 | struct buffer_head *sbh = EXT2_SB(sb)->s_sbh; | ||
| 1111 | |||
| 1112 | if (buffer_write_io_error(sbh)) { | ||
| 1113 | /* | ||
| 1114 | * Oh, dear. A previous attempt to write the | ||
| 1115 | * superblock failed. This could happen because the | ||
| 1116 | * USB device was yanked out. Or it could happen to | ||
| 1117 | * be a transient write error and maybe the block will | ||
| 1118 | * be remapped. Nothing we can do but to retry the | ||
| 1119 | * write and hope for the best. | ||
| 1120 | */ | ||
| 1121 | printk(KERN_ERR "EXT2-fs: %s previous I/O error to " | ||
| 1122 | "superblock detected", sb->s_id); | ||
| 1123 | clear_buffer_write_io_error(sbh); | ||
| 1124 | set_buffer_uptodate(sbh); | ||
| 1125 | } | ||
| 1126 | } | ||
| 1127 | |||
| 1108 | static void ext2_commit_super (struct super_block * sb, | 1128 | static void ext2_commit_super (struct super_block * sb, |
| 1109 | struct ext2_super_block * es) | 1129 | struct ext2_super_block * es) |
| 1110 | { | 1130 | { |
| 1131 | ext2_clear_super_error(sb); | ||
| 1111 | es->s_wtime = cpu_to_le32(get_seconds()); | 1132 | es->s_wtime = cpu_to_le32(get_seconds()); |
| 1112 | mark_buffer_dirty(EXT2_SB(sb)->s_sbh); | 1133 | mark_buffer_dirty(EXT2_SB(sb)->s_sbh); |
| 1113 | sb->s_dirt = 0; | 1134 | sb->s_dirt = 0; |
| @@ -1115,6 +1136,7 @@ static void ext2_commit_super (struct super_block * sb, | |||
| 1115 | 1136 | ||
| 1116 | static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es) | 1137 | static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es) |
| 1117 | { | 1138 | { |
| 1139 | ext2_clear_super_error(sb); | ||
| 1118 | es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb)); | 1140 | es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb)); |
| 1119 | es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb)); | 1141 | es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb)); |
| 1120 | es->s_wtime = cpu_to_le32(get_seconds()); | 1142 | es->s_wtime = cpu_to_le32(get_seconds()); |
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c index 7913531ec6d5..904f00642f84 100644 --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c | |||
| @@ -60,6 +60,7 @@ | |||
| 60 | #include <linux/mbcache.h> | 60 | #include <linux/mbcache.h> |
| 61 | #include <linux/quotaops.h> | 61 | #include <linux/quotaops.h> |
| 62 | #include <linux/rwsem.h> | 62 | #include <linux/rwsem.h> |
| 63 | #include <linux/security.h> | ||
| 63 | #include "ext2.h" | 64 | #include "ext2.h" |
| 64 | #include "xattr.h" | 65 | #include "xattr.h" |
| 65 | #include "acl.h" | 66 | #include "acl.h" |
| @@ -249,8 +250,9 @@ cleanup: | |||
| 249 | * used / required on success. | 250 | * used / required on success. |
| 250 | */ | 251 | */ |
| 251 | static int | 252 | static int |
| 252 | ext2_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) | 253 | ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
| 253 | { | 254 | { |
| 255 | struct inode *inode = dentry->d_inode; | ||
| 254 | struct buffer_head *bh = NULL; | 256 | struct buffer_head *bh = NULL; |
| 255 | struct ext2_xattr_entry *entry; | 257 | struct ext2_xattr_entry *entry; |
| 256 | char *end; | 258 | char *end; |
| @@ -300,9 +302,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list", | |||
| 300 | ext2_xattr_handler(entry->e_name_index); | 302 | ext2_xattr_handler(entry->e_name_index); |
| 301 | 303 | ||
| 302 | if (handler) { | 304 | if (handler) { |
| 303 | size_t size = handler->list(inode, buffer, rest, | 305 | size_t size = handler->list(dentry, buffer, rest, |
| 304 | entry->e_name, | 306 | entry->e_name, |
| 305 | entry->e_name_len); | 307 | entry->e_name_len, |
| 308 | handler->flags); | ||
| 306 | if (buffer) { | 309 | if (buffer) { |
| 307 | if (size > rest) { | 310 | if (size > rest) { |
| 308 | error = -ERANGE; | 311 | error = -ERANGE; |
| @@ -330,7 +333,7 @@ cleanup: | |||
| 330 | ssize_t | 333 | ssize_t |
| 331 | ext2_listxattr(struct dentry *dentry, char *buffer, size_t size) | 334 | ext2_listxattr(struct dentry *dentry, char *buffer, size_t size) |
| 332 | { | 335 | { |
| 333 | return ext2_xattr_list(dentry->d_inode, buffer, size); | 336 | return ext2_xattr_list(dentry, buffer, size); |
| 334 | } | 337 | } |
| 335 | 338 | ||
| 336 | /* | 339 | /* |
diff --git a/fs/ext2/xattr_security.c b/fs/ext2/xattr_security.c index 70c0dbdcdcb7..c8155845ac05 100644 --- a/fs/ext2/xattr_security.c +++ b/fs/ext2/xattr_security.c | |||
| @@ -11,8 +11,8 @@ | |||
| 11 | #include "xattr.h" | 11 | #include "xattr.h" |
| 12 | 12 | ||
| 13 | static size_t | 13 | static size_t |
| 14 | ext2_xattr_security_list(struct inode *inode, char *list, size_t list_size, | 14 | ext2_xattr_security_list(struct dentry *dentry, char *list, size_t list_size, |
| 15 | const char *name, size_t name_len) | 15 | const char *name, size_t name_len, int type) |
| 16 | { | 16 | { |
| 17 | const int prefix_len = XATTR_SECURITY_PREFIX_LEN; | 17 | const int prefix_len = XATTR_SECURITY_PREFIX_LEN; |
| 18 | const size_t total_len = prefix_len + name_len + 1; | 18 | const size_t total_len = prefix_len + name_len + 1; |
| @@ -26,22 +26,22 @@ ext2_xattr_security_list(struct inode *inode, char *list, size_t list_size, | |||
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | static int | 28 | static int |
| 29 | ext2_xattr_security_get(struct inode *inode, const char *name, | 29 | ext2_xattr_security_get(struct dentry *dentry, const char *name, |
| 30 | void *buffer, size_t size) | 30 | void *buffer, size_t size, int type) |
| 31 | { | 31 | { |
| 32 | if (strcmp(name, "") == 0) | 32 | if (strcmp(name, "") == 0) |
| 33 | return -EINVAL; | 33 | return -EINVAL; |
| 34 | return ext2_xattr_get(inode, EXT2_XATTR_INDEX_SECURITY, name, | 34 | return ext2_xattr_get(dentry->d_inode, EXT2_XATTR_INDEX_SECURITY, name, |
| 35 | buffer, size); | 35 | buffer, size); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | static int | 38 | static int |
| 39 | ext2_xattr_security_set(struct inode *inode, const char *name, | 39 | ext2_xattr_security_set(struct dentry *dentry, const char *name, |
| 40 | const void *value, size_t size, int flags) | 40 | const void *value, size_t size, int flags, int type) |
| 41 | { | 41 | { |
| 42 | if (strcmp(name, "") == 0) | 42 | if (strcmp(name, "") == 0) |
| 43 | return -EINVAL; | 43 | return -EINVAL; |
| 44 | return ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY, name, | 44 | return ext2_xattr_set(dentry->d_inode, EXT2_XATTR_INDEX_SECURITY, name, |
| 45 | value, size, flags); | 45 | value, size, flags); |
| 46 | } | 46 | } |
| 47 | 47 | ||
diff --git a/fs/ext2/xattr_trusted.c b/fs/ext2/xattr_trusted.c index e8219f8eae9f..2a26d71f4771 100644 --- a/fs/ext2/xattr_trusted.c +++ b/fs/ext2/xattr_trusted.c | |||
| @@ -13,8 +13,8 @@ | |||
| 13 | #include "xattr.h" | 13 | #include "xattr.h" |
| 14 | 14 | ||
| 15 | static size_t | 15 | static size_t |
| 16 | ext2_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, | 16 | ext2_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size, |
| 17 | const char *name, size_t name_len) | 17 | const char *name, size_t name_len, int type) |
| 18 | { | 18 | { |
| 19 | const int prefix_len = XATTR_TRUSTED_PREFIX_LEN; | 19 | const int prefix_len = XATTR_TRUSTED_PREFIX_LEN; |
| 20 | const size_t total_len = prefix_len + name_len + 1; | 20 | const size_t total_len = prefix_len + name_len + 1; |
| @@ -31,22 +31,22 @@ ext2_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, | |||
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | static int | 33 | static int |
| 34 | ext2_xattr_trusted_get(struct inode *inode, const char *name, | 34 | ext2_xattr_trusted_get(struct dentry *dentry, const char *name, |
| 35 | void *buffer, size_t size) | 35 | void *buffer, size_t size, int type) |
| 36 | { | 36 | { |
| 37 | if (strcmp(name, "") == 0) | 37 | if (strcmp(name, "") == 0) |
| 38 | return -EINVAL; | 38 | return -EINVAL; |
| 39 | return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name, | 39 | return ext2_xattr_get(dentry->d_inode, EXT2_XATTR_INDEX_TRUSTED, name, |
| 40 | buffer, size); | 40 | buffer, size); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | static int | 43 | static int |
| 44 | ext2_xattr_trusted_set(struct inode *inode, const char *name, | 44 | ext2_xattr_trusted_set(struct dentry *dentry, const char *name, |
| 45 | const void *value, size_t size, int flags) | 45 | const void *value, size_t size, int flags, int type) |
| 46 | { | 46 | { |
| 47 | if (strcmp(name, "") == 0) | 47 | if (strcmp(name, "") == 0) |
| 48 | return -EINVAL; | 48 | return -EINVAL; |
| 49 | return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name, | 49 | return ext2_xattr_set(dentry->d_inode, EXT2_XATTR_INDEX_TRUSTED, name, |
| 50 | value, size, flags); | 50 | value, size, flags); |
| 51 | } | 51 | } |
| 52 | 52 | ||
diff --git a/fs/ext2/xattr_user.c b/fs/ext2/xattr_user.c index 92495d28c62f..3f6caf3684b4 100644 --- a/fs/ext2/xattr_user.c +++ b/fs/ext2/xattr_user.c | |||
| @@ -12,13 +12,13 @@ | |||
| 12 | #include "xattr.h" | 12 | #include "xattr.h" |
| 13 | 13 | ||
| 14 | static size_t | 14 | static size_t |
| 15 | ext2_xattr_user_list(struct inode *inode, char *list, size_t list_size, | 15 | ext2_xattr_user_list(struct dentry *dentry, char *list, size_t list_size, |
| 16 | const char *name, size_t name_len) | 16 | const char *name, size_t name_len, int type) |
| 17 | { | 17 | { |
| 18 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; | 18 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; |
| 19 | const size_t total_len = prefix_len + name_len + 1; | 19 | const size_t total_len = prefix_len + name_len + 1; |
| 20 | 20 | ||
| 21 | if (!test_opt(inode->i_sb, XATTR_USER)) | 21 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
| 22 | return 0; | 22 | return 0; |
| 23 | 23 | ||
| 24 | if (list && total_len <= list_size) { | 24 | if (list && total_len <= list_size) { |
| @@ -30,27 +30,28 @@ ext2_xattr_user_list(struct inode *inode, char *list, size_t list_size, | |||
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | static int | 32 | static int |
| 33 | ext2_xattr_user_get(struct inode *inode, const char *name, | 33 | ext2_xattr_user_get(struct dentry *dentry, const char *name, |
| 34 | void *buffer, size_t size) | 34 | void *buffer, size_t size, int type) |
| 35 | { | 35 | { |
| 36 | if (strcmp(name, "") == 0) | 36 | if (strcmp(name, "") == 0) |
| 37 | return -EINVAL; | 37 | return -EINVAL; |
| 38 | if (!test_opt(inode->i_sb, XATTR_USER)) | 38 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
| 39 | return -EOPNOTSUPP; | 39 | return -EOPNOTSUPP; |
| 40 | return ext2_xattr_get(inode, EXT2_XATTR_INDEX_USER, name, buffer, size); | 40 | return ext2_xattr_get(dentry->d_inode, EXT2_XATTR_INDEX_USER, |
| 41 | name, buffer, size); | ||
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | static int | 44 | static int |
| 44 | ext2_xattr_user_set(struct inode *inode, const char *name, | 45 | ext2_xattr_user_set(struct dentry *dentry, const char *name, |
| 45 | const void *value, size_t size, int flags) | 46 | const void *value, size_t size, int flags, int type) |
| 46 | { | 47 | { |
| 47 | if (strcmp(name, "") == 0) | 48 | if (strcmp(name, "") == 0) |
| 48 | return -EINVAL; | 49 | return -EINVAL; |
| 49 | if (!test_opt(inode->i_sb, XATTR_USER)) | 50 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
| 50 | return -EOPNOTSUPP; | 51 | return -EOPNOTSUPP; |
| 51 | 52 | ||
| 52 | return ext2_xattr_set(inode, EXT2_XATTR_INDEX_USER, name, | 53 | return ext2_xattr_set(dentry->d_inode, EXT2_XATTR_INDEX_USER, |
| 53 | value, size, flags); | 54 | name, value, size, flags); |
| 54 | } | 55 | } |
| 55 | 56 | ||
| 56 | struct xattr_handler ext2_xattr_user_handler = { | 57 | struct xattr_handler ext2_xattr_user_handler = { |
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c index c9b0df376b5f..82ba34158661 100644 --- a/fs/ext3/acl.c +++ b/fs/ext3/acl.c | |||
| @@ -366,12 +366,12 @@ out: | |||
| 366 | * Extended attribute handlers | 366 | * Extended attribute handlers |
| 367 | */ | 367 | */ |
| 368 | static size_t | 368 | static size_t |
| 369 | ext3_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len, | 369 | ext3_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_len, |
| 370 | const char *name, size_t name_len) | 370 | const char *name, size_t name_len, int type) |
| 371 | { | 371 | { |
| 372 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); | 372 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); |
| 373 | 373 | ||
| 374 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 374 | if (!test_opt(dentry->d_sb, POSIX_ACL)) |
| 375 | return 0; | 375 | return 0; |
| 376 | if (list && size <= list_len) | 376 | if (list && size <= list_len) |
| 377 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); | 377 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); |
| @@ -379,12 +379,12 @@ ext3_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len, | |||
| 379 | } | 379 | } |
| 380 | 380 | ||
| 381 | static size_t | 381 | static size_t |
| 382 | ext3_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len, | 382 | ext3_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_len, |
| 383 | const char *name, size_t name_len) | 383 | const char *name, size_t name_len, int type) |
| 384 | { | 384 | { |
| 385 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); | 385 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); |
| 386 | 386 | ||
| 387 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 387 | if (!test_opt(dentry->d_sb, POSIX_ACL)) |
| 388 | return 0; | 388 | return 0; |
| 389 | if (list && size <= list_len) | 389 | if (list && size <= list_len) |
| 390 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); | 390 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); |
| @@ -392,15 +392,18 @@ ext3_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len, | |||
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | static int | 394 | static int |
| 395 | ext3_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) | 395 | ext3_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, |
| 396 | size_t size, int type) | ||
| 396 | { | 397 | { |
| 397 | struct posix_acl *acl; | 398 | struct posix_acl *acl; |
| 398 | int error; | 399 | int error; |
| 399 | 400 | ||
| 400 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 401 | if (strcmp(name, "") != 0) |
| 402 | return -EINVAL; | ||
| 403 | if (!test_opt(dentry->d_sb, POSIX_ACL)) | ||
| 401 | return -EOPNOTSUPP; | 404 | return -EOPNOTSUPP; |
| 402 | 405 | ||
| 403 | acl = ext3_get_acl(inode, type); | 406 | acl = ext3_get_acl(dentry->d_inode, type); |
| 404 | if (IS_ERR(acl)) | 407 | if (IS_ERR(acl)) |
| 405 | return PTR_ERR(acl); | 408 | return PTR_ERR(acl); |
| 406 | if (acl == NULL) | 409 | if (acl == NULL) |
| @@ -412,31 +415,16 @@ ext3_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) | |||
| 412 | } | 415 | } |
| 413 | 416 | ||
| 414 | static int | 417 | static int |
| 415 | ext3_xattr_get_acl_access(struct inode *inode, const char *name, | 418 | ext3_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, |
| 416 | void *buffer, size_t size) | 419 | size_t size, int flags, int type) |
| 417 | { | ||
| 418 | if (strcmp(name, "") != 0) | ||
| 419 | return -EINVAL; | ||
| 420 | return ext3_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); | ||
| 421 | } | ||
| 422 | |||
| 423 | static int | ||
| 424 | ext3_xattr_get_acl_default(struct inode *inode, const char *name, | ||
| 425 | void *buffer, size_t size) | ||
| 426 | { | ||
| 427 | if (strcmp(name, "") != 0) | ||
| 428 | return -EINVAL; | ||
| 429 | return ext3_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); | ||
| 430 | } | ||
| 431 | |||
| 432 | static int | ||
| 433 | ext3_xattr_set_acl(struct inode *inode, int type, const void *value, | ||
| 434 | size_t size) | ||
| 435 | { | 420 | { |
| 421 | struct inode *inode = dentry->d_inode; | ||
| 436 | handle_t *handle; | 422 | handle_t *handle; |
| 437 | struct posix_acl *acl; | 423 | struct posix_acl *acl; |
| 438 | int error, retries = 0; | 424 | int error, retries = 0; |
| 439 | 425 | ||
| 426 | if (strcmp(name, "") != 0) | ||
| 427 | return -EINVAL; | ||
| 440 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 428 | if (!test_opt(inode->i_sb, POSIX_ACL)) |
| 441 | return -EOPNOTSUPP; | 429 | return -EOPNOTSUPP; |
| 442 | if (!is_owner_or_cap(inode)) | 430 | if (!is_owner_or_cap(inode)) |
| @@ -468,34 +456,18 @@ release_and_out: | |||
| 468 | return error; | 456 | return error; |
| 469 | } | 457 | } |
| 470 | 458 | ||
| 471 | static int | ||
| 472 | ext3_xattr_set_acl_access(struct inode *inode, const char *name, | ||
| 473 | const void *value, size_t size, int flags) | ||
| 474 | { | ||
| 475 | if (strcmp(name, "") != 0) | ||
| 476 | return -EINVAL; | ||
| 477 | return ext3_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
| 478 | } | ||
| 479 | |||
| 480 | static int | ||
| 481 | ext3_xattr_set_acl_default(struct inode *inode, const char *name, | ||
| 482 | const void *value, size_t size, int flags) | ||
| 483 | { | ||
| 484 | if (strcmp(name, "") != 0) | ||
| 485 | return -EINVAL; | ||
| 486 | return ext3_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
| 487 | } | ||
| 488 | |||
| 489 | struct xattr_handler ext3_xattr_acl_access_handler = { | 459 | struct xattr_handler ext3_xattr_acl_access_handler = { |
| 490 | .prefix = POSIX_ACL_XATTR_ACCESS, | 460 | .prefix = POSIX_ACL_XATTR_ACCESS, |
| 461 | .flags = ACL_TYPE_ACCESS, | ||
| 491 | .list = ext3_xattr_list_acl_access, | 462 | .list = ext3_xattr_list_acl_access, |
| 492 | .get = ext3_xattr_get_acl_access, | 463 | .get = ext3_xattr_get_acl, |
| 493 | .set = ext3_xattr_set_acl_access, | 464 | .set = ext3_xattr_set_acl, |
| 494 | }; | 465 | }; |
| 495 | 466 | ||
| 496 | struct xattr_handler ext3_xattr_acl_default_handler = { | 467 | struct xattr_handler ext3_xattr_acl_default_handler = { |
| 497 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 468 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
| 469 | .flags = ACL_TYPE_DEFAULT, | ||
| 498 | .list = ext3_xattr_list_acl_default, | 470 | .list = ext3_xattr_list_acl_default, |
| 499 | .get = ext3_xattr_get_acl_default, | 471 | .get = ext3_xattr_get_acl, |
| 500 | .set = ext3_xattr_set_acl_default, | 472 | .set = ext3_xattr_set_acl, |
| 501 | }; | 473 | }; |
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c index 387d92d00b97..66895ccf76c7 100644 --- a/fs/ext3/xattr.c +++ b/fs/ext3/xattr.c | |||
| @@ -99,7 +99,7 @@ static struct buffer_head *ext3_xattr_cache_find(struct inode *, | |||
| 99 | struct mb_cache_entry **); | 99 | struct mb_cache_entry **); |
| 100 | static void ext3_xattr_rehash(struct ext3_xattr_header *, | 100 | static void ext3_xattr_rehash(struct ext3_xattr_header *, |
| 101 | struct ext3_xattr_entry *); | 101 | struct ext3_xattr_entry *); |
| 102 | static int ext3_xattr_list(struct inode *inode, char *buffer, | 102 | static int ext3_xattr_list(struct dentry *dentry, char *buffer, |
| 103 | size_t buffer_size); | 103 | size_t buffer_size); |
| 104 | 104 | ||
| 105 | static struct mb_cache *ext3_xattr_cache; | 105 | static struct mb_cache *ext3_xattr_cache; |
| @@ -147,7 +147,7 @@ ext3_xattr_handler(int name_index) | |||
| 147 | ssize_t | 147 | ssize_t |
| 148 | ext3_listxattr(struct dentry *dentry, char *buffer, size_t size) | 148 | ext3_listxattr(struct dentry *dentry, char *buffer, size_t size) |
| 149 | { | 149 | { |
| 150 | return ext3_xattr_list(dentry->d_inode, buffer, size); | 150 | return ext3_xattr_list(dentry, buffer, size); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | static int | 153 | static int |
| @@ -332,7 +332,7 @@ ext3_xattr_get(struct inode *inode, int name_index, const char *name, | |||
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | static int | 334 | static int |
| 335 | ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry, | 335 | ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry, |
| 336 | char *buffer, size_t buffer_size) | 336 | char *buffer, size_t buffer_size) |
| 337 | { | 337 | { |
| 338 | size_t rest = buffer_size; | 338 | size_t rest = buffer_size; |
| @@ -342,9 +342,10 @@ ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry, | |||
| 342 | ext3_xattr_handler(entry->e_name_index); | 342 | ext3_xattr_handler(entry->e_name_index); |
| 343 | 343 | ||
| 344 | if (handler) { | 344 | if (handler) { |
| 345 | size_t size = handler->list(inode, buffer, rest, | 345 | size_t size = handler->list(dentry, buffer, rest, |
| 346 | entry->e_name, | 346 | entry->e_name, |
| 347 | entry->e_name_len); | 347 | entry->e_name_len, |
| 348 | handler->flags); | ||
| 348 | if (buffer) { | 349 | if (buffer) { |
| 349 | if (size > rest) | 350 | if (size > rest) |
| 350 | return -ERANGE; | 351 | return -ERANGE; |
| @@ -357,8 +358,9 @@ ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry, | |||
| 357 | } | 358 | } |
| 358 | 359 | ||
| 359 | static int | 360 | static int |
| 360 | ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) | 361 | ext3_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
| 361 | { | 362 | { |
| 363 | struct inode *inode = dentry->d_inode; | ||
| 362 | struct buffer_head *bh = NULL; | 364 | struct buffer_head *bh = NULL; |
| 363 | int error; | 365 | int error; |
| 364 | 366 | ||
| @@ -383,7 +385,7 @@ ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
| 383 | goto cleanup; | 385 | goto cleanup; |
| 384 | } | 386 | } |
| 385 | ext3_xattr_cache_insert(bh); | 387 | ext3_xattr_cache_insert(bh); |
| 386 | error = ext3_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size); | 388 | error = ext3_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); |
| 387 | 389 | ||
| 388 | cleanup: | 390 | cleanup: |
| 389 | brelse(bh); | 391 | brelse(bh); |
| @@ -392,8 +394,9 @@ cleanup: | |||
| 392 | } | 394 | } |
| 393 | 395 | ||
| 394 | static int | 396 | static int |
| 395 | ext3_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) | 397 | ext3_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
| 396 | { | 398 | { |
| 399 | struct inode *inode = dentry->d_inode; | ||
| 397 | struct ext3_xattr_ibody_header *header; | 400 | struct ext3_xattr_ibody_header *header; |
| 398 | struct ext3_inode *raw_inode; | 401 | struct ext3_inode *raw_inode; |
| 399 | struct ext3_iloc iloc; | 402 | struct ext3_iloc iloc; |
| @@ -411,7 +414,7 @@ ext3_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
| 411 | error = ext3_xattr_check_names(IFIRST(header), end); | 414 | error = ext3_xattr_check_names(IFIRST(header), end); |
| 412 | if (error) | 415 | if (error) |
| 413 | goto cleanup; | 416 | goto cleanup; |
| 414 | error = ext3_xattr_list_entries(inode, IFIRST(header), | 417 | error = ext3_xattr_list_entries(dentry, IFIRST(header), |
| 415 | buffer, buffer_size); | 418 | buffer, buffer_size); |
| 416 | 419 | ||
| 417 | cleanup: | 420 | cleanup: |
| @@ -430,12 +433,12 @@ cleanup: | |||
| 430 | * used / required on success. | 433 | * used / required on success. |
| 431 | */ | 434 | */ |
| 432 | static int | 435 | static int |
| 433 | ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) | 436 | ext3_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
| 434 | { | 437 | { |
| 435 | int i_error, b_error; | 438 | int i_error, b_error; |
| 436 | 439 | ||
| 437 | down_read(&EXT3_I(inode)->xattr_sem); | 440 | down_read(&EXT3_I(dentry->d_inode)->xattr_sem); |
| 438 | i_error = ext3_xattr_ibody_list(inode, buffer, buffer_size); | 441 | i_error = ext3_xattr_ibody_list(dentry, buffer, buffer_size); |
| 439 | if (i_error < 0) { | 442 | if (i_error < 0) { |
| 440 | b_error = 0; | 443 | b_error = 0; |
| 441 | } else { | 444 | } else { |
| @@ -443,11 +446,11 @@ ext3_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
| 443 | buffer += i_error; | 446 | buffer += i_error; |
| 444 | buffer_size -= i_error; | 447 | buffer_size -= i_error; |
| 445 | } | 448 | } |
| 446 | b_error = ext3_xattr_block_list(inode, buffer, buffer_size); | 449 | b_error = ext3_xattr_block_list(dentry, buffer, buffer_size); |
| 447 | if (b_error < 0) | 450 | if (b_error < 0) |
| 448 | i_error = 0; | 451 | i_error = 0; |
| 449 | } | 452 | } |
| 450 | up_read(&EXT3_I(inode)->xattr_sem); | 453 | up_read(&EXT3_I(dentry->d_inode)->xattr_sem); |
| 451 | return i_error + b_error; | 454 | return i_error + b_error; |
| 452 | } | 455 | } |
| 453 | 456 | ||
diff --git a/fs/ext3/xattr_security.c b/fs/ext3/xattr_security.c index 37b81097bdf2..474348788dd9 100644 --- a/fs/ext3/xattr_security.c +++ b/fs/ext3/xattr_security.c | |||
| @@ -12,8 +12,8 @@ | |||
| 12 | #include "xattr.h" | 12 | #include "xattr.h" |
| 13 | 13 | ||
| 14 | static size_t | 14 | static size_t |
| 15 | ext3_xattr_security_list(struct inode *inode, char *list, size_t list_size, | 15 | ext3_xattr_security_list(struct dentry *dentry, char *list, size_t list_size, |
| 16 | const char *name, size_t name_len) | 16 | const char *name, size_t name_len, int type) |
| 17 | { | 17 | { |
| 18 | const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN; | 18 | const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN; |
| 19 | const size_t total_len = prefix_len + name_len + 1; | 19 | const size_t total_len = prefix_len + name_len + 1; |
| @@ -28,23 +28,23 @@ ext3_xattr_security_list(struct inode *inode, char *list, size_t list_size, | |||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | static int | 30 | static int |
| 31 | ext3_xattr_security_get(struct inode *inode, const char *name, | 31 | ext3_xattr_security_get(struct dentry *dentry, const char *name, |
| 32 | void *buffer, size_t size) | 32 | void *buffer, size_t size, int type) |
| 33 | { | 33 | { |
| 34 | if (strcmp(name, "") == 0) | 34 | if (strcmp(name, "") == 0) |
| 35 | return -EINVAL; | 35 | return -EINVAL; |
| 36 | return ext3_xattr_get(inode, EXT3_XATTR_INDEX_SECURITY, name, | 36 | return ext3_xattr_get(dentry->d_inode, EXT3_XATTR_INDEX_SECURITY, |
| 37 | buffer, size); | 37 | name, buffer, size); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | static int | 40 | static int |
| 41 | ext3_xattr_security_set(struct inode *inode, const char *name, | 41 | ext3_xattr_security_set(struct dentry *dentry, const char *name, |
| 42 | const void *value, size_t size, int flags) | 42 | const void *value, size_t size, int flags, int type) |
| 43 | { | 43 | { |
| 44 | if (strcmp(name, "") == 0) | 44 | if (strcmp(name, "") == 0) |
| 45 | return -EINVAL; | 45 | return -EINVAL; |
| 46 | return ext3_xattr_set(inode, EXT3_XATTR_INDEX_SECURITY, name, | 46 | return ext3_xattr_set(dentry->d_inode, EXT3_XATTR_INDEX_SECURITY, |
| 47 | value, size, flags); | 47 | name, value, size, flags); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | int | 50 | int |
diff --git a/fs/ext3/xattr_trusted.c b/fs/ext3/xattr_trusted.c index c7c41a410c4b..e5562845ed96 100644 --- a/fs/ext3/xattr_trusted.c +++ b/fs/ext3/xattr_trusted.c | |||
| @@ -14,8 +14,8 @@ | |||
| 14 | #include "xattr.h" | 14 | #include "xattr.h" |
| 15 | 15 | ||
| 16 | static size_t | 16 | static size_t |
| 17 | ext3_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, | 17 | ext3_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size, |
| 18 | const char *name, size_t name_len) | 18 | const char *name, size_t name_len, int type) |
| 19 | { | 19 | { |
| 20 | const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; | 20 | const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; |
| 21 | const size_t total_len = prefix_len + name_len + 1; | 21 | const size_t total_len = prefix_len + name_len + 1; |
| @@ -32,22 +32,22 @@ ext3_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, | |||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | static int | 34 | static int |
| 35 | ext3_xattr_trusted_get(struct inode *inode, const char *name, | 35 | ext3_xattr_trusted_get(struct dentry *dentry, const char *name, |
| 36 | void *buffer, size_t size) | 36 | void *buffer, size_t size, int type) |
| 37 | { | 37 | { |
| 38 | if (strcmp(name, "") == 0) | 38 | if (strcmp(name, "") == 0) |
| 39 | return -EINVAL; | 39 | return -EINVAL; |
| 40 | return ext3_xattr_get(inode, EXT3_XATTR_INDEX_TRUSTED, name, | 40 | return ext3_xattr_get(dentry->d_inode, EXT3_XATTR_INDEX_TRUSTED, |
| 41 | buffer, size); | 41 | name, buffer, size); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | static int | 44 | static int |
| 45 | ext3_xattr_trusted_set(struct inode *inode, const char *name, | 45 | ext3_xattr_trusted_set(struct dentry *dentry, const char *name, |
| 46 | const void *value, size_t size, int flags) | 46 | const void *value, size_t size, int flags, int type) |
| 47 | { | 47 | { |
| 48 | if (strcmp(name, "") == 0) | 48 | if (strcmp(name, "") == 0) |
| 49 | return -EINVAL; | 49 | return -EINVAL; |
| 50 | return ext3_xattr_set(inode, EXT3_XATTR_INDEX_TRUSTED, name, | 50 | return ext3_xattr_set(dentry->d_inode, EXT3_XATTR_INDEX_TRUSTED, name, |
| 51 | value, size, flags); | 51 | value, size, flags); |
| 52 | } | 52 | } |
| 53 | 53 | ||
diff --git a/fs/ext3/xattr_user.c b/fs/ext3/xattr_user.c index 430fe63b31b3..3bcfe9ee0a68 100644 --- a/fs/ext3/xattr_user.c +++ b/fs/ext3/xattr_user.c | |||
| @@ -13,13 +13,13 @@ | |||
| 13 | #include "xattr.h" | 13 | #include "xattr.h" |
| 14 | 14 | ||
| 15 | static size_t | 15 | static size_t |
| 16 | ext3_xattr_user_list(struct inode *inode, char *list, size_t list_size, | 16 | ext3_xattr_user_list(struct dentry *dentry, char *list, size_t list_size, |
| 17 | const char *name, size_t name_len) | 17 | const char *name, size_t name_len, int type) |
| 18 | { | 18 | { |
| 19 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; | 19 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; |
| 20 | const size_t total_len = prefix_len + name_len + 1; | 20 | const size_t total_len = prefix_len + name_len + 1; |
| 21 | 21 | ||
| 22 | if (!test_opt(inode->i_sb, XATTR_USER)) | 22 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
| 23 | return 0; | 23 | return 0; |
| 24 | 24 | ||
| 25 | if (list && total_len <= list_size) { | 25 | if (list && total_len <= list_size) { |
| @@ -31,26 +31,27 @@ ext3_xattr_user_list(struct inode *inode, char *list, size_t list_size, | |||
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | static int | 33 | static int |
| 34 | ext3_xattr_user_get(struct inode *inode, const char *name, | 34 | ext3_xattr_user_get(struct dentry *dentry, const char *name, void *buffer, |
| 35 | void *buffer, size_t size) | 35 | size_t size, int type) |
| 36 | { | 36 | { |
| 37 | if (strcmp(name, "") == 0) | 37 | if (strcmp(name, "") == 0) |
| 38 | return -EINVAL; | 38 | return -EINVAL; |
| 39 | if (!test_opt(inode->i_sb, XATTR_USER)) | 39 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
| 40 | return -EOPNOTSUPP; | 40 | return -EOPNOTSUPP; |
| 41 | return ext3_xattr_get(inode, EXT3_XATTR_INDEX_USER, name, buffer, size); | 41 | return ext3_xattr_get(dentry->d_inode, EXT3_XATTR_INDEX_USER, |
| 42 | name, buffer, size); | ||
| 42 | } | 43 | } |
| 43 | 44 | ||
| 44 | static int | 45 | static int |
| 45 | ext3_xattr_user_set(struct inode *inode, const char *name, | 46 | ext3_xattr_user_set(struct dentry *dentry, const char *name, |
| 46 | const void *value, size_t size, int flags) | 47 | const void *value, size_t size, int flags, int type) |
| 47 | { | 48 | { |
| 48 | if (strcmp(name, "") == 0) | 49 | if (strcmp(name, "") == 0) |
| 49 | return -EINVAL; | 50 | return -EINVAL; |
| 50 | if (!test_opt(inode->i_sb, XATTR_USER)) | 51 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
| 51 | return -EOPNOTSUPP; | 52 | return -EOPNOTSUPP; |
| 52 | return ext3_xattr_set(inode, EXT3_XATTR_INDEX_USER, name, | 53 | return ext3_xattr_set(dentry->d_inode, EXT3_XATTR_INDEX_USER, |
| 53 | value, size, flags); | 54 | name, value, size, flags); |
| 54 | } | 55 | } |
| 55 | 56 | ||
| 56 | struct xattr_handler ext3_xattr_user_handler = { | 57 | struct xattr_handler ext3_xattr_user_handler = { |
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c index 0df88b2a69b0..8a2a29d35a6f 100644 --- a/fs/ext4/acl.c +++ b/fs/ext4/acl.c | |||
| @@ -364,12 +364,12 @@ out: | |||
| 364 | * Extended attribute handlers | 364 | * Extended attribute handlers |
| 365 | */ | 365 | */ |
| 366 | static size_t | 366 | static size_t |
| 367 | ext4_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len, | 367 | ext4_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_len, |
| 368 | const char *name, size_t name_len) | 368 | const char *name, size_t name_len, int type) |
| 369 | { | 369 | { |
| 370 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); | 370 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); |
| 371 | 371 | ||
| 372 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 372 | if (!test_opt(dentry->d_sb, POSIX_ACL)) |
| 373 | return 0; | 373 | return 0; |
| 374 | if (list && size <= list_len) | 374 | if (list && size <= list_len) |
| 375 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); | 375 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); |
| @@ -377,12 +377,12 @@ ext4_xattr_list_acl_access(struct inode *inode, char *list, size_t list_len, | |||
| 377 | } | 377 | } |
| 378 | 378 | ||
| 379 | static size_t | 379 | static size_t |
| 380 | ext4_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len, | 380 | ext4_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_len, |
| 381 | const char *name, size_t name_len) | 381 | const char *name, size_t name_len, int type) |
| 382 | { | 382 | { |
| 383 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); | 383 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); |
| 384 | 384 | ||
| 385 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 385 | if (!test_opt(dentry->d_sb, POSIX_ACL)) |
| 386 | return 0; | 386 | return 0; |
| 387 | if (list && size <= list_len) | 387 | if (list && size <= list_len) |
| 388 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); | 388 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); |
| @@ -390,15 +390,18 @@ ext4_xattr_list_acl_default(struct inode *inode, char *list, size_t list_len, | |||
| 390 | } | 390 | } |
| 391 | 391 | ||
| 392 | static int | 392 | static int |
| 393 | ext4_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) | 393 | ext4_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, |
| 394 | size_t size, int type) | ||
| 394 | { | 395 | { |
| 395 | struct posix_acl *acl; | 396 | struct posix_acl *acl; |
| 396 | int error; | 397 | int error; |
| 397 | 398 | ||
| 398 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 399 | if (strcmp(name, "") != 0) |
| 400 | return -EINVAL; | ||
| 401 | if (!test_opt(dentry->d_sb, POSIX_ACL)) | ||
| 399 | return -EOPNOTSUPP; | 402 | return -EOPNOTSUPP; |
| 400 | 403 | ||
| 401 | acl = ext4_get_acl(inode, type); | 404 | acl = ext4_get_acl(dentry->d_inode, type); |
| 402 | if (IS_ERR(acl)) | 405 | if (IS_ERR(acl)) |
| 403 | return PTR_ERR(acl); | 406 | return PTR_ERR(acl); |
| 404 | if (acl == NULL) | 407 | if (acl == NULL) |
| @@ -410,31 +413,16 @@ ext4_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) | |||
| 410 | } | 413 | } |
| 411 | 414 | ||
| 412 | static int | 415 | static int |
| 413 | ext4_xattr_get_acl_access(struct inode *inode, const char *name, | 416 | ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value, |
| 414 | void *buffer, size_t size) | 417 | size_t size, int flags, int type) |
| 415 | { | ||
| 416 | if (strcmp(name, "") != 0) | ||
| 417 | return -EINVAL; | ||
| 418 | return ext4_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); | ||
| 419 | } | ||
| 420 | |||
| 421 | static int | ||
| 422 | ext4_xattr_get_acl_default(struct inode *inode, const char *name, | ||
| 423 | void *buffer, size_t size) | ||
| 424 | { | ||
| 425 | if (strcmp(name, "") != 0) | ||
| 426 | return -EINVAL; | ||
| 427 | return ext4_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); | ||
| 428 | } | ||
| 429 | |||
| 430 | static int | ||
| 431 | ext4_xattr_set_acl(struct inode *inode, int type, const void *value, | ||
| 432 | size_t size) | ||
| 433 | { | 418 | { |
| 419 | struct inode *inode = dentry->d_inode; | ||
| 434 | handle_t *handle; | 420 | handle_t *handle; |
| 435 | struct posix_acl *acl; | 421 | struct posix_acl *acl; |
| 436 | int error, retries = 0; | 422 | int error, retries = 0; |
| 437 | 423 | ||
| 424 | if (strcmp(name, "") != 0) | ||
| 425 | return -EINVAL; | ||
| 438 | if (!test_opt(inode->i_sb, POSIX_ACL)) | 426 | if (!test_opt(inode->i_sb, POSIX_ACL)) |
| 439 | return -EOPNOTSUPP; | 427 | return -EOPNOTSUPP; |
| 440 | if (!is_owner_or_cap(inode)) | 428 | if (!is_owner_or_cap(inode)) |
| @@ -466,34 +454,18 @@ release_and_out: | |||
| 466 | return error; | 454 | return error; |
| 467 | } | 455 | } |
| 468 | 456 | ||
| 469 | static int | ||
| 470 | ext4_xattr_set_acl_access(struct inode *inode, const char *name, | ||
| 471 | const void *value, size_t size, int flags) | ||
| 472 | { | ||
| 473 | if (strcmp(name, "") != 0) | ||
| 474 | return -EINVAL; | ||
| 475 | return ext4_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
| 476 | } | ||
| 477 | |||
| 478 | static int | ||
| 479 | ext4_xattr_set_acl_default(struct inode *inode, const char *name, | ||
| 480 | const void *value, size_t size, int flags) | ||
| 481 | { | ||
| 482 | if (strcmp(name, "") != 0) | ||
| 483 | return -EINVAL; | ||
| 484 | return ext4_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
| 485 | } | ||
| 486 | |||
| 487 | struct xattr_handler ext4_xattr_acl_access_handler = { | 457 | struct xattr_handler ext4_xattr_acl_access_handler = { |
| 488 | .prefix = POSIX_ACL_XATTR_ACCESS, | 458 | .prefix = POSIX_ACL_XATTR_ACCESS, |
| 459 | .flags = ACL_TYPE_ACCESS, | ||
| 489 | .list = ext4_xattr_list_acl_access, | 460 | .list = ext4_xattr_list_acl_access, |
| 490 | .get = ext4_xattr_get_acl_access, | 461 | .get = ext4_xattr_get_acl, |
| 491 | .set = ext4_xattr_set_acl_access, | 462 | .set = ext4_xattr_set_acl, |
| 492 | }; | 463 | }; |
| 493 | 464 | ||
| 494 | struct xattr_handler ext4_xattr_acl_default_handler = { | 465 | struct xattr_handler ext4_xattr_acl_default_handler = { |
| 495 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 466 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
| 467 | .flags = ACL_TYPE_DEFAULT, | ||
| 496 | .list = ext4_xattr_list_acl_default, | 468 | .list = ext4_xattr_list_acl_default, |
| 497 | .get = ext4_xattr_get_acl_default, | 469 | .get = ext4_xattr_get_acl, |
| 498 | .set = ext4_xattr_set_acl_default, | 470 | .set = ext4_xattr_set_acl, |
| 499 | }; | 471 | }; |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index c1e19d5b5985..b1fd3daadc9c 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
| @@ -3955,7 +3955,7 @@ static void ext4_mb_group_or_file(struct ext4_allocation_context *ac) | |||
| 3955 | * per cpu locality group is to reduce the contention between block | 3955 | * per cpu locality group is to reduce the contention between block |
| 3956 | * request from multiple CPUs. | 3956 | * request from multiple CPUs. |
| 3957 | */ | 3957 | */ |
| 3958 | ac->ac_lg = per_cpu_ptr(sbi->s_locality_groups, raw_smp_processor_id()); | 3958 | ac->ac_lg = __this_cpu_ptr(sbi->s_locality_groups); |
| 3959 | 3959 | ||
| 3960 | /* we're going to use group allocation */ | 3960 | /* we're going to use group allocation */ |
| 3961 | ac->ac_flags |= EXT4_MB_HINT_GROUP_ALLOC; | 3961 | ac->ac_flags |= EXT4_MB_HINT_GROUP_ALLOC; |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 768c111a77ec..827bde1f2594 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
| @@ -2137,11 +2137,8 @@ static int parse_strtoul(const char *buf, | |||
| 2137 | { | 2137 | { |
| 2138 | char *endp; | 2138 | char *endp; |
| 2139 | 2139 | ||
| 2140 | while (*buf && isspace(*buf)) | 2140 | *value = simple_strtoul(skip_spaces(buf), &endp, 0); |
| 2141 | buf++; | 2141 | endp = skip_spaces(endp); |
| 2142 | *value = simple_strtoul(buf, &endp, 0); | ||
| 2143 | while (*endp && isspace(*endp)) | ||
| 2144 | endp++; | ||
| 2145 | if (*endp || *value > max) | 2142 | if (*endp || *value > max) |
| 2146 | return -EINVAL; | 2143 | return -EINVAL; |
| 2147 | 2144 | ||
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 910bf9a59cb3..83218bebbc7c 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
| @@ -92,7 +92,7 @@ static struct buffer_head *ext4_xattr_cache_find(struct inode *, | |||
| 92 | struct mb_cache_entry **); | 92 | struct mb_cache_entry **); |
| 93 | static void ext4_xattr_rehash(struct ext4_xattr_header *, | 93 | static void ext4_xattr_rehash(struct ext4_xattr_header *, |
| 94 | struct ext4_xattr_entry *); | 94 | struct ext4_xattr_entry *); |
| 95 | static int ext4_xattr_list(struct inode *inode, char *buffer, | 95 | static int ext4_xattr_list(struct dentry *dentry, char *buffer, |
| 96 | size_t buffer_size); | 96 | size_t buffer_size); |
| 97 | 97 | ||
| 98 | static struct mb_cache *ext4_xattr_cache; | 98 | static struct mb_cache *ext4_xattr_cache; |
| @@ -140,7 +140,7 @@ ext4_xattr_handler(int name_index) | |||
| 140 | ssize_t | 140 | ssize_t |
| 141 | ext4_listxattr(struct dentry *dentry, char *buffer, size_t size) | 141 | ext4_listxattr(struct dentry *dentry, char *buffer, size_t size) |
| 142 | { | 142 | { |
| 143 | return ext4_xattr_list(dentry->d_inode, buffer, size); | 143 | return ext4_xattr_list(dentry, buffer, size); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | static int | 146 | static int |
| @@ -325,7 +325,7 @@ ext4_xattr_get(struct inode *inode, int name_index, const char *name, | |||
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | static int | 327 | static int |
| 328 | ext4_xattr_list_entries(struct inode *inode, struct ext4_xattr_entry *entry, | 328 | ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry, |
| 329 | char *buffer, size_t buffer_size) | 329 | char *buffer, size_t buffer_size) |
| 330 | { | 330 | { |
| 331 | size_t rest = buffer_size; | 331 | size_t rest = buffer_size; |
| @@ -335,9 +335,10 @@ ext4_xattr_list_entries(struct inode *inode, struct ext4_xattr_entry *entry, | |||
| 335 | ext4_xattr_handler(entry->e_name_index); | 335 | ext4_xattr_handler(entry->e_name_index); |
| 336 | 336 | ||
| 337 | if (handler) { | 337 | if (handler) { |
| 338 | size_t size = handler->list(inode, buffer, rest, | 338 | size_t size = handler->list(dentry, buffer, rest, |
| 339 | entry->e_name, | 339 | entry->e_name, |
| 340 | entry->e_name_len); | 340 | entry->e_name_len, |
| 341 | handler->flags); | ||
| 341 | if (buffer) { | 342 | if (buffer) { |
| 342 | if (size > rest) | 343 | if (size > rest) |
| 343 | return -ERANGE; | 344 | return -ERANGE; |
| @@ -350,8 +351,9 @@ ext4_xattr_list_entries(struct inode *inode, struct ext4_xattr_entry *entry, | |||
| 350 | } | 351 | } |
| 351 | 352 | ||
| 352 | static int | 353 | static int |
| 353 | ext4_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) | 354 | ext4_xattr_block_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
| 354 | { | 355 | { |
| 356 | struct inode *inode = dentry->d_inode; | ||
| 355 | struct buffer_head *bh = NULL; | 357 | struct buffer_head *bh = NULL; |
| 356 | int error; | 358 | int error; |
| 357 | 359 | ||
| @@ -376,7 +378,7 @@ ext4_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
| 376 | goto cleanup; | 378 | goto cleanup; |
| 377 | } | 379 | } |
| 378 | ext4_xattr_cache_insert(bh); | 380 | ext4_xattr_cache_insert(bh); |
| 379 | error = ext4_xattr_list_entries(inode, BFIRST(bh), buffer, buffer_size); | 381 | error = ext4_xattr_list_entries(dentry, BFIRST(bh), buffer, buffer_size); |
| 380 | 382 | ||
| 381 | cleanup: | 383 | cleanup: |
| 382 | brelse(bh); | 384 | brelse(bh); |
| @@ -385,8 +387,9 @@ cleanup: | |||
| 385 | } | 387 | } |
| 386 | 388 | ||
| 387 | static int | 389 | static int |
| 388 | ext4_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) | 390 | ext4_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
| 389 | { | 391 | { |
| 392 | struct inode *inode = dentry->d_inode; | ||
| 390 | struct ext4_xattr_ibody_header *header; | 393 | struct ext4_xattr_ibody_header *header; |
| 391 | struct ext4_inode *raw_inode; | 394 | struct ext4_inode *raw_inode; |
| 392 | struct ext4_iloc iloc; | 395 | struct ext4_iloc iloc; |
| @@ -404,7 +407,7 @@ ext4_xattr_ibody_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
| 404 | error = ext4_xattr_check_names(IFIRST(header), end); | 407 | error = ext4_xattr_check_names(IFIRST(header), end); |
| 405 | if (error) | 408 | if (error) |
| 406 | goto cleanup; | 409 | goto cleanup; |
| 407 | error = ext4_xattr_list_entries(inode, IFIRST(header), | 410 | error = ext4_xattr_list_entries(dentry, IFIRST(header), |
| 408 | buffer, buffer_size); | 411 | buffer, buffer_size); |
| 409 | 412 | ||
| 410 | cleanup: | 413 | cleanup: |
| @@ -423,12 +426,12 @@ cleanup: | |||
| 423 | * used / required on success. | 426 | * used / required on success. |
| 424 | */ | 427 | */ |
| 425 | static int | 428 | static int |
| 426 | ext4_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) | 429 | ext4_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) |
| 427 | { | 430 | { |
| 428 | int i_error, b_error; | 431 | int i_error, b_error; |
| 429 | 432 | ||
| 430 | down_read(&EXT4_I(inode)->xattr_sem); | 433 | down_read(&EXT4_I(dentry->d_inode)->xattr_sem); |
| 431 | i_error = ext4_xattr_ibody_list(inode, buffer, buffer_size); | 434 | i_error = ext4_xattr_ibody_list(dentry, buffer, buffer_size); |
| 432 | if (i_error < 0) { | 435 | if (i_error < 0) { |
| 433 | b_error = 0; | 436 | b_error = 0; |
| 434 | } else { | 437 | } else { |
| @@ -436,11 +439,11 @@ ext4_xattr_list(struct inode *inode, char *buffer, size_t buffer_size) | |||
| 436 | buffer += i_error; | 439 | buffer += i_error; |
| 437 | buffer_size -= i_error; | 440 | buffer_size -= i_error; |
| 438 | } | 441 | } |
| 439 | b_error = ext4_xattr_block_list(inode, buffer, buffer_size); | 442 | b_error = ext4_xattr_block_list(dentry, buffer, buffer_size); |
| 440 | if (b_error < 0) | 443 | if (b_error < 0) |
| 441 | i_error = 0; | 444 | i_error = 0; |
| 442 | } | 445 | } |
| 443 | up_read(&EXT4_I(inode)->xattr_sem); | 446 | up_read(&EXT4_I(dentry->d_inode)->xattr_sem); |
| 444 | return i_error + b_error; | 447 | return i_error + b_error; |
| 445 | } | 448 | } |
| 446 | 449 | ||
diff --git a/fs/ext4/xattr_security.c b/fs/ext4/xattr_security.c index ca5f89fc6cae..983c253999a7 100644 --- a/fs/ext4/xattr_security.c +++ b/fs/ext4/xattr_security.c | |||
| @@ -12,8 +12,8 @@ | |||
| 12 | #include "xattr.h" | 12 | #include "xattr.h" |
| 13 | 13 | ||
| 14 | static size_t | 14 | static size_t |
| 15 | ext4_xattr_security_list(struct inode *inode, char *list, size_t list_size, | 15 | ext4_xattr_security_list(struct dentry *dentry, char *list, size_t list_size, |
| 16 | const char *name, size_t name_len) | 16 | const char *name, size_t name_len, int type) |
| 17 | { | 17 | { |
| 18 | const size_t prefix_len = sizeof(XATTR_SECURITY_PREFIX)-1; | 18 | const size_t prefix_len = sizeof(XATTR_SECURITY_PREFIX)-1; |
| 19 | const size_t total_len = prefix_len + name_len + 1; | 19 | const size_t total_len = prefix_len + name_len + 1; |
| @@ -28,23 +28,23 @@ ext4_xattr_security_list(struct inode *inode, char *list, size_t list_size, | |||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | static int | 30 | static int |
| 31 | ext4_xattr_security_get(struct inode *inode, const char *name, | 31 | ext4_xattr_security_get(struct dentry *dentry, const char *name, |
| 32 | void *buffer, size_t size) | 32 | void *buffer, size_t size, int type) |
| 33 | { | 33 | { |
| 34 | if (strcmp(name, "") == 0) | 34 | if (strcmp(name, "") == 0) |
| 35 | return -EINVAL; | 35 | return -EINVAL; |
| 36 | return ext4_xattr_get(inode, EXT4_XATTR_INDEX_SECURITY, name, | 36 | return ext4_xattr_get(dentry->d_inode, EXT4_XATTR_INDEX_SECURITY, |
| 37 | buffer, size); | 37 | name, buffer, size); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | static int | 40 | static int |
| 41 | ext4_xattr_security_set(struct inode *inode, const char *name, | 41 | ext4_xattr_security_set(struct dentry *dentry, const char *name, |
| 42 | const void *value, size_t size, int flags) | 42 | const void *value, size_t size, int flags, int type) |
| 43 | { | 43 | { |
| 44 | if (strcmp(name, "") == 0) | 44 | if (strcmp(name, "") == 0) |
| 45 | return -EINVAL; | 45 | return -EINVAL; |
| 46 | return ext4_xattr_set(inode, EXT4_XATTR_INDEX_SECURITY, name, | 46 | return ext4_xattr_set(dentry->d_inode, EXT4_XATTR_INDEX_SECURITY, |
| 47 | value, size, flags); | 47 | name, value, size, flags); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | int | 50 | int |
diff --git a/fs/ext4/xattr_trusted.c b/fs/ext4/xattr_trusted.c index ac1a52cf2a37..15b50edc6587 100644 --- a/fs/ext4/xattr_trusted.c +++ b/fs/ext4/xattr_trusted.c | |||
| @@ -14,8 +14,8 @@ | |||
| 14 | #include "xattr.h" | 14 | #include "xattr.h" |
| 15 | 15 | ||
| 16 | static size_t | 16 | static size_t |
| 17 | ext4_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, | 17 | ext4_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size, |
| 18 | const char *name, size_t name_len) | 18 | const char *name, size_t name_len, int type) |
| 19 | { | 19 | { |
| 20 | const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; | 20 | const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; |
| 21 | const size_t total_len = prefix_len + name_len + 1; | 21 | const size_t total_len = prefix_len + name_len + 1; |
| @@ -32,23 +32,23 @@ ext4_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, | |||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | static int | 34 | static int |
| 35 | ext4_xattr_trusted_get(struct inode *inode, const char *name, | 35 | ext4_xattr_trusted_get(struct dentry *dentry, const char *name, void *buffer, |
| 36 | void *buffer, size_t size) | 36 | size_t size, int type) |
| 37 | { | 37 | { |
| 38 | if (strcmp(name, "") == 0) | 38 | if (strcmp(name, "") == 0) |
| 39 | return -EINVAL; | 39 | return -EINVAL; |
| 40 | return ext4_xattr_get(inode, EXT4_XATTR_INDEX_TRUSTED, name, | 40 | return ext4_xattr_get(dentry->d_inode, EXT4_XATTR_INDEX_TRUSTED, |
| 41 | buffer, size); | 41 | name, buffer, size); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | static int | 44 | static int |
| 45 | ext4_xattr_trusted_set(struct inode *inode, const char *name, | 45 | ext4_xattr_trusted_set(struct dentry *dentry, const char *name, |
| 46 | const void *value, size_t size, int flags) | 46 | const void *value, size_t size, int flags, int type) |
| 47 | { | 47 | { |
| 48 | if (strcmp(name, "") == 0) | 48 | if (strcmp(name, "") == 0) |
| 49 | return -EINVAL; | 49 | return -EINVAL; |
| 50 | return ext4_xattr_set(inode, EXT4_XATTR_INDEX_TRUSTED, name, | 50 | return ext4_xattr_set(dentry->d_inode, EXT4_XATTR_INDEX_TRUSTED, |
| 51 | value, size, flags); | 51 | name, value, size, flags); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | struct xattr_handler ext4_xattr_trusted_handler = { | 54 | struct xattr_handler ext4_xattr_trusted_handler = { |
diff --git a/fs/ext4/xattr_user.c b/fs/ext4/xattr_user.c index d91aa61b42aa..c4ce05746ce1 100644 --- a/fs/ext4/xattr_user.c +++ b/fs/ext4/xattr_user.c | |||
| @@ -13,13 +13,13 @@ | |||
| 13 | #include "xattr.h" | 13 | #include "xattr.h" |
| 14 | 14 | ||
| 15 | static size_t | 15 | static size_t |
| 16 | ext4_xattr_user_list(struct inode *inode, char *list, size_t list_size, | 16 | ext4_xattr_user_list(struct dentry *dentry, char *list, size_t list_size, |
| 17 | const char *name, size_t name_len) | 17 | const char *name, size_t name_len, int type) |
| 18 | { | 18 | { |
| 19 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; | 19 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; |
| 20 | const size_t total_len = prefix_len + name_len + 1; | 20 | const size_t total_len = prefix_len + name_len + 1; |
| 21 | 21 | ||
| 22 | if (!test_opt(inode->i_sb, XATTR_USER)) | 22 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
| 23 | return 0; | 23 | return 0; |
| 24 | 24 | ||
| 25 | if (list && total_len <= list_size) { | 25 | if (list && total_len <= list_size) { |
| @@ -31,26 +31,27 @@ ext4_xattr_user_list(struct inode *inode, char *list, size_t list_size, | |||
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | static int | 33 | static int |
| 34 | ext4_xattr_user_get(struct inode *inode, const char *name, | 34 | ext4_xattr_user_get(struct dentry *dentry, const char *name, |
| 35 | void *buffer, size_t size) | 35 | void *buffer, size_t size, int type) |
| 36 | { | 36 | { |
| 37 | if (strcmp(name, "") == 0) | 37 | if (strcmp(name, "") == 0) |
| 38 | return -EINVAL; | 38 | return -EINVAL; |
| 39 | if (!test_opt(inode->i_sb, XATTR_USER)) | 39 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
| 40 | return -EOPNOTSUPP; | 40 | return -EOPNOTSUPP; |
| 41 | return ext4_xattr_get(inode, EXT4_XATTR_INDEX_USER, name, buffer, size); | 41 | return ext4_xattr_get(dentry->d_inode, EXT4_XATTR_INDEX_USER, |
| 42 | name, buffer, size); | ||
| 42 | } | 43 | } |
| 43 | 44 | ||
| 44 | static int | 45 | static int |
| 45 | ext4_xattr_user_set(struct inode *inode, const char *name, | 46 | ext4_xattr_user_set(struct dentry *dentry, const char *name, |
| 46 | const void *value, size_t size, int flags) | 47 | const void *value, size_t size, int flags, int type) |
| 47 | { | 48 | { |
| 48 | if (strcmp(name, "") == 0) | 49 | if (strcmp(name, "") == 0) |
| 49 | return -EINVAL; | 50 | return -EINVAL; |
| 50 | if (!test_opt(inode->i_sb, XATTR_USER)) | 51 | if (!test_opt(dentry->d_sb, XATTR_USER)) |
| 51 | return -EOPNOTSUPP; | 52 | return -EOPNOTSUPP; |
| 52 | return ext4_xattr_set(inode, EXT4_XATTR_INDEX_USER, name, | 53 | return ext4_xattr_set(dentry->d_inode, EXT4_XATTR_INDEX_USER, |
| 53 | value, size, flags); | 54 | name, value, size, flags); |
| 54 | } | 55 | } |
| 55 | 56 | ||
| 56 | struct xattr_handler ext4_xattr_user_handler = { | 57 | struct xattr_handler ext4_xattr_user_handler = { |
diff --git a/fs/fat/fat.h b/fs/fat/fat.h index 7db0979c6b72..e6efdfa0f6db 100644 --- a/fs/fat/fat.h +++ b/fs/fat/fat.h | |||
| @@ -44,7 +44,8 @@ struct fat_mount_options { | |||
| 44 | nocase:1, /* Does this need case conversion? 0=need case conversion*/ | 44 | nocase:1, /* Does this need case conversion? 0=need case conversion*/ |
| 45 | usefree:1, /* Use free_clusters for FAT32 */ | 45 | usefree:1, /* Use free_clusters for FAT32 */ |
| 46 | tz_utc:1, /* Filesystem timestamps are in UTC */ | 46 | tz_utc:1, /* Filesystem timestamps are in UTC */ |
| 47 | rodir:1; /* allow ATTR_RO for directory */ | 47 | rodir:1, /* allow ATTR_RO for directory */ |
| 48 | discard:1; /* Issue discard requests on deletions */ | ||
| 48 | }; | 49 | }; |
| 49 | 50 | ||
| 50 | #define FAT_HASH_BITS 8 | 51 | #define FAT_HASH_BITS 8 |
diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c index a81037721a6f..81184d3b75a3 100644 --- a/fs/fat/fatent.c +++ b/fs/fat/fatent.c | |||
| @@ -566,16 +566,21 @@ int fat_free_clusters(struct inode *inode, int cluster) | |||
| 566 | goto error; | 566 | goto error; |
| 567 | } | 567 | } |
| 568 | 568 | ||
| 569 | /* | 569 | if (sbi->options.discard) { |
| 570 | * Issue discard for the sectors we no longer care about, | 570 | /* |
| 571 | * batching contiguous clusters into one request | 571 | * Issue discard for the sectors we no longer |
| 572 | */ | 572 | * care about, batching contiguous clusters |
| 573 | if (cluster != fatent.entry + 1) { | 573 | * into one request |
| 574 | int nr_clus = fatent.entry - first_cl + 1; | 574 | */ |
| 575 | 575 | if (cluster != fatent.entry + 1) { | |
| 576 | sb_issue_discard(sb, fat_clus_to_blknr(sbi, first_cl), | 576 | int nr_clus = fatent.entry - first_cl + 1; |
| 577 | nr_clus * sbi->sec_per_clus); | 577 | |
| 578 | first_cl = cluster; | 578 | sb_issue_discard(sb, |
| 579 | fat_clus_to_blknr(sbi, first_cl), | ||
| 580 | nr_clus * sbi->sec_per_clus); | ||
| 581 | |||
| 582 | first_cl = cluster; | ||
| 583 | } | ||
| 579 | } | 584 | } |
| 580 | 585 | ||
| 581 | ops->ent_put(&fatent, FAT_ENT_FREE); | 586 | ops->ent_put(&fatent, FAT_ENT_FREE); |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 76b7961ab663..14da530b05ca 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
| @@ -858,6 +858,8 @@ static int fat_show_options(struct seq_file *m, struct vfsmount *mnt) | |||
| 858 | seq_puts(m, ",errors=panic"); | 858 | seq_puts(m, ",errors=panic"); |
| 859 | else | 859 | else |
| 860 | seq_puts(m, ",errors=remount-ro"); | 860 | seq_puts(m, ",errors=remount-ro"); |
| 861 | if (opts->discard) | ||
| 862 | seq_puts(m, ",discard"); | ||
| 861 | 863 | ||
| 862 | return 0; | 864 | return 0; |
| 863 | } | 865 | } |
| @@ -871,7 +873,7 @@ enum { | |||
| 871 | Opt_shortname_winnt, Opt_shortname_mixed, Opt_utf8_no, Opt_utf8_yes, | 873 | Opt_shortname_winnt, Opt_shortname_mixed, Opt_utf8_no, Opt_utf8_yes, |
| 872 | Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes, | 874 | Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes, |
| 873 | Opt_obsolate, Opt_flush, Opt_tz_utc, Opt_rodir, Opt_err_cont, | 875 | Opt_obsolate, Opt_flush, Opt_tz_utc, Opt_rodir, Opt_err_cont, |
| 874 | Opt_err_panic, Opt_err_ro, Opt_err, | 876 | Opt_err_panic, Opt_err_ro, Opt_discard, Opt_err, |
| 875 | }; | 877 | }; |
| 876 | 878 | ||
| 877 | static const match_table_t fat_tokens = { | 879 | static const match_table_t fat_tokens = { |
| @@ -899,6 +901,7 @@ static const match_table_t fat_tokens = { | |||
| 899 | {Opt_err_cont, "errors=continue"}, | 901 | {Opt_err_cont, "errors=continue"}, |
| 900 | {Opt_err_panic, "errors=panic"}, | 902 | {Opt_err_panic, "errors=panic"}, |
| 901 | {Opt_err_ro, "errors=remount-ro"}, | 903 | {Opt_err_ro, "errors=remount-ro"}, |
| 904 | {Opt_discard, "discard"}, | ||
| 902 | {Opt_obsolate, "conv=binary"}, | 905 | {Opt_obsolate, "conv=binary"}, |
| 903 | {Opt_obsolate, "conv=text"}, | 906 | {Opt_obsolate, "conv=text"}, |
| 904 | {Opt_obsolate, "conv=auto"}, | 907 | {Opt_obsolate, "conv=auto"}, |
| @@ -1136,6 +1139,9 @@ static int parse_options(char *options, int is_vfat, int silent, int *debug, | |||
| 1136 | case Opt_rodir: | 1139 | case Opt_rodir: |
| 1137 | opts->rodir = 1; | 1140 | opts->rodir = 1; |
| 1138 | break; | 1141 | break; |
| 1142 | case Opt_discard: | ||
| 1143 | opts->discard = 1; | ||
| 1144 | break; | ||
| 1139 | 1145 | ||
| 1140 | /* obsolete mount options */ | 1146 | /* obsolete mount options */ |
| 1141 | case Opt_obsolate: | 1147 | case Opt_obsolate: |
diff --git a/fs/fat/misc.c b/fs/fat/misc.c index 0f55f5cb732f..d3da05f26465 100644 --- a/fs/fat/misc.c +++ b/fs/fat/misc.c | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
| 10 | #include <linux/fs.h> | 10 | #include <linux/fs.h> |
| 11 | #include <linux/buffer_head.h> | 11 | #include <linux/buffer_head.h> |
| 12 | #include <linux/time.h> | ||
| 12 | #include "fat.h" | 13 | #include "fat.h" |
| 13 | 14 | ||
| 14 | /* | 15 | /* |
| @@ -157,10 +158,6 @@ extern struct timezone sys_tz; | |||
| 157 | #define SECS_PER_MIN 60 | 158 | #define SECS_PER_MIN 60 |
| 158 | #define SECS_PER_HOUR (60 * 60) | 159 | #define SECS_PER_HOUR (60 * 60) |
| 159 | #define SECS_PER_DAY (SECS_PER_HOUR * 24) | 160 | #define SECS_PER_DAY (SECS_PER_HOUR * 24) |
| 160 | #define UNIX_SECS_1980 315532800L | ||
| 161 | #if BITS_PER_LONG == 64 | ||
| 162 | #define UNIX_SECS_2108 4354819200L | ||
| 163 | #endif | ||
| 164 | /* days between 1.1.70 and 1.1.80 (2 leap days) */ | 161 | /* days between 1.1.70 and 1.1.80 (2 leap days) */ |
| 165 | #define DAYS_DELTA (365 * 10 + 2) | 162 | #define DAYS_DELTA (365 * 10 + 2) |
| 166 | /* 120 (2100 - 1980) isn't leap year */ | 163 | /* 120 (2100 - 1980) isn't leap year */ |
| @@ -213,58 +210,35 @@ void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts, | |||
| 213 | void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec *ts, | 210 | void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec *ts, |
| 214 | __le16 *time, __le16 *date, u8 *time_cs) | 211 | __le16 *time, __le16 *date, u8 *time_cs) |
| 215 | { | 212 | { |
| 216 | time_t second = ts->tv_sec; | 213 | struct tm tm; |
| 217 | time_t day, leap_day, month, year; | 214 | time_to_tm(ts->tv_sec, sbi->options.tz_utc ? 0 : |
| 215 | -sys_tz.tz_minuteswest * 60, &tm); | ||
| 218 | 216 | ||
| 219 | if (!sbi->options.tz_utc) | 217 | /* FAT can only support year between 1980 to 2107 */ |
| 220 | second -= sys_tz.tz_minuteswest * SECS_PER_MIN; | 218 | if (tm.tm_year < 1980 - 1900) { |
| 221 | |||
| 222 | /* Jan 1 GMT 00:00:00 1980. But what about another time zone? */ | ||
| 223 | if (second < UNIX_SECS_1980) { | ||
| 224 | *time = 0; | 219 | *time = 0; |
| 225 | *date = cpu_to_le16((0 << 9) | (1 << 5) | 1); | 220 | *date = cpu_to_le16((0 << 9) | (1 << 5) | 1); |
| 226 | if (time_cs) | 221 | if (time_cs) |
| 227 | *time_cs = 0; | 222 | *time_cs = 0; |
| 228 | return; | 223 | return; |
| 229 | } | 224 | } |
| 230 | #if BITS_PER_LONG == 64 | 225 | if (tm.tm_year > 2107 - 1900) { |
| 231 | if (second >= UNIX_SECS_2108) { | ||
| 232 | *time = cpu_to_le16((23 << 11) | (59 << 5) | 29); | 226 | *time = cpu_to_le16((23 << 11) | (59 << 5) | 29); |
| 233 | *date = cpu_to_le16((127 << 9) | (12 << 5) | 31); | 227 | *date = cpu_to_le16((127 << 9) | (12 << 5) | 31); |
| 234 | if (time_cs) | 228 | if (time_cs) |
| 235 | *time_cs = 199; | 229 | *time_cs = 199; |
| 236 | return; | 230 | return; |
| 237 | } | 231 | } |
| 238 | #endif | ||
| 239 | 232 | ||
| 240 | day = second / SECS_PER_DAY - DAYS_DELTA; | 233 | /* from 1900 -> from 1980 */ |
| 241 | year = day / 365; | 234 | tm.tm_year -= 80; |
| 242 | leap_day = (year + 3) / 4; | 235 | /* 0~11 -> 1~12 */ |
| 243 | if (year > YEAR_2100) /* 2100 isn't leap year */ | 236 | tm.tm_mon++; |
| 244 | leap_day--; | 237 | /* 0~59 -> 0~29(2sec counts) */ |
| 245 | if (year * 365 + leap_day > day) | 238 | tm.tm_sec >>= 1; |
| 246 | year--; | ||
| 247 | leap_day = (year + 3) / 4; | ||
| 248 | if (year > YEAR_2100) /* 2100 isn't leap year */ | ||
| 249 | leap_day--; | ||
| 250 | day -= year * 365 + leap_day; | ||
| 251 | |||
| 252 | if (IS_LEAP_YEAR(year) && day == days_in_year[3]) { | ||
| 253 | month = 2; | ||
| 254 | } else { | ||
| 255 | if (IS_LEAP_YEAR(year) && day > days_in_year[3]) | ||
| 256 | day--; | ||
| 257 | for (month = 1; month < 12; month++) { | ||
| 258 | if (days_in_year[month + 1] > day) | ||
| 259 | break; | ||
| 260 | } | ||
| 261 | } | ||
| 262 | day -= days_in_year[month]; | ||
| 263 | 239 | ||
| 264 | *time = cpu_to_le16(((second / SECS_PER_HOUR) % 24) << 11 | 240 | *time = cpu_to_le16(tm.tm_hour << 11 | tm.tm_min << 5 | tm.tm_sec); |
| 265 | | ((second / SECS_PER_MIN) % 60) << 5 | 241 | *date = cpu_to_le16(tm.tm_year << 9 | tm.tm_mon << 5 | tm.tm_mday); |
| 266 | | (second % SECS_PER_MIN) >> 1); | ||
| 267 | *date = cpu_to_le16((year << 9) | (month << 5) | (day + 1)); | ||
| 268 | if (time_cs) | 242 | if (time_cs) |
| 269 | *time_cs = (ts->tv_sec & 1) * 100 + ts->tv_nsec / 10000000; | 243 | *time_cs = (ts->tv_sec & 1) * 100 + ts->tv_nsec / 10000000; |
| 270 | } | 244 | } |
| @@ -285,4 +259,3 @@ int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs) | |||
| 285 | } | 259 | } |
| 286 | return err; | 260 | return err; |
| 287 | } | 261 | } |
| 288 | |||
diff --git a/fs/file_table.c b/fs/file_table.c index 4bef4c01ec6f..0afacf654398 100644 --- a/fs/file_table.c +++ b/fs/file_table.c | |||
| @@ -21,9 +21,12 @@ | |||
| 21 | #include <linux/fsnotify.h> | 21 | #include <linux/fsnotify.h> |
| 22 | #include <linux/sysctl.h> | 22 | #include <linux/sysctl.h> |
| 23 | #include <linux/percpu_counter.h> | 23 | #include <linux/percpu_counter.h> |
| 24 | #include <linux/ima.h> | ||
| 24 | 25 | ||
| 25 | #include <asm/atomic.h> | 26 | #include <asm/atomic.h> |
| 26 | 27 | ||
| 28 | #include "internal.h" | ||
| 29 | |||
| 27 | /* sysctl tunables... */ | 30 | /* sysctl tunables... */ |
| 28 | struct files_stat_struct files_stat = { | 31 | struct files_stat_struct files_stat = { |
| 29 | .max_files = NR_FILE | 32 | .max_files = NR_FILE |
| @@ -147,8 +150,6 @@ fail: | |||
| 147 | return NULL; | 150 | return NULL; |
| 148 | } | 151 | } |
| 149 | 152 | ||
| 150 | EXPORT_SYMBOL(get_empty_filp); | ||
| 151 | |||
| 152 | /** | 153 | /** |
| 153 | * alloc_file - allocate and initialize a 'struct file' | 154 | * alloc_file - allocate and initialize a 'struct file' |
| 154 | * @mnt: the vfsmount on which the file will reside | 155 | * @mnt: the vfsmount on which the file will reside |
| @@ -164,8 +165,8 @@ EXPORT_SYMBOL(get_empty_filp); | |||
| 164 | * If all the callers of init_file() are eliminated, its | 165 | * If all the callers of init_file() are eliminated, its |
| 165 | * code should be moved into this function. | 166 | * code should be moved into this function. |
| 166 | */ | 167 | */ |
| 167 | struct file *alloc_file(struct vfsmount *mnt, struct dentry *dentry, | 168 | struct file *alloc_file(struct path *path, fmode_t mode, |
| 168 | fmode_t mode, const struct file_operations *fop) | 169 | const struct file_operations *fop) |
| 169 | { | 170 | { |
| 170 | struct file *file; | 171 | struct file *file; |
| 171 | 172 | ||
| @@ -173,35 +174,8 @@ struct file *alloc_file(struct vfsmount *mnt, struct dentry *dentry, | |||
| 173 | if (!file) | 174 | if (!file) |
| 174 | return NULL; | 175 | return NULL; |
| 175 | 176 | ||
| 176 | init_file(file, mnt, dentry, mode, fop); | 177 | file->f_path = *path; |
| 177 | return file; | 178 | file->f_mapping = path->dentry->d_inode->i_mapping; |
| 178 | } | ||
| 179 | EXPORT_SYMBOL(alloc_file); | ||
| 180 | |||
| 181 | /** | ||
| 182 | * init_file - initialize a 'struct file' | ||
| 183 | * @file: the already allocated 'struct file' to initialized | ||
| 184 | * @mnt: the vfsmount on which the file resides | ||
| 185 | * @dentry: the dentry representing this file | ||
| 186 | * @mode: the mode the file is opened with | ||
| 187 | * @fop: the 'struct file_operations' for this file | ||
| 188 | * | ||
| 189 | * Use this instead of setting the members directly. Doing so | ||
| 190 | * avoids making mistakes like forgetting the mntget() or | ||
| 191 | * forgetting to take a write on the mnt. | ||
| 192 | * | ||
| 193 | * Note: This is a crappy interface. It is here to make | ||
| 194 | * merging with the existing users of get_empty_filp() | ||
| 195 | * who have complex failure logic easier. All users | ||
| 196 | * of this should be moving to alloc_file(). | ||
| 197 | */ | ||
| 198 | int init_file(struct file *file, struct vfsmount *mnt, struct dentry *dentry, | ||
| 199 | fmode_t mode, const struct file_operations *fop) | ||
| 200 | { | ||
| 201 | int error = 0; | ||
| 202 | file->f_path.dentry = dentry; | ||
| 203 | file->f_path.mnt = mntget(mnt); | ||
| 204 | file->f_mapping = dentry->d_inode->i_mapping; | ||
| 205 | file->f_mode = mode; | 179 | file->f_mode = mode; |
| 206 | file->f_op = fop; | 180 | file->f_op = fop; |
| 207 | 181 | ||
| @@ -211,14 +185,16 @@ int init_file(struct file *file, struct vfsmount *mnt, struct dentry *dentry, | |||
| 211 | * visible. We do this for consistency, and so | 185 | * visible. We do this for consistency, and so |
| 212 | * that we can do debugging checks at __fput() | 186 | * that we can do debugging checks at __fput() |
| 213 | */ | 187 | */ |
| 214 | if ((mode & FMODE_WRITE) && !special_file(dentry->d_inode->i_mode)) { | 188 | if ((mode & FMODE_WRITE) && !special_file(path->dentry->d_inode->i_mode)) { |
| 189 | int error = 0; | ||
| 215 | file_take_write(file); | 190 | file_take_write(file); |
| 216 | error = mnt_clone_write(mnt); | 191 | error = mnt_clone_write(path->mnt); |
| 217 | WARN_ON(error); | 192 | WARN_ON(error); |
| 218 | } | 193 | } |
| 219 | return error; | 194 | ima_counts_get(file); |
| 195 | return file; | ||
| 220 | } | 196 | } |
| 221 | EXPORT_SYMBOL(init_file); | 197 | EXPORT_SYMBOL(alloc_file); |
| 222 | 198 | ||
| 223 | void fput(struct file *file) | 199 | void fput(struct file *file) |
| 224 | { | 200 | { |
diff --git a/fs/fscache/object-list.c b/fs/fscache/object-list.c index e590242fa41a..3221a0c7944e 100644 --- a/fs/fscache/object-list.c +++ b/fs/fscache/object-list.c | |||
| @@ -91,7 +91,7 @@ EXPORT_SYMBOL(fscache_object_destroy); | |||
| 91 | */ | 91 | */ |
| 92 | static struct fscache_object *fscache_objlist_lookup(loff_t *_pos) | 92 | static struct fscache_object *fscache_objlist_lookup(loff_t *_pos) |
| 93 | { | 93 | { |
| 94 | struct fscache_object *pobj, *obj, *minobj = NULL; | 94 | struct fscache_object *pobj, *obj = NULL, *minobj = NULL; |
| 95 | struct rb_node *p; | 95 | struct rb_node *p; |
| 96 | unsigned long pos; | 96 | unsigned long pos; |
| 97 | 97 | ||
diff --git a/fs/generic_acl.c b/fs/generic_acl.c index e0b53aa7bbec..55458031e501 100644 --- a/fs/generic_acl.c +++ b/fs/generic_acl.c | |||
| @@ -1,62 +1,58 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * fs/generic_acl.c | ||
| 3 | * | ||
| 4 | * (C) 2005 Andreas Gruenbacher <agruen@suse.de> | 2 | * (C) 2005 Andreas Gruenbacher <agruen@suse.de> |
| 5 | * | 3 | * |
| 6 | * This file is released under the GPL. | 4 | * This file is released under the GPL. |
| 5 | * | ||
| 6 | * Generic ACL support for in-memory filesystems. | ||
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | #include <linux/sched.h> | 9 | #include <linux/sched.h> |
| 10 | #include <linux/fs.h> | 10 | #include <linux/fs.h> |
| 11 | #include <linux/generic_acl.h> | 11 | #include <linux/generic_acl.h> |
| 12 | #include <linux/posix_acl.h> | ||
| 13 | #include <linux/posix_acl_xattr.h> | ||
| 12 | 14 | ||
| 13 | /** | 15 | |
| 14 | * generic_acl_list - Generic xattr_handler->list() operation | 16 | static size_t |
| 15 | * @ops: Filesystem specific getacl and setacl callbacks | 17 | generic_acl_list(struct dentry *dentry, char *list, size_t list_size, |
| 16 | */ | 18 | const char *name, size_t name_len, int type) |
| 17 | size_t | ||
| 18 | generic_acl_list(struct inode *inode, struct generic_acl_operations *ops, | ||
| 19 | int type, char *list, size_t list_size) | ||
| 20 | { | 19 | { |
| 21 | struct posix_acl *acl; | 20 | struct posix_acl *acl; |
| 22 | const char *name; | 21 | const char *xname; |
| 23 | size_t size; | 22 | size_t size; |
| 24 | 23 | ||
| 25 | acl = ops->getacl(inode, type); | 24 | acl = get_cached_acl(dentry->d_inode, type); |
| 26 | if (!acl) | 25 | if (!acl) |
| 27 | return 0; | 26 | return 0; |
| 28 | posix_acl_release(acl); | 27 | posix_acl_release(acl); |
| 29 | 28 | ||
| 30 | switch(type) { | 29 | switch (type) { |
| 31 | case ACL_TYPE_ACCESS: | 30 | case ACL_TYPE_ACCESS: |
| 32 | name = POSIX_ACL_XATTR_ACCESS; | 31 | xname = POSIX_ACL_XATTR_ACCESS; |
| 33 | break; | 32 | break; |
| 34 | 33 | case ACL_TYPE_DEFAULT: | |
| 35 | case ACL_TYPE_DEFAULT: | 34 | xname = POSIX_ACL_XATTR_DEFAULT; |
| 36 | name = POSIX_ACL_XATTR_DEFAULT; | 35 | break; |
| 37 | break; | 36 | default: |
| 38 | 37 | return 0; | |
| 39 | default: | ||
| 40 | return 0; | ||
| 41 | } | 38 | } |
| 42 | size = strlen(name) + 1; | 39 | size = strlen(xname) + 1; |
| 43 | if (list && size <= list_size) | 40 | if (list && size <= list_size) |
| 44 | memcpy(list, name, size); | 41 | memcpy(list, xname, size); |
| 45 | return size; | 42 | return size; |
| 46 | } | 43 | } |
| 47 | 44 | ||
| 48 | /** | 45 | static int |
| 49 | * generic_acl_get - Generic xattr_handler->get() operation | 46 | generic_acl_get(struct dentry *dentry, const char *name, void *buffer, |
| 50 | * @ops: Filesystem specific getacl and setacl callbacks | 47 | size_t size, int type) |
| 51 | */ | ||
| 52 | int | ||
| 53 | generic_acl_get(struct inode *inode, struct generic_acl_operations *ops, | ||
| 54 | int type, void *buffer, size_t size) | ||
| 55 | { | 48 | { |
| 56 | struct posix_acl *acl; | 49 | struct posix_acl *acl; |
| 57 | int error; | 50 | int error; |
| 58 | 51 | ||
| 59 | acl = ops->getacl(inode, type); | 52 | if (strcmp(name, "") != 0) |
| 53 | return -EINVAL; | ||
| 54 | |||
| 55 | acl = get_cached_acl(dentry->d_inode, type); | ||
| 60 | if (!acl) | 56 | if (!acl) |
| 61 | return -ENODATA; | 57 | return -ENODATA; |
| 62 | error = posix_acl_to_xattr(acl, buffer, size); | 58 | error = posix_acl_to_xattr(acl, buffer, size); |
| @@ -65,17 +61,16 @@ generic_acl_get(struct inode *inode, struct generic_acl_operations *ops, | |||
| 65 | return error; | 61 | return error; |
| 66 | } | 62 | } |
| 67 | 63 | ||
| 68 | /** | 64 | static int |
| 69 | * generic_acl_set - Generic xattr_handler->set() operation | 65 | generic_acl_set(struct dentry *dentry, const char *name, const void *value, |
| 70 | * @ops: Filesystem specific getacl and setacl callbacks | 66 | size_t size, int flags, int type) |
| 71 | */ | ||
| 72 | int | ||
| 73 | generic_acl_set(struct inode *inode, struct generic_acl_operations *ops, | ||
| 74 | int type, const void *value, size_t size) | ||
| 75 | { | 67 | { |
| 68 | struct inode *inode = dentry->d_inode; | ||
| 76 | struct posix_acl *acl = NULL; | 69 | struct posix_acl *acl = NULL; |
| 77 | int error; | 70 | int error; |
| 78 | 71 | ||
| 72 | if (strcmp(name, "") != 0) | ||
| 73 | return -EINVAL; | ||
| 79 | if (S_ISLNK(inode->i_mode)) | 74 | if (S_ISLNK(inode->i_mode)) |
| 80 | return -EOPNOTSUPP; | 75 | return -EOPNOTSUPP; |
| 81 | if (!is_owner_or_cap(inode)) | 76 | if (!is_owner_or_cap(inode)) |
| @@ -91,28 +86,27 @@ generic_acl_set(struct inode *inode, struct generic_acl_operations *ops, | |||
| 91 | error = posix_acl_valid(acl); | 86 | error = posix_acl_valid(acl); |
| 92 | if (error) | 87 | if (error) |
| 93 | goto failed; | 88 | goto failed; |
| 94 | switch(type) { | 89 | switch (type) { |
| 95 | case ACL_TYPE_ACCESS: | 90 | case ACL_TYPE_ACCESS: |
| 96 | mode = inode->i_mode; | 91 | mode = inode->i_mode; |
| 97 | error = posix_acl_equiv_mode(acl, &mode); | 92 | error = posix_acl_equiv_mode(acl, &mode); |
| 98 | if (error < 0) | 93 | if (error < 0) |
| 99 | goto failed; | 94 | goto failed; |
| 100 | inode->i_mode = mode; | 95 | inode->i_mode = mode; |
| 101 | if (error == 0) { | 96 | if (error == 0) { |
| 102 | posix_acl_release(acl); | 97 | posix_acl_release(acl); |
| 103 | acl = NULL; | 98 | acl = NULL; |
| 104 | } | 99 | } |
| 105 | break; | 100 | break; |
| 106 | 101 | case ACL_TYPE_DEFAULT: | |
| 107 | case ACL_TYPE_DEFAULT: | 102 | if (!S_ISDIR(inode->i_mode)) { |
| 108 | if (!S_ISDIR(inode->i_mode)) { | 103 | error = -EINVAL; |
| 109 | error = -EINVAL; | 104 | goto failed; |
| 110 | goto failed; | 105 | } |
| 111 | } | 106 | break; |
| 112 | break; | ||
| 113 | } | 107 | } |
| 114 | } | 108 | } |
| 115 | ops->setacl(inode, type, acl); | 109 | set_cached_acl(inode, type, acl); |
| 116 | error = 0; | 110 | error = 0; |
| 117 | failed: | 111 | failed: |
| 118 | posix_acl_release(acl); | 112 | posix_acl_release(acl); |
| @@ -121,14 +115,12 @@ failed: | |||
| 121 | 115 | ||
| 122 | /** | 116 | /** |
| 123 | * generic_acl_init - Take care of acl inheritance at @inode create time | 117 | * generic_acl_init - Take care of acl inheritance at @inode create time |
| 124 | * @ops: Filesystem specific getacl and setacl callbacks | ||
| 125 | * | 118 | * |
| 126 | * Files created inside a directory with a default ACL inherit the | 119 | * Files created inside a directory with a default ACL inherit the |
| 127 | * directory's default ACL. | 120 | * directory's default ACL. |
| 128 | */ | 121 | */ |
| 129 | int | 122 | int |
| 130 | generic_acl_init(struct inode *inode, struct inode *dir, | 123 | generic_acl_init(struct inode *inode, struct inode *dir) |
| 131 | struct generic_acl_operations *ops) | ||
| 132 | { | 124 | { |
| 133 | struct posix_acl *acl = NULL; | 125 | struct posix_acl *acl = NULL; |
| 134 | mode_t mode = inode->i_mode; | 126 | mode_t mode = inode->i_mode; |
| @@ -136,7 +128,7 @@ generic_acl_init(struct inode *inode, struct inode *dir, | |||
| 136 | 128 | ||
| 137 | inode->i_mode = mode & ~current_umask(); | 129 | inode->i_mode = mode & ~current_umask(); |
| 138 | if (!S_ISLNK(inode->i_mode)) | 130 | if (!S_ISLNK(inode->i_mode)) |
| 139 | acl = ops->getacl(dir, ACL_TYPE_DEFAULT); | 131 | acl = get_cached_acl(dir, ACL_TYPE_DEFAULT); |
| 140 | if (acl) { | 132 | if (acl) { |
| 141 | struct posix_acl *clone; | 133 | struct posix_acl *clone; |
| 142 | 134 | ||
| @@ -145,7 +137,7 @@ generic_acl_init(struct inode *inode, struct inode *dir, | |||
| 145 | error = -ENOMEM; | 137 | error = -ENOMEM; |
| 146 | if (!clone) | 138 | if (!clone) |
| 147 | goto cleanup; | 139 | goto cleanup; |
| 148 | ops->setacl(inode, ACL_TYPE_DEFAULT, clone); | 140 | set_cached_acl(inode, ACL_TYPE_DEFAULT, clone); |
| 149 | posix_acl_release(clone); | 141 | posix_acl_release(clone); |
| 150 | } | 142 | } |
| 151 | clone = posix_acl_clone(acl, GFP_KERNEL); | 143 | clone = posix_acl_clone(acl, GFP_KERNEL); |
| @@ -156,7 +148,7 @@ generic_acl_init(struct inode *inode, struct inode *dir, | |||
| 156 | if (error >= 0) { | 148 | if (error >= 0) { |
| 157 | inode->i_mode = mode; | 149 | inode->i_mode = mode; |
| 158 | if (error > 0) | 150 | if (error > 0) |
| 159 | ops->setacl(inode, ACL_TYPE_ACCESS, clone); | 151 | set_cached_acl(inode, ACL_TYPE_ACCESS, clone); |
| 160 | } | 152 | } |
| 161 | posix_acl_release(clone); | 153 | posix_acl_release(clone); |
| 162 | } | 154 | } |
| @@ -169,20 +161,19 @@ cleanup: | |||
| 169 | 161 | ||
| 170 | /** | 162 | /** |
| 171 | * generic_acl_chmod - change the access acl of @inode upon chmod() | 163 | * generic_acl_chmod - change the access acl of @inode upon chmod() |
| 172 | * @ops: FIlesystem specific getacl and setacl callbacks | ||
| 173 | * | 164 | * |
| 174 | * A chmod also changes the permissions of the owner, group/mask, and | 165 | * A chmod also changes the permissions of the owner, group/mask, and |
| 175 | * other ACL entries. | 166 | * other ACL entries. |
| 176 | */ | 167 | */ |
| 177 | int | 168 | int |
| 178 | generic_acl_chmod(struct inode *inode, struct generic_acl_operations *ops) | 169 | generic_acl_chmod(struct inode *inode) |
| 179 | { | 170 | { |
| 180 | struct posix_acl *acl, *clone; | 171 | struct posix_acl *acl, *clone; |
| 181 | int error = 0; | 172 | int error = 0; |
| 182 | 173 | ||
| 183 | if (S_ISLNK(inode->i_mode)) | 174 | if (S_ISLNK(inode->i_mode)) |
| 184 | return -EOPNOTSUPP; | 175 | return -EOPNOTSUPP; |
| 185 | acl = ops->getacl(inode, ACL_TYPE_ACCESS); | 176 | acl = get_cached_acl(inode, ACL_TYPE_ACCESS); |
| 186 | if (acl) { | 177 | if (acl) { |
| 187 | clone = posix_acl_clone(acl, GFP_KERNEL); | 178 | clone = posix_acl_clone(acl, GFP_KERNEL); |
| 188 | posix_acl_release(acl); | 179 | posix_acl_release(acl); |
| @@ -190,8 +181,37 @@ generic_acl_chmod(struct inode *inode, struct generic_acl_operations *ops) | |||
| 190 | return -ENOMEM; | 181 | return -ENOMEM; |
| 191 | error = posix_acl_chmod_masq(clone, inode->i_mode); | 182 | error = posix_acl_chmod_masq(clone, inode->i_mode); |
| 192 | if (!error) | 183 | if (!error) |
| 193 | ops->setacl(inode, ACL_TYPE_ACCESS, clone); | 184 | set_cached_acl(inode, ACL_TYPE_ACCESS, clone); |
| 194 | posix_acl_release(clone); | 185 | posix_acl_release(clone); |
| 195 | } | 186 | } |
| 196 | return error; | 187 | return error; |
| 197 | } | 188 | } |
| 189 | |||
| 190 | int | ||
| 191 | generic_check_acl(struct inode *inode, int mask) | ||
| 192 | { | ||
| 193 | struct posix_acl *acl = get_cached_acl(inode, ACL_TYPE_ACCESS); | ||
| 194 | |||
| 195 | if (acl) { | ||
| 196 | int error = posix_acl_permission(inode, acl, mask); | ||
| 197 | posix_acl_release(acl); | ||
| 198 | return error; | ||
| 199 | } | ||
| 200 | return -EAGAIN; | ||
| 201 | } | ||
| 202 | |||
| 203 | struct xattr_handler generic_acl_access_handler = { | ||
| 204 | .prefix = POSIX_ACL_XATTR_ACCESS, | ||
| 205 | .flags = ACL_TYPE_ACCESS, | ||
| 206 | .list = generic_acl_list, | ||
| 207 | .get = generic_acl_get, | ||
| 208 | .set = generic_acl_set, | ||
| 209 | }; | ||
| 210 | |||
| 211 | struct xattr_handler generic_acl_default_handler = { | ||
| 212 | .prefix = POSIX_ACL_XATTR_DEFAULT, | ||
| 213 | .flags = ACL_TYPE_DEFAULT, | ||
| 214 | .list = generic_acl_list, | ||
| 215 | .get = generic_acl_get, | ||
| 216 | .set = generic_acl_set, | ||
| 217 | }; | ||
diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c index 3eb1ea846173..87ee309d4c24 100644 --- a/fs/gfs2/acl.c +++ b/fs/gfs2/acl.c | |||
| @@ -126,7 +126,7 @@ static int gfs2_acl_set(struct inode *inode, int type, struct posix_acl *acl) | |||
| 126 | error = posix_acl_to_xattr(acl, data, len); | 126 | error = posix_acl_to_xattr(acl, data, len); |
| 127 | if (error < 0) | 127 | if (error < 0) |
| 128 | goto out; | 128 | goto out; |
| 129 | error = gfs2_xattr_set(inode, GFS2_EATYPE_SYS, name, data, len, 0); | 129 | error = __gfs2_xattr_set(inode, name, data, len, 0, GFS2_EATYPE_SYS); |
| 130 | if (!error) | 130 | if (!error) |
| 131 | set_cached_acl(inode, type, acl); | 131 | set_cached_acl(inode, type, acl); |
| 132 | out: | 132 | out: |
| @@ -232,9 +232,10 @@ static int gfs2_acl_type(const char *name) | |||
| 232 | return -EINVAL; | 232 | return -EINVAL; |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | static int gfs2_xattr_system_get(struct inode *inode, const char *name, | 235 | static int gfs2_xattr_system_get(struct dentry *dentry, const char *name, |
| 236 | void *buffer, size_t size) | 236 | void *buffer, size_t size, int xtype) |
| 237 | { | 237 | { |
| 238 | struct inode *inode = dentry->d_inode; | ||
| 238 | struct posix_acl *acl; | 239 | struct posix_acl *acl; |
| 239 | int type; | 240 | int type; |
| 240 | int error; | 241 | int error; |
| @@ -255,9 +256,11 @@ static int gfs2_xattr_system_get(struct inode *inode, const char *name, | |||
| 255 | return error; | 256 | return error; |
| 256 | } | 257 | } |
| 257 | 258 | ||
| 258 | static int gfs2_xattr_system_set(struct inode *inode, const char *name, | 259 | static int gfs2_xattr_system_set(struct dentry *dentry, const char *name, |
| 259 | const void *value, size_t size, int flags) | 260 | const void *value, size_t size, int flags, |
| 261 | int xtype) | ||
| 260 | { | 262 | { |
| 263 | struct inode *inode = dentry->d_inode; | ||
| 261 | struct gfs2_sbd *sdp = GFS2_SB(inode); | 264 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
| 262 | struct posix_acl *acl = NULL; | 265 | struct posix_acl *acl = NULL; |
| 263 | int error = 0, type; | 266 | int error = 0, type; |
| @@ -319,7 +322,7 @@ static int gfs2_xattr_system_set(struct inode *inode, const char *name, | |||
| 319 | } | 322 | } |
| 320 | 323 | ||
| 321 | set_acl: | 324 | set_acl: |
| 322 | error = gfs2_xattr_set(inode, GFS2_EATYPE_SYS, name, value, size, 0); | 325 | error = __gfs2_xattr_set(inode, name, value, size, 0, GFS2_EATYPE_SYS); |
| 323 | if (!error) { | 326 | if (!error) { |
| 324 | if (acl) | 327 | if (acl) |
| 325 | set_cached_acl(inode, type, acl); | 328 | set_cached_acl(inode, type, acl); |
| @@ -334,6 +337,7 @@ out: | |||
| 334 | 337 | ||
| 335 | struct xattr_handler gfs2_xattr_system_handler = { | 338 | struct xattr_handler gfs2_xattr_system_handler = { |
| 336 | .prefix = XATTR_SYSTEM_PREFIX, | 339 | .prefix = XATTR_SYSTEM_PREFIX, |
| 340 | .flags = GFS2_EATYPE_SYS, | ||
| 337 | .get = gfs2_xattr_system_get, | 341 | .get = gfs2_xattr_system_get, |
| 338 | .set = gfs2_xattr_system_set, | 342 | .set = gfs2_xattr_system_set, |
| 339 | }; | 343 | }; |
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 26ba2a4c4a2d..6e220f4eee7d 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
| @@ -125,7 +125,7 @@ static struct inode *gfs2_iget_skip(struct super_block *sb, | |||
| 125 | * directory entry when gfs2_inode_lookup() is invoked. Part of the code | 125 | * directory entry when gfs2_inode_lookup() is invoked. Part of the code |
| 126 | * segment inside gfs2_inode_lookup code needs to get moved around. | 126 | * segment inside gfs2_inode_lookup code needs to get moved around. |
| 127 | * | 127 | * |
| 128 | * Clean up I_LOCK and I_NEW as well. | 128 | * Clears I_NEW as well. |
| 129 | **/ | 129 | **/ |
| 130 | 130 | ||
| 131 | void gfs2_set_iop(struct inode *inode) | 131 | void gfs2_set_iop(struct inode *inode) |
| @@ -801,7 +801,8 @@ static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip) | |||
| 801 | return err; | 801 | return err; |
| 802 | } | 802 | } |
| 803 | 803 | ||
| 804 | err = gfs2_xattr_set(&ip->i_inode, GFS2_EATYPE_SECURITY, name, value, len, 0); | 804 | err = __gfs2_xattr_set(&ip->i_inode, name, value, len, 0, |
| 805 | GFS2_EATYPE_SECURITY); | ||
| 805 | kfree(value); | 806 | kfree(value); |
| 806 | kfree(name); | 807 | kfree(name); |
| 807 | 808 | ||
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index c5dad1eb7b91..0dc34621f6a6 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c | |||
| @@ -85,11 +85,7 @@ static ssize_t uuid_show(struct gfs2_sbd *sdp, char *buf) | |||
| 85 | buf[0] = '\0'; | 85 | buf[0] = '\0'; |
| 86 | if (!gfs2_uuid_valid(uuid)) | 86 | if (!gfs2_uuid_valid(uuid)) |
| 87 | return 0; | 87 | return 0; |
| 88 | return snprintf(buf, PAGE_SIZE, "%02X%02X%02X%02X-%02X%02X-" | 88 | return snprintf(buf, PAGE_SIZE, "%pUB\n", uuid); |
| 89 | "%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X\n", | ||
| 90 | uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], | ||
| 91 | uuid[6], uuid[7], uuid[8], uuid[9], uuid[10], uuid[11], | ||
| 92 | uuid[12], uuid[13], uuid[14], uuid[15]); | ||
| 93 | } | 89 | } |
| 94 | 90 | ||
| 95 | static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf) | 91 | static ssize_t freeze_show(struct gfs2_sbd *sdp, char *buf) |
| @@ -575,14 +571,8 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj, | |||
| 575 | add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name); | 571 | add_uevent_var(env, "LOCKPROTO=%s", sdp->sd_proto_name); |
| 576 | if (!sdp->sd_args.ar_spectator) | 572 | if (!sdp->sd_args.ar_spectator) |
| 577 | add_uevent_var(env, "JOURNALID=%u", sdp->sd_lockstruct.ls_jid); | 573 | add_uevent_var(env, "JOURNALID=%u", sdp->sd_lockstruct.ls_jid); |
| 578 | if (gfs2_uuid_valid(uuid)) { | 574 | if (gfs2_uuid_valid(uuid)) |
| 579 | add_uevent_var(env, "UUID=%02X%02X%02X%02X-%02X%02X-%02X%02X-" | 575 | add_uevent_var(env, "UUID=%pUB", uuid); |
| 580 | "%02X%02X-%02X%02X%02X%02X%02X%02X", | ||
| 581 | uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], | ||
| 582 | uuid[5], uuid[6], uuid[7], uuid[8], uuid[9], | ||
| 583 | uuid[10], uuid[11], uuid[12], uuid[13], | ||
| 584 | uuid[14], uuid[15]); | ||
| 585 | } | ||
| 586 | return 0; | 576 | return 0; |
| 587 | } | 577 | } |
| 588 | 578 | ||
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c index 912f5cbc4740..8a04108e0c22 100644 --- a/fs/gfs2/xattr.c +++ b/fs/gfs2/xattr.c | |||
| @@ -567,18 +567,17 @@ out: | |||
| 567 | /** | 567 | /** |
| 568 | * gfs2_xattr_get - Get a GFS2 extended attribute | 568 | * gfs2_xattr_get - Get a GFS2 extended attribute |
| 569 | * @inode: The inode | 569 | * @inode: The inode |
| 570 | * @type: The type of extended attribute | ||
| 571 | * @name: The name of the extended attribute | 570 | * @name: The name of the extended attribute |
| 572 | * @buffer: The buffer to write the result into | 571 | * @buffer: The buffer to write the result into |
| 573 | * @size: The size of the buffer | 572 | * @size: The size of the buffer |
| 573 | * @type: The type of extended attribute | ||
| 574 | * | 574 | * |
| 575 | * Returns: actual size of data on success, -errno on error | 575 | * Returns: actual size of data on success, -errno on error |
| 576 | */ | 576 | */ |
| 577 | 577 | static int gfs2_xattr_get(struct dentry *dentry, const char *name, | |
| 578 | int gfs2_xattr_get(struct inode *inode, int type, const char *name, | 578 | void *buffer, size_t size, int type) |
| 579 | void *buffer, size_t size) | ||
| 580 | { | 579 | { |
| 581 | struct gfs2_inode *ip = GFS2_I(inode); | 580 | struct gfs2_inode *ip = GFS2_I(dentry->d_inode); |
| 582 | struct gfs2_ea_location el; | 581 | struct gfs2_ea_location el; |
| 583 | int error; | 582 | int error; |
| 584 | 583 | ||
| @@ -1119,7 +1118,7 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el) | |||
| 1119 | 1118 | ||
| 1120 | /** | 1119 | /** |
| 1121 | * gfs2_xattr_remove - Remove a GFS2 extended attribute | 1120 | * gfs2_xattr_remove - Remove a GFS2 extended attribute |
| 1122 | * @inode: The inode | 1121 | * @ip: The inode |
| 1123 | * @type: The type of the extended attribute | 1122 | * @type: The type of the extended attribute |
| 1124 | * @name: The name of the extended attribute | 1123 | * @name: The name of the extended attribute |
| 1125 | * | 1124 | * |
| @@ -1130,9 +1129,8 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el) | |||
| 1130 | * Returns: 0, or errno on failure | 1129 | * Returns: 0, or errno on failure |
| 1131 | */ | 1130 | */ |
| 1132 | 1131 | ||
| 1133 | static int gfs2_xattr_remove(struct inode *inode, int type, const char *name) | 1132 | static int gfs2_xattr_remove(struct gfs2_inode *ip, int type, const char *name) |
| 1134 | { | 1133 | { |
| 1135 | struct gfs2_inode *ip = GFS2_I(inode); | ||
| 1136 | struct gfs2_ea_location el; | 1134 | struct gfs2_ea_location el; |
| 1137 | int error; | 1135 | int error; |
| 1138 | 1136 | ||
| @@ -1156,24 +1154,24 @@ static int gfs2_xattr_remove(struct inode *inode, int type, const char *name) | |||
| 1156 | } | 1154 | } |
| 1157 | 1155 | ||
| 1158 | /** | 1156 | /** |
| 1159 | * gfs2_xattr_set - Set (or remove) a GFS2 extended attribute | 1157 | * __gfs2_xattr_set - Set (or remove) a GFS2 extended attribute |
| 1160 | * @inode: The inode | 1158 | * @ip: The inode |
| 1161 | * @type: The type of the extended attribute | ||
| 1162 | * @name: The name of the extended attribute | 1159 | * @name: The name of the extended attribute |
| 1163 | * @value: The value of the extended attribute (NULL for remove) | 1160 | * @value: The value of the extended attribute (NULL for remove) |
| 1164 | * @size: The size of the @value argument | 1161 | * @size: The size of the @value argument |
| 1165 | * @flags: Create or Replace | 1162 | * @flags: Create or Replace |
| 1163 | * @type: The type of the extended attribute | ||
| 1166 | * | 1164 | * |
| 1167 | * See gfs2_xattr_remove() for details of the removal of xattrs. | 1165 | * See gfs2_xattr_remove() for details of the removal of xattrs. |
| 1168 | * | 1166 | * |
| 1169 | * Returns: 0 or errno on failure | 1167 | * Returns: 0 or errno on failure |
| 1170 | */ | 1168 | */ |
| 1171 | 1169 | ||
| 1172 | int gfs2_xattr_set(struct inode *inode, int type, const char *name, | 1170 | int __gfs2_xattr_set(struct inode *inode, const char *name, |
| 1173 | const void *value, size_t size, int flags) | 1171 | const void *value, size_t size, int flags, int type) |
| 1174 | { | 1172 | { |
| 1175 | struct gfs2_sbd *sdp = GFS2_SB(inode); | ||
| 1176 | struct gfs2_inode *ip = GFS2_I(inode); | 1173 | struct gfs2_inode *ip = GFS2_I(inode); |
| 1174 | struct gfs2_sbd *sdp = GFS2_SB(inode); | ||
| 1177 | struct gfs2_ea_location el; | 1175 | struct gfs2_ea_location el; |
| 1178 | unsigned int namel = strlen(name); | 1176 | unsigned int namel = strlen(name); |
| 1179 | int error; | 1177 | int error; |
| @@ -1184,7 +1182,7 @@ int gfs2_xattr_set(struct inode *inode, int type, const char *name, | |||
| 1184 | return -ERANGE; | 1182 | return -ERANGE; |
| 1185 | 1183 | ||
| 1186 | if (value == NULL) | 1184 | if (value == NULL) |
| 1187 | return gfs2_xattr_remove(inode, type, name); | 1185 | return gfs2_xattr_remove(ip, type, name); |
| 1188 | 1186 | ||
| 1189 | if (ea_check_size(sdp, namel, size)) | 1187 | if (ea_check_size(sdp, namel, size)) |
| 1190 | return -ERANGE; | 1188 | return -ERANGE; |
| @@ -1224,6 +1222,13 @@ int gfs2_xattr_set(struct inode *inode, int type, const char *name, | |||
| 1224 | return error; | 1222 | return error; |
| 1225 | } | 1223 | } |
| 1226 | 1224 | ||
| 1225 | static int gfs2_xattr_set(struct dentry *dentry, const char *name, | ||
| 1226 | const void *value, size_t size, int flags, int type) | ||
| 1227 | { | ||
| 1228 | return __gfs2_xattr_set(dentry->d_inode, name, value, | ||
| 1229 | size, flags, type); | ||
| 1230 | } | ||
| 1231 | |||
| 1227 | static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip, | 1232 | static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip, |
| 1228 | struct gfs2_ea_header *ea, char *data) | 1233 | struct gfs2_ea_header *ea, char *data) |
| 1229 | { | 1234 | { |
| @@ -1529,40 +1534,18 @@ out_alloc: | |||
| 1529 | return error; | 1534 | return error; |
| 1530 | } | 1535 | } |
| 1531 | 1536 | ||
| 1532 | static int gfs2_xattr_user_get(struct inode *inode, const char *name, | ||
| 1533 | void *buffer, size_t size) | ||
| 1534 | { | ||
| 1535 | return gfs2_xattr_get(inode, GFS2_EATYPE_USR, name, buffer, size); | ||
| 1536 | } | ||
| 1537 | |||
| 1538 | static int gfs2_xattr_user_set(struct inode *inode, const char *name, | ||
| 1539 | const void *value, size_t size, int flags) | ||
| 1540 | { | ||
| 1541 | return gfs2_xattr_set(inode, GFS2_EATYPE_USR, name, value, size, flags); | ||
| 1542 | } | ||
| 1543 | |||
| 1544 | static int gfs2_xattr_security_get(struct inode *inode, const char *name, | ||
| 1545 | void *buffer, size_t size) | ||
| 1546 | { | ||
| 1547 | return gfs2_xattr_get(inode, GFS2_EATYPE_SECURITY, name, buffer, size); | ||
| 1548 | } | ||
| 1549 | |||
| 1550 | static int gfs2_xattr_security_set(struct inode *inode, const char *name, | ||
| 1551 | const void *value, size_t size, int flags) | ||
| 1552 | { | ||
| 1553 | return gfs2_xattr_set(inode, GFS2_EATYPE_SECURITY, name, value, size, flags); | ||
| 1554 | } | ||
| 1555 | |||
| 1556 | static struct xattr_handler gfs2_xattr_user_handler = { | 1537 | static struct xattr_handler gfs2_xattr_user_handler = { |
| 1557 | .prefix = XATTR_USER_PREFIX, | 1538 | .prefix = XATTR_USER_PREFIX, |
| 1558 | .get = gfs2_xattr_user_get, | 1539 | .flags = GFS2_EATYPE_USR, |
| 1559 | .set = gfs2_xattr_user_set, | 1540 | .get = gfs2_xattr_get, |
| 1541 | .set = gfs2_xattr_set, | ||
| 1560 | }; | 1542 | }; |
| 1561 | 1543 | ||
| 1562 | static struct xattr_handler gfs2_xattr_security_handler = { | 1544 | static struct xattr_handler gfs2_xattr_security_handler = { |
| 1563 | .prefix = XATTR_SECURITY_PREFIX, | 1545 | .prefix = XATTR_SECURITY_PREFIX, |
| 1564 | .get = gfs2_xattr_security_get, | 1546 | .flags = GFS2_EATYPE_SECURITY, |
| 1565 | .set = gfs2_xattr_security_set, | 1547 | .get = gfs2_xattr_get, |
| 1548 | .set = gfs2_xattr_set, | ||
| 1566 | }; | 1549 | }; |
| 1567 | 1550 | ||
| 1568 | struct xattr_handler *gfs2_xattr_handlers[] = { | 1551 | struct xattr_handler *gfs2_xattr_handlers[] = { |
diff --git a/fs/gfs2/xattr.h b/fs/gfs2/xattr.h index 8d6ae5813c4d..d392f8358f2f 100644 --- a/fs/gfs2/xattr.h +++ b/fs/gfs2/xattr.h | |||
| @@ -53,10 +53,9 @@ struct gfs2_ea_location { | |||
| 53 | struct gfs2_ea_header *el_prev; | 53 | struct gfs2_ea_header *el_prev; |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | extern int gfs2_xattr_get(struct inode *inode, int type, const char *name, | 56 | extern int __gfs2_xattr_set(struct inode *inode, const char *name, |
| 57 | void *buffer, size_t size); | 57 | const void *value, size_t size, |
| 58 | extern int gfs2_xattr_set(struct inode *inode, int type, const char *name, | 58 | int flags, int type); |
| 59 | const void *value, size_t size, int flags); | ||
| 60 | extern ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size); | 59 | extern ssize_t gfs2_listxattr(struct dentry *dentry, char *buffer, size_t size); |
| 61 | extern int gfs2_ea_dealloc(struct gfs2_inode *ip); | 60 | extern int gfs2_ea_dealloc(struct gfs2_inode *ip); |
| 62 | 61 | ||
diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c index 6d98f116ca03..424b0337f524 100644 --- a/fs/hfs/catalog.c +++ b/fs/hfs/catalog.c | |||
| @@ -289,6 +289,10 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, struct qstr *src_name, | |||
| 289 | err = hfs_brec_find(&src_fd); | 289 | err = hfs_brec_find(&src_fd); |
| 290 | if (err) | 290 | if (err) |
| 291 | goto out; | 291 | goto out; |
| 292 | if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) { | ||
| 293 | err = -EIO; | ||
| 294 | goto out; | ||
| 295 | } | ||
| 292 | 296 | ||
| 293 | hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset, | 297 | hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset, |
| 294 | src_fd.entrylength); | 298 | src_fd.entrylength); |
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c index 7c69b98a2e45..2b3b8611b41b 100644 --- a/fs/hfs/dir.c +++ b/fs/hfs/dir.c | |||
| @@ -79,6 +79,11 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
| 79 | filp->f_pos++; | 79 | filp->f_pos++; |
| 80 | /* fall through */ | 80 | /* fall through */ |
| 81 | case 1: | 81 | case 1: |
| 82 | if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) { | ||
| 83 | err = -EIO; | ||
| 84 | goto out; | ||
| 85 | } | ||
| 86 | |||
| 82 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength); | 87 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength); |
| 83 | if (entry.type != HFS_CDR_THD) { | 88 | if (entry.type != HFS_CDR_THD) { |
| 84 | printk(KERN_ERR "hfs: bad catalog folder thread\n"); | 89 | printk(KERN_ERR "hfs: bad catalog folder thread\n"); |
| @@ -109,6 +114,12 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
| 109 | err = -EIO; | 114 | err = -EIO; |
| 110 | goto out; | 115 | goto out; |
| 111 | } | 116 | } |
| 117 | |||
| 118 | if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) { | ||
| 119 | err = -EIO; | ||
| 120 | goto out; | ||
| 121 | } | ||
| 122 | |||
| 112 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength); | 123 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength); |
| 113 | type = entry.type; | 124 | type = entry.type; |
| 114 | len = hfs_mac2asc(sb, strbuf, &fd.key->cat.CName); | 125 | len = hfs_mac2asc(sb, strbuf, &fd.key->cat.CName); |
diff --git a/fs/hfs/super.c b/fs/hfs/super.c index f7fcbe49da72..5ed7252b7b23 100644 --- a/fs/hfs/super.c +++ b/fs/hfs/super.c | |||
| @@ -409,8 +409,13 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 409 | /* try to get the root inode */ | 409 | /* try to get the root inode */ |
| 410 | hfs_find_init(HFS_SB(sb)->cat_tree, &fd); | 410 | hfs_find_init(HFS_SB(sb)->cat_tree, &fd); |
| 411 | res = hfs_cat_find_brec(sb, HFS_ROOT_CNID, &fd); | 411 | res = hfs_cat_find_brec(sb, HFS_ROOT_CNID, &fd); |
| 412 | if (!res) | 412 | if (!res) { |
| 413 | if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) { | ||
| 414 | res = -EIO; | ||
| 415 | goto bail; | ||
| 416 | } | ||
| 413 | hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, fd.entrylength); | 417 | hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, fd.entrylength); |
| 418 | } | ||
| 414 | if (res) { | 419 | if (res) { |
| 415 | hfs_find_exit(&fd); | 420 | hfs_find_exit(&fd); |
| 416 | goto bail_no_root; | 421 | goto bail_no_root; |
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c index f2feaa06bf26..cadc4ce48656 100644 --- a/fs/hpfs/super.c +++ b/fs/hpfs/super.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include <linux/magic.h> | 14 | #include <linux/magic.h> |
| 15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
| 16 | #include <linux/smp_lock.h> | 16 | #include <linux/smp_lock.h> |
| 17 | #include <linux/bitmap.h> | ||
| 17 | 18 | ||
| 18 | /* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */ | 19 | /* Mark the filesystem dirty, so that chkdsk checks it when os/2 booted */ |
| 19 | 20 | ||
| @@ -115,15 +116,13 @@ static void hpfs_put_super(struct super_block *s) | |||
| 115 | unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno) | 116 | unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno) |
| 116 | { | 117 | { |
| 117 | struct quad_buffer_head qbh; | 118 | struct quad_buffer_head qbh; |
| 118 | unsigned *bits; | 119 | unsigned long *bits; |
| 119 | unsigned i, count; | 120 | unsigned count; |
| 120 | if (!(bits = hpfs_map_4sectors(s, secno, &qbh, 4))) return 0; | 121 | |
| 121 | count = 0; | 122 | bits = hpfs_map_4sectors(s, secno, &qbh, 4); |
| 122 | for (i = 0; i < 2048 / sizeof(unsigned); i++) { | 123 | if (!bits) |
| 123 | unsigned b; | 124 | return 0; |
| 124 | if (!bits[i]) continue; | 125 | count = bitmap_weight(bits, 2048 * BITS_PER_BYTE); |
| 125 | for (b = bits[i]; b; b>>=1) count += b & 1; | ||
| 126 | } | ||
| 127 | hpfs_brelse4(&qbh); | 126 | hpfs_brelse4(&qbh); |
| 128 | return count; | 127 | return count; |
| 129 | } | 128 | } |
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 87a1258953b8..a0bbd3d1b41a 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
| @@ -30,7 +30,6 @@ | |||
| 30 | #include <linux/dnotify.h> | 30 | #include <linux/dnotify.h> |
| 31 | #include <linux/statfs.h> | 31 | #include <linux/statfs.h> |
| 32 | #include <linux/security.h> | 32 | #include <linux/security.h> |
| 33 | #include <linux/ima.h> | ||
| 34 | #include <linux/magic.h> | 33 | #include <linux/magic.h> |
| 35 | 34 | ||
| 36 | #include <asm/uaccess.h> | 35 | #include <asm/uaccess.h> |
| @@ -922,7 +921,8 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag, | |||
| 922 | int error = -ENOMEM; | 921 | int error = -ENOMEM; |
| 923 | struct file *file; | 922 | struct file *file; |
| 924 | struct inode *inode; | 923 | struct inode *inode; |
| 925 | struct dentry *dentry, *root; | 924 | struct path path; |
| 925 | struct dentry *root; | ||
| 926 | struct qstr quick_string; | 926 | struct qstr quick_string; |
| 927 | 927 | ||
| 928 | *user = NULL; | 928 | *user = NULL; |
| @@ -944,10 +944,11 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag, | |||
| 944 | quick_string.name = name; | 944 | quick_string.name = name; |
| 945 | quick_string.len = strlen(quick_string.name); | 945 | quick_string.len = strlen(quick_string.name); |
| 946 | quick_string.hash = 0; | 946 | quick_string.hash = 0; |
| 947 | dentry = d_alloc(root, &quick_string); | 947 | path.dentry = d_alloc(root, &quick_string); |
| 948 | if (!dentry) | 948 | if (!path.dentry) |
| 949 | goto out_shm_unlock; | 949 | goto out_shm_unlock; |
| 950 | 950 | ||
| 951 | path.mnt = mntget(hugetlbfs_vfsmount); | ||
| 951 | error = -ENOSPC; | 952 | error = -ENOSPC; |
| 952 | inode = hugetlbfs_get_inode(root->d_sb, current_fsuid(), | 953 | inode = hugetlbfs_get_inode(root->d_sb, current_fsuid(), |
| 953 | current_fsgid(), S_IFREG | S_IRWXUGO, 0); | 954 | current_fsgid(), S_IFREG | S_IRWXUGO, 0); |
| @@ -960,24 +961,22 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag, | |||
| 960 | acctflag)) | 961 | acctflag)) |
| 961 | goto out_inode; | 962 | goto out_inode; |
| 962 | 963 | ||
| 963 | d_instantiate(dentry, inode); | 964 | d_instantiate(path.dentry, inode); |
| 964 | inode->i_size = size; | 965 | inode->i_size = size; |
| 965 | inode->i_nlink = 0; | 966 | inode->i_nlink = 0; |
| 966 | 967 | ||
| 967 | error = -ENFILE; | 968 | error = -ENFILE; |
| 968 | file = alloc_file(hugetlbfs_vfsmount, dentry, | 969 | file = alloc_file(&path, FMODE_WRITE | FMODE_READ, |
| 969 | FMODE_WRITE | FMODE_READ, | ||
| 970 | &hugetlbfs_file_operations); | 970 | &hugetlbfs_file_operations); |
| 971 | if (!file) | 971 | if (!file) |
| 972 | goto out_dentry; /* inode is already attached */ | 972 | goto out_dentry; /* inode is already attached */ |
| 973 | ima_counts_get(file); | ||
| 974 | 973 | ||
| 975 | return file; | 974 | return file; |
| 976 | 975 | ||
| 977 | out_inode: | 976 | out_inode: |
| 978 | iput(inode); | 977 | iput(inode); |
| 979 | out_dentry: | 978 | out_dentry: |
| 980 | dput(dentry); | 979 | path_put(&path); |
| 981 | out_shm_unlock: | 980 | out_shm_unlock: |
| 982 | if (*user) { | 981 | if (*user) { |
| 983 | user_shm_unlock(size, *user); | 982 | user_shm_unlock(size, *user); |
diff --git a/fs/inode.c b/fs/inode.c index 06c1f02de611..03dfeb2e3928 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
| @@ -113,7 +113,7 @@ static void wake_up_inode(struct inode *inode) | |||
| 113 | * Prevent speculative execution through spin_unlock(&inode_lock); | 113 | * Prevent speculative execution through spin_unlock(&inode_lock); |
| 114 | */ | 114 | */ |
| 115 | smp_mb(); | 115 | smp_mb(); |
| 116 | wake_up_bit(&inode->i_state, __I_LOCK); | 116 | wake_up_bit(&inode->i_state, __I_NEW); |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | /** | 119 | /** |
| @@ -690,17 +690,17 @@ void unlock_new_inode(struct inode *inode) | |||
| 690 | } | 690 | } |
| 691 | #endif | 691 | #endif |
| 692 | /* | 692 | /* |
| 693 | * This is special! We do not need the spinlock when clearing I_LOCK, | 693 | * This is special! We do not need the spinlock when clearing I_NEW, |
| 694 | * because we're guaranteed that nobody else tries to do anything about | 694 | * because we're guaranteed that nobody else tries to do anything about |
| 695 | * the state of the inode when it is locked, as we just created it (so | 695 | * the state of the inode when it is locked, as we just created it (so |
| 696 | * there can be no old holders that haven't tested I_LOCK). | 696 | * there can be no old holders that haven't tested I_NEW). |
| 697 | * However we must emit the memory barrier so that other CPUs reliably | 697 | * However we must emit the memory barrier so that other CPUs reliably |
| 698 | * see the clearing of I_LOCK after the other inode initialisation has | 698 | * see the clearing of I_NEW after the other inode initialisation has |
| 699 | * completed. | 699 | * completed. |
| 700 | */ | 700 | */ |
| 701 | smp_mb(); | 701 | smp_mb(); |
| 702 | WARN_ON((inode->i_state & (I_LOCK|I_NEW)) != (I_LOCK|I_NEW)); | 702 | WARN_ON(!(inode->i_state & I_NEW)); |
| 703 | inode->i_state &= ~(I_LOCK|I_NEW); | 703 | inode->i_state &= ~I_NEW; |
| 704 | wake_up_inode(inode); | 704 | wake_up_inode(inode); |
| 705 | } | 705 | } |
| 706 | EXPORT_SYMBOL(unlock_new_inode); | 706 | EXPORT_SYMBOL(unlock_new_inode); |
| @@ -731,7 +731,7 @@ static struct inode *get_new_inode(struct super_block *sb, | |||
| 731 | goto set_failed; | 731 | goto set_failed; |
| 732 | 732 | ||
| 733 | __inode_add_to_lists(sb, head, inode); | 733 | __inode_add_to_lists(sb, head, inode); |
| 734 | inode->i_state = I_LOCK|I_NEW; | 734 | inode->i_state = I_NEW; |
| 735 | spin_unlock(&inode_lock); | 735 | spin_unlock(&inode_lock); |
| 736 | 736 | ||
| 737 | /* Return the locked inode with I_NEW set, the | 737 | /* Return the locked inode with I_NEW set, the |
| @@ -778,7 +778,7 @@ static struct inode *get_new_inode_fast(struct super_block *sb, | |||
| 778 | if (!old) { | 778 | if (!old) { |
| 779 | inode->i_ino = ino; | 779 | inode->i_ino = ino; |
| 780 | __inode_add_to_lists(sb, head, inode); | 780 | __inode_add_to_lists(sb, head, inode); |
| 781 | inode->i_state = I_LOCK|I_NEW; | 781 | inode->i_state = I_NEW; |
| 782 | spin_unlock(&inode_lock); | 782 | spin_unlock(&inode_lock); |
| 783 | 783 | ||
| 784 | /* Return the locked inode with I_NEW set, the | 784 | /* Return the locked inode with I_NEW set, the |
| @@ -1083,7 +1083,7 @@ int insert_inode_locked(struct inode *inode) | |||
| 1083 | ino_t ino = inode->i_ino; | 1083 | ino_t ino = inode->i_ino; |
| 1084 | struct hlist_head *head = inode_hashtable + hash(sb, ino); | 1084 | struct hlist_head *head = inode_hashtable + hash(sb, ino); |
| 1085 | 1085 | ||
| 1086 | inode->i_state |= I_LOCK|I_NEW; | 1086 | inode->i_state |= I_NEW; |
| 1087 | while (1) { | 1087 | while (1) { |
| 1088 | struct hlist_node *node; | 1088 | struct hlist_node *node; |
| 1089 | struct inode *old = NULL; | 1089 | struct inode *old = NULL; |
| @@ -1120,7 +1120,7 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval, | |||
| 1120 | struct super_block *sb = inode->i_sb; | 1120 | struct super_block *sb = inode->i_sb; |
| 1121 | struct hlist_head *head = inode_hashtable + hash(sb, hashval); | 1121 | struct hlist_head *head = inode_hashtable + hash(sb, hashval); |
| 1122 | 1122 | ||
| 1123 | inode->i_state |= I_LOCK|I_NEW; | 1123 | inode->i_state |= I_NEW; |
| 1124 | 1124 | ||
| 1125 | while (1) { | 1125 | while (1) { |
| 1126 | struct hlist_node *node; | 1126 | struct hlist_node *node; |
| @@ -1510,7 +1510,7 @@ EXPORT_SYMBOL(inode_wait); | |||
| 1510 | * until the deletion _might_ have completed. Callers are responsible | 1510 | * until the deletion _might_ have completed. Callers are responsible |
| 1511 | * to recheck inode state. | 1511 | * to recheck inode state. |
| 1512 | * | 1512 | * |
| 1513 | * It doesn't matter if I_LOCK is not set initially, a call to | 1513 | * It doesn't matter if I_NEW is not set initially, a call to |
| 1514 | * wake_up_inode() after removing from the hash list will DTRT. | 1514 | * wake_up_inode() after removing from the hash list will DTRT. |
| 1515 | * | 1515 | * |
| 1516 | * This is called with inode_lock held. | 1516 | * This is called with inode_lock held. |
| @@ -1518,8 +1518,8 @@ EXPORT_SYMBOL(inode_wait); | |||
| 1518 | static void __wait_on_freeing_inode(struct inode *inode) | 1518 | static void __wait_on_freeing_inode(struct inode *inode) |
| 1519 | { | 1519 | { |
| 1520 | wait_queue_head_t *wq; | 1520 | wait_queue_head_t *wq; |
| 1521 | DEFINE_WAIT_BIT(wait, &inode->i_state, __I_LOCK); | 1521 | DEFINE_WAIT_BIT(wait, &inode->i_state, __I_NEW); |
| 1522 | wq = bit_waitqueue(&inode->i_state, __I_LOCK); | 1522 | wq = bit_waitqueue(&inode->i_state, __I_NEW); |
| 1523 | prepare_to_wait(wq, &wait.wait, TASK_UNINTERRUPTIBLE); | 1523 | prepare_to_wait(wq, &wait.wait, TASK_UNINTERRUPTIBLE); |
| 1524 | spin_unlock(&inode_lock); | 1524 | spin_unlock(&inode_lock); |
| 1525 | schedule(); | 1525 | schedule(); |
diff --git a/fs/internal.h b/fs/internal.h index 515175b8b72e..f67cd141d9a8 100644 --- a/fs/internal.h +++ b/fs/internal.h | |||
| @@ -79,6 +79,7 @@ extern void chroot_fs_refs(struct path *, struct path *); | |||
| 79 | * file_table.c | 79 | * file_table.c |
| 80 | */ | 80 | */ |
| 81 | extern void mark_files_ro(struct super_block *); | 81 | extern void mark_files_ro(struct super_block *); |
| 82 | extern struct file *get_empty_filp(void); | ||
| 82 | 83 | ||
| 83 | /* | 84 | /* |
| 84 | * super.c | 85 | * super.c |
diff --git a/fs/isofs/export.c b/fs/isofs/export.c index e81a30593ba9..ed752cb38474 100644 --- a/fs/isofs/export.c +++ b/fs/isofs/export.c | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | * | 9 | * |
| 10 | * The following files are helpful: | 10 | * The following files are helpful: |
| 11 | * | 11 | * |
| 12 | * Documentation/filesystems/Exporting | 12 | * Documentation/filesystems/nfs/Exporting |
| 13 | * fs/exportfs/expfs.c. | 13 | * fs/exportfs/expfs.c. |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c index 7edb62e97419..7cdc3196476a 100644 --- a/fs/jffs2/acl.c +++ b/fs/jffs2/acl.c | |||
| @@ -350,8 +350,8 @@ int jffs2_acl_chmod(struct inode *inode) | |||
| 350 | return rc; | 350 | return rc; |
| 351 | } | 351 | } |
| 352 | 352 | ||
| 353 | static size_t jffs2_acl_access_listxattr(struct inode *inode, char *list, size_t list_size, | 353 | static size_t jffs2_acl_access_listxattr(struct dentry *dentry, char *list, |
| 354 | const char *name, size_t name_len) | 354 | size_t list_size, const char *name, size_t name_len, int type) |
| 355 | { | 355 | { |
| 356 | const int retlen = sizeof(POSIX_ACL_XATTR_ACCESS); | 356 | const int retlen = sizeof(POSIX_ACL_XATTR_ACCESS); |
| 357 | 357 | ||
| @@ -360,8 +360,8 @@ static size_t jffs2_acl_access_listxattr(struct inode *inode, char *list, size_t | |||
| 360 | return retlen; | 360 | return retlen; |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | static size_t jffs2_acl_default_listxattr(struct inode *inode, char *list, size_t list_size, | 363 | static size_t jffs2_acl_default_listxattr(struct dentry *dentry, char *list, |
| 364 | const char *name, size_t name_len) | 364 | size_t list_size, const char *name, size_t name_len, int type) |
| 365 | { | 365 | { |
| 366 | const int retlen = sizeof(POSIX_ACL_XATTR_DEFAULT); | 366 | const int retlen = sizeof(POSIX_ACL_XATTR_DEFAULT); |
| 367 | 367 | ||
| @@ -370,12 +370,16 @@ static size_t jffs2_acl_default_listxattr(struct inode *inode, char *list, size_ | |||
| 370 | return retlen; | 370 | return retlen; |
| 371 | } | 371 | } |
| 372 | 372 | ||
| 373 | static int jffs2_acl_getxattr(struct inode *inode, int type, void *buffer, size_t size) | 373 | static int jffs2_acl_getxattr(struct dentry *dentry, const char *name, |
| 374 | void *buffer, size_t size, int type) | ||
| 374 | { | 375 | { |
| 375 | struct posix_acl *acl; | 376 | struct posix_acl *acl; |
| 376 | int rc; | 377 | int rc; |
| 377 | 378 | ||
| 378 | acl = jffs2_get_acl(inode, type); | 379 | if (name[0] != '\0') |
| 380 | return -EINVAL; | ||
| 381 | |||
| 382 | acl = jffs2_get_acl(dentry->d_inode, type); | ||
| 379 | if (IS_ERR(acl)) | 383 | if (IS_ERR(acl)) |
| 380 | return PTR_ERR(acl); | 384 | return PTR_ERR(acl); |
| 381 | if (!acl) | 385 | if (!acl) |
| @@ -386,26 +390,15 @@ static int jffs2_acl_getxattr(struct inode *inode, int type, void *buffer, size_ | |||
| 386 | return rc; | 390 | return rc; |
| 387 | } | 391 | } |
| 388 | 392 | ||
| 389 | static int jffs2_acl_access_getxattr(struct inode *inode, const char *name, void *buffer, size_t size) | 393 | static int jffs2_acl_setxattr(struct dentry *dentry, const char *name, |
| 390 | { | 394 | const void *value, size_t size, int flags, int type) |
| 391 | if (name[0] != '\0') | ||
| 392 | return -EINVAL; | ||
| 393 | return jffs2_acl_getxattr(inode, ACL_TYPE_ACCESS, buffer, size); | ||
| 394 | } | ||
| 395 | |||
| 396 | static int jffs2_acl_default_getxattr(struct inode *inode, const char *name, void *buffer, size_t size) | ||
| 397 | { | ||
| 398 | if (name[0] != '\0') | ||
| 399 | return -EINVAL; | ||
| 400 | return jffs2_acl_getxattr(inode, ACL_TYPE_DEFAULT, buffer, size); | ||
| 401 | } | ||
| 402 | |||
| 403 | static int jffs2_acl_setxattr(struct inode *inode, int type, const void *value, size_t size) | ||
| 404 | { | 395 | { |
| 405 | struct posix_acl *acl; | 396 | struct posix_acl *acl; |
| 406 | int rc; | 397 | int rc; |
| 407 | 398 | ||
| 408 | if (!is_owner_or_cap(inode)) | 399 | if (name[0] != '\0') |
| 400 | return -EINVAL; | ||
| 401 | if (!is_owner_or_cap(dentry->d_inode)) | ||
| 409 | return -EPERM; | 402 | return -EPERM; |
| 410 | 403 | ||
| 411 | if (value) { | 404 | if (value) { |
| @@ -420,38 +413,24 @@ static int jffs2_acl_setxattr(struct inode *inode, int type, const void *value, | |||
| 420 | } else { | 413 | } else { |
| 421 | acl = NULL; | 414 | acl = NULL; |
| 422 | } | 415 | } |
| 423 | rc = jffs2_set_acl(inode, type, acl); | 416 | rc = jffs2_set_acl(dentry->d_inode, type, acl); |
| 424 | out: | 417 | out: |
| 425 | posix_acl_release(acl); | 418 | posix_acl_release(acl); |
| 426 | return rc; | 419 | return rc; |
| 427 | } | 420 | } |
| 428 | 421 | ||
| 429 | static int jffs2_acl_access_setxattr(struct inode *inode, const char *name, | ||
| 430 | const void *buffer, size_t size, int flags) | ||
| 431 | { | ||
| 432 | if (name[0] != '\0') | ||
| 433 | return -EINVAL; | ||
| 434 | return jffs2_acl_setxattr(inode, ACL_TYPE_ACCESS, buffer, size); | ||
| 435 | } | ||
| 436 | |||
| 437 | static int jffs2_acl_default_setxattr(struct inode *inode, const char *name, | ||
| 438 | const void *buffer, size_t size, int flags) | ||
| 439 | { | ||
| 440 | if (name[0] != '\0') | ||
| 441 | return -EINVAL; | ||
| 442 | return jffs2_acl_setxattr(inode, ACL_TYPE_DEFAULT, buffer, size); | ||
| 443 | } | ||
| 444 | |||
| 445 | struct xattr_handler jffs2_acl_access_xattr_handler = { | 422 | struct xattr_handler jffs2_acl_access_xattr_handler = { |
| 446 | .prefix = POSIX_ACL_XATTR_ACCESS, | 423 | .prefix = POSIX_ACL_XATTR_ACCESS, |
| 424 | .flags = ACL_TYPE_DEFAULT, | ||
| 447 | .list = jffs2_acl_access_listxattr, | 425 | .list = jffs2_acl_access_listxattr, |
| 448 | .get = jffs2_acl_access_getxattr, | 426 | .get = jffs2_acl_getxattr, |
| 449 | .set = jffs2_acl_access_setxattr, | 427 | .set = jffs2_acl_setxattr, |
| 450 | }; | 428 | }; |
| 451 | 429 | ||
| 452 | struct xattr_handler jffs2_acl_default_xattr_handler = { | 430 | struct xattr_handler jffs2_acl_default_xattr_handler = { |
| 453 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 431 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
| 432 | .flags = ACL_TYPE_DEFAULT, | ||
| 454 | .list = jffs2_acl_default_listxattr, | 433 | .list = jffs2_acl_default_listxattr, |
| 455 | .get = jffs2_acl_default_getxattr, | 434 | .get = jffs2_acl_getxattr, |
| 456 | .set = jffs2_acl_default_setxattr, | 435 | .set = jffs2_acl_setxattr, |
| 457 | }; | 436 | }; |
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c index 090c556ffed2..3b6f2fa12cff 100644 --- a/fs/jffs2/gc.c +++ b/fs/jffs2/gc.c | |||
| @@ -700,7 +700,8 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ | |||
| 700 | struct jffs2_raw_inode ri; | 700 | struct jffs2_raw_inode ri; |
| 701 | struct jffs2_node_frag *last_frag; | 701 | struct jffs2_node_frag *last_frag; |
| 702 | union jffs2_device_node dev; | 702 | union jffs2_device_node dev; |
| 703 | char *mdata = NULL, mdatalen = 0; | 703 | char *mdata = NULL; |
| 704 | int mdatalen = 0; | ||
| 704 | uint32_t alloclen, ilen; | 705 | uint32_t alloclen, ilen; |
| 705 | int ret; | 706 | int ret; |
| 706 | 707 | ||
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c index 378991cfe40f..e22de8397b74 100644 --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c | |||
| @@ -1284,7 +1284,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
| 1284 | f->target = NULL; | 1284 | f->target = NULL; |
| 1285 | mutex_unlock(&f->sem); | 1285 | mutex_unlock(&f->sem); |
| 1286 | jffs2_do_clear_inode(c, f); | 1286 | jffs2_do_clear_inode(c, f); |
| 1287 | return -ret; | 1287 | return ret; |
| 1288 | } | 1288 | } |
| 1289 | 1289 | ||
| 1290 | f->target[je32_to_cpu(latest_node->csize)] = '\0'; | 1290 | f->target[je32_to_cpu(latest_node->csize)] = '\0'; |
diff --git a/fs/jffs2/security.c b/fs/jffs2/security.c index 02c39c64ecb3..eaccee058583 100644 --- a/fs/jffs2/security.c +++ b/fs/jffs2/security.c | |||
| @@ -44,26 +44,28 @@ int jffs2_init_security(struct inode *inode, struct inode *dir) | |||
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | /* ---- XATTR Handler for "security.*" ----------------- */ | 46 | /* ---- XATTR Handler for "security.*" ----------------- */ |
| 47 | static int jffs2_security_getxattr(struct inode *inode, const char *name, | 47 | static int jffs2_security_getxattr(struct dentry *dentry, const char *name, |
| 48 | void *buffer, size_t size) | 48 | void *buffer, size_t size, int type) |
| 49 | { | 49 | { |
| 50 | if (!strcmp(name, "")) | 50 | if (!strcmp(name, "")) |
| 51 | return -EINVAL; | 51 | return -EINVAL; |
| 52 | 52 | ||
| 53 | return do_jffs2_getxattr(inode, JFFS2_XPREFIX_SECURITY, name, buffer, size); | 53 | return do_jffs2_getxattr(dentry->d_inode, JFFS2_XPREFIX_SECURITY, |
| 54 | name, buffer, size); | ||
| 54 | } | 55 | } |
| 55 | 56 | ||
| 56 | static int jffs2_security_setxattr(struct inode *inode, const char *name, const void *buffer, | 57 | static int jffs2_security_setxattr(struct dentry *dentry, const char *name, |
| 57 | size_t size, int flags) | 58 | const void *buffer, size_t size, int flags, int type) |
| 58 | { | 59 | { |
| 59 | if (!strcmp(name, "")) | 60 | if (!strcmp(name, "")) |
| 60 | return -EINVAL; | 61 | return -EINVAL; |
| 61 | 62 | ||
| 62 | return do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY, name, buffer, size, flags); | 63 | return do_jffs2_setxattr(dentry->d_inode, JFFS2_XPREFIX_SECURITY, |
| 64 | name, buffer, size, flags); | ||
| 63 | } | 65 | } |
| 64 | 66 | ||
| 65 | static size_t jffs2_security_listxattr(struct inode *inode, char *list, size_t list_size, | 67 | static size_t jffs2_security_listxattr(struct dentry *dentry, char *list, |
| 66 | const char *name, size_t name_len) | 68 | size_t list_size, const char *name, size_t name_len, int type) |
| 67 | { | 69 | { |
| 68 | size_t retlen = XATTR_SECURITY_PREFIX_LEN + name_len + 1; | 70 | size_t retlen = XATTR_SECURITY_PREFIX_LEN + name_len + 1; |
| 69 | 71 | ||
diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c index 6caf1e1ee26d..800171dca53b 100644 --- a/fs/jffs2/summary.c +++ b/fs/jffs2/summary.c | |||
| @@ -23,7 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | int jffs2_sum_init(struct jffs2_sb_info *c) | 24 | int jffs2_sum_init(struct jffs2_sb_info *c) |
| 25 | { | 25 | { |
| 26 | uint32_t sum_size = max_t(uint32_t, c->sector_size, MAX_SUMMARY_SIZE); | 26 | uint32_t sum_size = min_t(uint32_t, c->sector_size, MAX_SUMMARY_SIZE); |
| 27 | 27 | ||
| 28 | c->summary = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL); | 28 | c->summary = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL); |
| 29 | 29 | ||
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c index 4b107881acd5..9e75c62c85d6 100644 --- a/fs/jffs2/xattr.c +++ b/fs/jffs2/xattr.c | |||
| @@ -990,9 +990,11 @@ ssize_t jffs2_listxattr(struct dentry *dentry, char *buffer, size_t size) | |||
| 990 | if (!xhandle) | 990 | if (!xhandle) |
| 991 | continue; | 991 | continue; |
| 992 | if (buffer) { | 992 | if (buffer) { |
| 993 | rc = xhandle->list(inode, buffer+len, size-len, xd->xname, xd->name_len); | 993 | rc = xhandle->list(dentry, buffer+len, size-len, |
| 994 | xd->xname, xd->name_len, xd->flags); | ||
| 994 | } else { | 995 | } else { |
| 995 | rc = xhandle->list(inode, NULL, 0, xd->xname, xd->name_len); | 996 | rc = xhandle->list(dentry, NULL, 0, xd->xname, |
| 997 | xd->name_len, xd->flags); | ||
| 996 | } | 998 | } |
| 997 | if (rc < 0) | 999 | if (rc < 0) |
| 998 | goto out; | 1000 | goto out; |
diff --git a/fs/jffs2/xattr_trusted.c b/fs/jffs2/xattr_trusted.c index 8ec5765ef348..3e5a5e356e05 100644 --- a/fs/jffs2/xattr_trusted.c +++ b/fs/jffs2/xattr_trusted.c | |||
| @@ -16,24 +16,26 @@ | |||
| 16 | #include <linux/mtd/mtd.h> | 16 | #include <linux/mtd/mtd.h> |
| 17 | #include "nodelist.h" | 17 | #include "nodelist.h" |
| 18 | 18 | ||
| 19 | static int jffs2_trusted_getxattr(struct inode *inode, const char *name, | 19 | static int jffs2_trusted_getxattr(struct dentry *dentry, const char *name, |
| 20 | void *buffer, size_t size) | 20 | void *buffer, size_t size, int type) |
| 21 | { | 21 | { |
| 22 | if (!strcmp(name, "")) | 22 | if (!strcmp(name, "")) |
| 23 | return -EINVAL; | 23 | return -EINVAL; |
| 24 | return do_jffs2_getxattr(inode, JFFS2_XPREFIX_TRUSTED, name, buffer, size); | 24 | return do_jffs2_getxattr(dentry->d_inode, JFFS2_XPREFIX_TRUSTED, |
| 25 | name, buffer, size); | ||
| 25 | } | 26 | } |
| 26 | 27 | ||
| 27 | static int jffs2_trusted_setxattr(struct inode *inode, const char *name, const void *buffer, | 28 | static int jffs2_trusted_setxattr(struct dentry *dentry, const char *name, |
| 28 | size_t size, int flags) | 29 | const void *buffer, size_t size, int flags, int type) |
| 29 | { | 30 | { |
| 30 | if (!strcmp(name, "")) | 31 | if (!strcmp(name, "")) |
| 31 | return -EINVAL; | 32 | return -EINVAL; |
| 32 | return do_jffs2_setxattr(inode, JFFS2_XPREFIX_TRUSTED, name, buffer, size, flags); | 33 | return do_jffs2_setxattr(dentry->d_inode, JFFS2_XPREFIX_TRUSTED, |
| 34 | name, buffer, size, flags); | ||
| 33 | } | 35 | } |
| 34 | 36 | ||
| 35 | static size_t jffs2_trusted_listxattr(struct inode *inode, char *list, size_t list_size, | 37 | static size_t jffs2_trusted_listxattr(struct dentry *dentry, char *list, |
| 36 | const char *name, size_t name_len) | 38 | size_t list_size, const char *name, size_t name_len, int type) |
| 37 | { | 39 | { |
| 38 | size_t retlen = XATTR_TRUSTED_PREFIX_LEN + name_len + 1; | 40 | size_t retlen = XATTR_TRUSTED_PREFIX_LEN + name_len + 1; |
| 39 | 41 | ||
diff --git a/fs/jffs2/xattr_user.c b/fs/jffs2/xattr_user.c index 8bbeab90ada1..8544af67dffe 100644 --- a/fs/jffs2/xattr_user.c +++ b/fs/jffs2/xattr_user.c | |||
| @@ -16,24 +16,26 @@ | |||
| 16 | #include <linux/mtd/mtd.h> | 16 | #include <linux/mtd/mtd.h> |
| 17 | #include "nodelist.h" | 17 | #include "nodelist.h" |
| 18 | 18 | ||
| 19 | static int jffs2_user_getxattr(struct inode *inode, const char *name, | 19 | static int jffs2_user_getxattr(struct dentry *dentry, const char *name, |
| 20 | void *buffer, size_t size) | 20 | void *buffer, size_t size, int type) |
| 21 | { | 21 | { |
| 22 | if (!strcmp(name, "")) | 22 | if (!strcmp(name, "")) |
| 23 | return -EINVAL; | 23 | return -EINVAL; |
| 24 | return do_jffs2_getxattr(inode, JFFS2_XPREFIX_USER, name, buffer, size); | 24 | return do_jffs2_getxattr(dentry->d_inode, JFFS2_XPREFIX_USER, |
| 25 | name, buffer, size); | ||
| 25 | } | 26 | } |
| 26 | 27 | ||
| 27 | static int jffs2_user_setxattr(struct inode *inode, const char *name, const void *buffer, | 28 | static int jffs2_user_setxattr(struct dentry *dentry, const char *name, |
| 28 | size_t size, int flags) | 29 | const void *buffer, size_t size, int flags, int type) |
| 29 | { | 30 | { |
| 30 | if (!strcmp(name, "")) | 31 | if (!strcmp(name, "")) |
| 31 | return -EINVAL; | 32 | return -EINVAL; |
| 32 | return do_jffs2_setxattr(inode, JFFS2_XPREFIX_USER, name, buffer, size, flags); | 33 | return do_jffs2_setxattr(dentry->d_inode, JFFS2_XPREFIX_USER, |
| 34 | name, buffer, size, flags); | ||
| 33 | } | 35 | } |
| 34 | 36 | ||
| 35 | static size_t jffs2_user_listxattr(struct inode *inode, char *list, size_t list_size, | 37 | static size_t jffs2_user_listxattr(struct dentry *dentry, char *list, |
| 36 | const char *name, size_t name_len) | 38 | size_t list_size, const char *name, size_t name_len, int type) |
| 37 | { | 39 | { |
| 38 | size_t retlen = XATTR_USER_PREFIX_LEN + name_len + 1; | 40 | size_t retlen = XATTR_USER_PREFIX_LEN + name_len + 1; |
| 39 | 41 | ||
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c index f26e4d03ada5..d945ea76b445 100644 --- a/fs/jfs/jfs_txnmgr.c +++ b/fs/jfs/jfs_txnmgr.c | |||
| @@ -1292,7 +1292,7 @@ int txCommit(tid_t tid, /* transaction identifier */ | |||
| 1292 | */ | 1292 | */ |
| 1293 | /* | 1293 | /* |
| 1294 | * I believe this code is no longer needed. Splitting I_LOCK | 1294 | * I believe this code is no longer needed. Splitting I_LOCK |
| 1295 | * into two bits, I_LOCK and I_SYNC should prevent this | 1295 | * into two bits, I_NEW and I_SYNC should prevent this |
| 1296 | * deadlock as well. But since I don't have a JFS testload | 1296 | * deadlock as well. But since I don't have a JFS testload |
| 1297 | * to verify this, only a trivial s/I_LOCK/I_SYNC/ was done. | 1297 | * to verify this, only a trivial s/I_LOCK/I_SYNC/ was done. |
| 1298 | * Joern | 1298 | * Joern |
diff --git a/fs/libfs.c b/fs/libfs.c index 219576c52d80..6e8d17e1dc4c 100644 --- a/fs/libfs.c +++ b/fs/libfs.c | |||
| @@ -848,7 +848,6 @@ EXPORT_SYMBOL(simple_write_end); | |||
| 848 | EXPORT_SYMBOL(simple_dir_inode_operations); | 848 | EXPORT_SYMBOL(simple_dir_inode_operations); |
| 849 | EXPORT_SYMBOL(simple_dir_operations); | 849 | EXPORT_SYMBOL(simple_dir_operations); |
| 850 | EXPORT_SYMBOL(simple_empty); | 850 | EXPORT_SYMBOL(simple_empty); |
| 851 | EXPORT_SYMBOL(d_alloc_name); | ||
| 852 | EXPORT_SYMBOL(simple_fill_super); | 851 | EXPORT_SYMBOL(simple_fill_super); |
| 853 | EXPORT_SYMBOL(simple_getattr); | 852 | EXPORT_SYMBOL(simple_getattr); |
| 854 | EXPORT_SYMBOL(simple_link); | 853 | EXPORT_SYMBOL(simple_link); |
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index bd173a6ca3b1..a7966eed3c17 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c | |||
| @@ -11,10 +11,6 @@ | |||
| 11 | #include <linux/time.h> | 11 | #include <linux/time.h> |
| 12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
| 13 | #include <linux/smp_lock.h> | 13 | #include <linux/smp_lock.h> |
| 14 | #include <linux/in.h> | ||
| 15 | #include <linux/sunrpc/svc.h> | ||
| 16 | #include <linux/sunrpc/clnt.h> | ||
| 17 | #include <linux/nfsd/nfsd.h> | ||
| 18 | #include <linux/lockd/lockd.h> | 14 | #include <linux/lockd/lockd.h> |
| 19 | #include <linux/lockd/share.h> | 15 | #include <linux/lockd/share.h> |
| 20 | 16 | ||
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index e1d28ddd2169..56c9519d900a 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c | |||
| @@ -11,10 +11,6 @@ | |||
| 11 | #include <linux/time.h> | 11 | #include <linux/time.h> |
| 12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
| 13 | #include <linux/smp_lock.h> | 13 | #include <linux/smp_lock.h> |
| 14 | #include <linux/in.h> | ||
| 15 | #include <linux/sunrpc/svc.h> | ||
| 16 | #include <linux/sunrpc/clnt.h> | ||
| 17 | #include <linux/nfsd/nfsd.h> | ||
| 18 | #include <linux/lockd/lockd.h> | 14 | #include <linux/lockd/lockd.h> |
| 19 | #include <linux/lockd/share.h> | 15 | #include <linux/lockd/share.h> |
| 20 | 16 | ||
diff --git a/fs/namei.c b/fs/namei.c index 87f97ba90ad1..dad4b80257db 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
| @@ -35,6 +35,8 @@ | |||
| 35 | #include <linux/fs_struct.h> | 35 | #include <linux/fs_struct.h> |
| 36 | #include <asm/uaccess.h> | 36 | #include <asm/uaccess.h> |
| 37 | 37 | ||
| 38 | #include "internal.h" | ||
| 39 | |||
| 38 | #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) | 40 | #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE]) |
| 39 | 41 | ||
| 40 | /* [Feb-1997 T. Schoebel-Theuer] | 42 | /* [Feb-1997 T. Schoebel-Theuer] |
| @@ -108,8 +110,6 @@ | |||
| 108 | * any extra contention... | 110 | * any extra contention... |
| 109 | */ | 111 | */ |
| 110 | 112 | ||
| 111 | static int __link_path_walk(const char *name, struct nameidata *nd); | ||
| 112 | |||
| 113 | /* In order to reduce some races, while at the same time doing additional | 113 | /* In order to reduce some races, while at the same time doing additional |
| 114 | * checking and hopefully speeding things up, we copy filenames to the | 114 | * checking and hopefully speeding things up, we copy filenames to the |
| 115 | * kernel data space before using them.. | 115 | * kernel data space before using them.. |
| @@ -414,36 +414,55 @@ do_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
| 414 | } | 414 | } |
| 415 | 415 | ||
| 416 | /* | 416 | /* |
| 417 | * Internal lookup() using the new generic dcache. | 417 | * force_reval_path - force revalidation of a dentry |
| 418 | * SMP-safe | 418 | * |
| 419 | * In some situations the path walking code will trust dentries without | ||
| 420 | * revalidating them. This causes problems for filesystems that depend on | ||
| 421 | * d_revalidate to handle file opens (e.g. NFSv4). When FS_REVAL_DOT is set | ||
| 422 | * (which indicates that it's possible for the dentry to go stale), force | ||
| 423 | * a d_revalidate call before proceeding. | ||
| 424 | * | ||
| 425 | * Returns 0 if the revalidation was successful. If the revalidation fails, | ||
| 426 | * either return the error returned by d_revalidate or -ESTALE if the | ||
| 427 | * revalidation it just returned 0. If d_revalidate returns 0, we attempt to | ||
| 428 | * invalidate the dentry. It's up to the caller to handle putting references | ||
| 429 | * to the path if necessary. | ||
| 419 | */ | 430 | */ |
| 420 | static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, struct nameidata *nd) | 431 | static int |
| 432 | force_reval_path(struct path *path, struct nameidata *nd) | ||
| 421 | { | 433 | { |
| 422 | struct dentry * dentry = __d_lookup(parent, name); | 434 | int status; |
| 435 | struct dentry *dentry = path->dentry; | ||
| 423 | 436 | ||
| 424 | /* lockess __d_lookup may fail due to concurrent d_move() | 437 | /* |
| 425 | * in some unrelated directory, so try with d_lookup | 438 | * only check on filesystems where it's possible for the dentry to |
| 439 | * become stale. It's assumed that if this flag is set then the | ||
| 440 | * d_revalidate op will also be defined. | ||
| 426 | */ | 441 | */ |
| 427 | if (!dentry) | 442 | if (!(dentry->d_sb->s_type->fs_flags & FS_REVAL_DOT)) |
| 428 | dentry = d_lookup(parent, name); | 443 | return 0; |
| 429 | 444 | ||
| 430 | if (dentry && dentry->d_op && dentry->d_op->d_revalidate) | 445 | status = dentry->d_op->d_revalidate(dentry, nd); |
| 431 | dentry = do_revalidate(dentry, nd); | 446 | if (status > 0) |
| 447 | return 0; | ||
| 432 | 448 | ||
| 433 | return dentry; | 449 | if (!status) { |
| 450 | d_invalidate(dentry); | ||
| 451 | status = -ESTALE; | ||
| 452 | } | ||
| 453 | return status; | ||
| 434 | } | 454 | } |
| 435 | 455 | ||
| 436 | /* | 456 | /* |
| 437 | * Short-cut version of permission(), for calling by | 457 | * Short-cut version of permission(), for calling on directories |
| 438 | * path_walk(), when dcache lock is held. Combines parts | 458 | * during pathname resolution. Combines parts of permission() |
| 439 | * of permission() and generic_permission(), and tests ONLY for | 459 | * and generic_permission(), and tests ONLY for MAY_EXEC permission. |
| 440 | * MAY_EXEC permission. | ||
| 441 | * | 460 | * |
| 442 | * If appropriate, check DAC only. If not appropriate, or | 461 | * If appropriate, check DAC only. If not appropriate, or |
| 443 | * short-cut DAC fails, then call permission() to do more | 462 | * short-cut DAC fails, then call ->permission() to do more |
| 444 | * complete permission check. | 463 | * complete permission check. |
| 445 | */ | 464 | */ |
| 446 | static int exec_permission_lite(struct inode *inode) | 465 | static int exec_permission(struct inode *inode) |
| 447 | { | 466 | { |
| 448 | int ret; | 467 | int ret; |
| 449 | 468 | ||
| @@ -465,99 +484,6 @@ ok: | |||
| 465 | return security_inode_permission(inode, MAY_EXEC); | 484 | return security_inode_permission(inode, MAY_EXEC); |
| 466 | } | 485 | } |
| 467 | 486 | ||
| 468 | /* | ||
| 469 | * This is called when everything else fails, and we actually have | ||
| 470 | * to go to the low-level filesystem to find out what we should do.. | ||
| 471 | * | ||
| 472 | * We get the directory semaphore, and after getting that we also | ||
| 473 | * make sure that nobody added the entry to the dcache in the meantime.. | ||
| 474 | * SMP-safe | ||
| 475 | */ | ||
| 476 | static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, struct nameidata *nd) | ||
| 477 | { | ||
| 478 | struct dentry * result; | ||
| 479 | struct inode *dir = parent->d_inode; | ||
| 480 | |||
| 481 | mutex_lock(&dir->i_mutex); | ||
| 482 | /* | ||
| 483 | * First re-do the cached lookup just in case it was created | ||
| 484 | * while we waited for the directory semaphore.. | ||
| 485 | * | ||
| 486 | * FIXME! This could use version numbering or similar to | ||
| 487 | * avoid unnecessary cache lookups. | ||
| 488 | * | ||
| 489 | * The "dcache_lock" is purely to protect the RCU list walker | ||
| 490 | * from concurrent renames at this point (we mustn't get false | ||
| 491 | * negatives from the RCU list walk here, unlike the optimistic | ||
| 492 | * fast walk). | ||
| 493 | * | ||
| 494 | * so doing d_lookup() (with seqlock), instead of lockfree __d_lookup | ||
| 495 | */ | ||
| 496 | result = d_lookup(parent, name); | ||
| 497 | if (!result) { | ||
| 498 | struct dentry *dentry; | ||
| 499 | |||
| 500 | /* Don't create child dentry for a dead directory. */ | ||
| 501 | result = ERR_PTR(-ENOENT); | ||
| 502 | if (IS_DEADDIR(dir)) | ||
| 503 | goto out_unlock; | ||
| 504 | |||
| 505 | dentry = d_alloc(parent, name); | ||
| 506 | result = ERR_PTR(-ENOMEM); | ||
| 507 | if (dentry) { | ||
| 508 | result = dir->i_op->lookup(dir, dentry, nd); | ||
| 509 | if (result) | ||
| 510 | dput(dentry); | ||
| 511 | else | ||
| 512 | result = dentry; | ||
| 513 | } | ||
| 514 | out_unlock: | ||
| 515 | mutex_unlock(&dir->i_mutex); | ||
| 516 | return result; | ||
| 517 | } | ||
| 518 | |||
| 519 | /* | ||
| 520 | * Uhhuh! Nasty case: the cache was re-populated while | ||
| 521 | * we waited on the semaphore. Need to revalidate. | ||
| 522 | */ | ||
| 523 | mutex_unlock(&dir->i_mutex); | ||
| 524 | if (result->d_op && result->d_op->d_revalidate) { | ||
| 525 | result = do_revalidate(result, nd); | ||
| 526 | if (!result) | ||
| 527 | result = ERR_PTR(-ENOENT); | ||
| 528 | } | ||
| 529 | return result; | ||
| 530 | } | ||
| 531 | |||
| 532 | /* | ||
| 533 | * Wrapper to retry pathname resolution whenever the underlying | ||
| 534 | * file system returns an ESTALE. | ||
| 535 | * | ||
| 536 | * Retry the whole path once, forcing real lookup requests | ||
| 537 | * instead of relying on the dcache. | ||
| 538 | */ | ||
| 539 | static __always_inline int link_path_walk(const char *name, struct nameidata *nd) | ||
| 540 | { | ||
| 541 | struct path save = nd->path; | ||
| 542 | int result; | ||
| 543 | |||
| 544 | /* make sure the stuff we saved doesn't go away */ | ||
| 545 | path_get(&save); | ||
| 546 | |||
| 547 | result = __link_path_walk(name, nd); | ||
| 548 | if (result == -ESTALE) { | ||
| 549 | /* nd->path had been dropped */ | ||
| 550 | nd->path = save; | ||
| 551 | path_get(&nd->path); | ||
| 552 | nd->flags |= LOOKUP_REVAL; | ||
| 553 | result = __link_path_walk(name, nd); | ||
| 554 | } | ||
| 555 | |||
| 556 | path_put(&save); | ||
| 557 | |||
| 558 | return result; | ||
| 559 | } | ||
| 560 | |||
| 561 | static __always_inline void set_root(struct nameidata *nd) | 487 | static __always_inline void set_root(struct nameidata *nd) |
| 562 | { | 488 | { |
| 563 | if (!nd->root.mnt) { | 489 | if (!nd->root.mnt) { |
| @@ -569,6 +495,8 @@ static __always_inline void set_root(struct nameidata *nd) | |||
| 569 | } | 495 | } |
| 570 | } | 496 | } |
| 571 | 497 | ||
| 498 | static int link_path_walk(const char *, struct nameidata *); | ||
| 499 | |||
| 572 | static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *link) | 500 | static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *link) |
| 573 | { | 501 | { |
| 574 | int res = 0; | 502 | int res = 0; |
| @@ -641,11 +569,14 @@ static __always_inline int __do_follow_link(struct path *path, struct nameidata | |||
| 641 | error = 0; | 569 | error = 0; |
| 642 | if (s) | 570 | if (s) |
| 643 | error = __vfs_follow_link(nd, s); | 571 | error = __vfs_follow_link(nd, s); |
| 572 | else if (nd->last_type == LAST_BIND) { | ||
| 573 | error = force_reval_path(&nd->path, nd); | ||
| 574 | if (error) | ||
| 575 | path_put(&nd->path); | ||
| 576 | } | ||
| 644 | if (dentry->d_inode->i_op->put_link) | 577 | if (dentry->d_inode->i_op->put_link) |
| 645 | dentry->d_inode->i_op->put_link(dentry, nd, cookie); | 578 | dentry->d_inode->i_op->put_link(dentry, nd, cookie); |
| 646 | } | 579 | } |
| 647 | path_put(path); | ||
| 648 | |||
| 649 | return error; | 580 | return error; |
| 650 | } | 581 | } |
| 651 | 582 | ||
| @@ -672,6 +603,7 @@ static inline int do_follow_link(struct path *path, struct nameidata *nd) | |||
| 672 | current->total_link_count++; | 603 | current->total_link_count++; |
| 673 | nd->depth++; | 604 | nd->depth++; |
| 674 | err = __do_follow_link(path, nd); | 605 | err = __do_follow_link(path, nd); |
| 606 | path_put(path); | ||
| 675 | current->link_count--; | 607 | current->link_count--; |
| 676 | nd->depth--; | 608 | nd->depth--; |
| 677 | return err; | 609 | return err; |
| @@ -797,8 +729,19 @@ static int do_lookup(struct nameidata *nd, struct qstr *name, | |||
| 797 | struct path *path) | 729 | struct path *path) |
| 798 | { | 730 | { |
| 799 | struct vfsmount *mnt = nd->path.mnt; | 731 | struct vfsmount *mnt = nd->path.mnt; |
| 800 | struct dentry *dentry = __d_lookup(nd->path.dentry, name); | 732 | struct dentry *dentry, *parent; |
| 733 | struct inode *dir; | ||
| 734 | /* | ||
| 735 | * See if the low-level filesystem might want | ||
| 736 | * to use its own hash.. | ||
| 737 | */ | ||
| 738 | if (nd->path.dentry->d_op && nd->path.dentry->d_op->d_hash) { | ||
| 739 | int err = nd->path.dentry->d_op->d_hash(nd->path.dentry, name); | ||
| 740 | if (err < 0) | ||
| 741 | return err; | ||
| 742 | } | ||
| 801 | 743 | ||
| 744 | dentry = __d_lookup(nd->path.dentry, name); | ||
| 802 | if (!dentry) | 745 | if (!dentry) |
| 803 | goto need_lookup; | 746 | goto need_lookup; |
| 804 | if (dentry->d_op && dentry->d_op->d_revalidate) | 747 | if (dentry->d_op && dentry->d_op->d_revalidate) |
| @@ -810,7 +753,59 @@ done: | |||
| 810 | return 0; | 753 | return 0; |
| 811 | 754 | ||
| 812 | need_lookup: | 755 | need_lookup: |
| 813 | dentry = real_lookup(nd->path.dentry, name, nd); | 756 | parent = nd->path.dentry; |
| 757 | dir = parent->d_inode; | ||
| 758 | |||
| 759 | mutex_lock(&dir->i_mutex); | ||
| 760 | /* | ||
| 761 | * First re-do the cached lookup just in case it was created | ||
| 762 | * while we waited for the directory semaphore.. | ||
| 763 | * | ||
| 764 | * FIXME! This could use version numbering or similar to | ||
| 765 | * avoid unnecessary cache lookups. | ||
| 766 | * | ||
| 767 | * The "dcache_lock" is purely to protect the RCU list walker | ||
| 768 | * from concurrent renames at this point (we mustn't get false | ||
| 769 | * negatives from the RCU list walk here, unlike the optimistic | ||
| 770 | * fast walk). | ||
| 771 | * | ||
| 772 | * so doing d_lookup() (with seqlock), instead of lockfree __d_lookup | ||
| 773 | */ | ||
| 774 | dentry = d_lookup(parent, name); | ||
| 775 | if (!dentry) { | ||
| 776 | struct dentry *new; | ||
| 777 | |||
| 778 | /* Don't create child dentry for a dead directory. */ | ||
| 779 | dentry = ERR_PTR(-ENOENT); | ||
| 780 | if (IS_DEADDIR(dir)) | ||
| 781 | goto out_unlock; | ||
| 782 | |||
| 783 | new = d_alloc(parent, name); | ||
| 784 | dentry = ERR_PTR(-ENOMEM); | ||
| 785 | if (new) { | ||
| 786 | dentry = dir->i_op->lookup(dir, new, nd); | ||
| 787 | if (dentry) | ||
| 788 | dput(new); | ||
| 789 | else | ||
| 790 | dentry = new; | ||
| 791 | } | ||
| 792 | out_unlock: | ||
| 793 | mutex_unlock(&dir->i_mutex); | ||
| 794 | if (IS_ERR(dentry)) | ||
| 795 | goto fail; | ||
| 796 | goto done; | ||
| 797 | } | ||
| 798 | |||
| 799 | /* | ||
| 800 | * Uhhuh! Nasty case: the cache was re-populated while | ||
| 801 | * we waited on the semaphore. Need to revalidate. | ||
| 802 | */ | ||
| 803 | mutex_unlock(&dir->i_mutex); | ||
| 804 | if (dentry->d_op && dentry->d_op->d_revalidate) { | ||
| 805 | dentry = do_revalidate(dentry, nd); | ||
| 806 | if (!dentry) | ||
| 807 | dentry = ERR_PTR(-ENOENT); | ||
| 808 | } | ||
| 814 | if (IS_ERR(dentry)) | 809 | if (IS_ERR(dentry)) |
| 815 | goto fail; | 810 | goto fail; |
| 816 | goto done; | 811 | goto done; |
| @@ -835,7 +830,7 @@ fail: | |||
| 835 | * Returns 0 and nd will have valid dentry and mnt on success. | 830 | * Returns 0 and nd will have valid dentry and mnt on success. |
| 836 | * Returns error and drops reference to input namei data on failure. | 831 | * Returns error and drops reference to input namei data on failure. |
| 837 | */ | 832 | */ |
| 838 | static int __link_path_walk(const char *name, struct nameidata *nd) | 833 | static int link_path_walk(const char *name, struct nameidata *nd) |
| 839 | { | 834 | { |
| 840 | struct path next; | 835 | struct path next; |
| 841 | struct inode *inode; | 836 | struct inode *inode; |
| @@ -858,7 +853,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd) | |||
| 858 | unsigned int c; | 853 | unsigned int c; |
| 859 | 854 | ||
| 860 | nd->flags |= LOOKUP_CONTINUE; | 855 | nd->flags |= LOOKUP_CONTINUE; |
| 861 | err = exec_permission_lite(inode); | 856 | err = exec_permission(inode); |
| 862 | if (err) | 857 | if (err) |
| 863 | break; | 858 | break; |
| 864 | 859 | ||
| @@ -898,16 +893,6 @@ static int __link_path_walk(const char *name, struct nameidata *nd) | |||
| 898 | case 1: | 893 | case 1: |
| 899 | continue; | 894 | continue; |
| 900 | } | 895 | } |
| 901 | /* | ||
| 902 | * See if the low-level filesystem might want | ||
| 903 | * to use its own hash.. | ||
| 904 | */ | ||
| 905 | if (nd->path.dentry->d_op && nd->path.dentry->d_op->d_hash) { | ||
| 906 | err = nd->path.dentry->d_op->d_hash(nd->path.dentry, | ||
| 907 | &this); | ||
| 908 | if (err < 0) | ||
| 909 | break; | ||
| 910 | } | ||
| 911 | /* This does the actual lookups.. */ | 896 | /* This does the actual lookups.. */ |
| 912 | err = do_lookup(nd, &this, &next); | 897 | err = do_lookup(nd, &this, &next); |
| 913 | if (err) | 898 | if (err) |
| @@ -953,12 +938,6 @@ last_component: | |||
| 953 | case 1: | 938 | case 1: |
| 954 | goto return_reval; | 939 | goto return_reval; |
| 955 | } | 940 | } |
| 956 | if (nd->path.dentry->d_op && nd->path.dentry->d_op->d_hash) { | ||
| 957 | err = nd->path.dentry->d_op->d_hash(nd->path.dentry, | ||
| 958 | &this); | ||
| 959 | if (err < 0) | ||
| 960 | break; | ||
| 961 | } | ||
| 962 | err = do_lookup(nd, &this, &next); | 941 | err = do_lookup(nd, &this, &next); |
| 963 | if (err) | 942 | if (err) |
| 964 | break; | 943 | break; |
| @@ -1017,8 +996,27 @@ return_err: | |||
| 1017 | 996 | ||
| 1018 | static int path_walk(const char *name, struct nameidata *nd) | 997 | static int path_walk(const char *name, struct nameidata *nd) |
| 1019 | { | 998 | { |
| 999 | struct path save = nd->path; | ||
| 1000 | int result; | ||
| 1001 | |||
| 1020 | current->total_link_count = 0; | 1002 | current->total_link_count = 0; |
| 1021 | return link_path_walk(name, nd); | 1003 | |
| 1004 | /* make sure the stuff we saved doesn't go away */ | ||
| 1005 | path_get(&save); | ||
| 1006 | |||
| 1007 | result = link_path_walk(name, nd); | ||
| 1008 | if (result == -ESTALE) { | ||
| 1009 | /* nd->path had been dropped */ | ||
| 1010 | current->total_link_count = 0; | ||
| 1011 | nd->path = save; | ||
| 1012 | path_get(&nd->path); | ||
| 1013 | nd->flags |= LOOKUP_REVAL; | ||
| 1014 | result = link_path_walk(name, nd); | ||
| 1015 | } | ||
| 1016 | |||
| 1017 | path_put(&save); | ||
| 1018 | |||
| 1019 | return result; | ||
| 1022 | } | 1020 | } |
| 1023 | 1021 | ||
| 1024 | static int path_init(int dfd, const char *name, unsigned int flags, struct nameidata *nd) | 1022 | static int path_init(int dfd, const char *name, unsigned int flags, struct nameidata *nd) |
| @@ -1141,36 +1139,6 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt, | |||
| 1141 | return retval; | 1139 | return retval; |
| 1142 | } | 1140 | } |
| 1143 | 1141 | ||
| 1144 | /** | ||
| 1145 | * path_lookup_open - lookup a file path with open intent | ||
| 1146 | * @dfd: the directory to use as base, or AT_FDCWD | ||
| 1147 | * @name: pointer to file name | ||
| 1148 | * @lookup_flags: lookup intent flags | ||
| 1149 | * @nd: pointer to nameidata | ||
| 1150 | * @open_flags: open intent flags | ||
| 1151 | */ | ||
| 1152 | static int path_lookup_open(int dfd, const char *name, | ||
| 1153 | unsigned int lookup_flags, struct nameidata *nd, int open_flags) | ||
| 1154 | { | ||
| 1155 | struct file *filp = get_empty_filp(); | ||
| 1156 | int err; | ||
| 1157 | |||
| 1158 | if (filp == NULL) | ||
| 1159 | return -ENFILE; | ||
| 1160 | nd->intent.open.file = filp; | ||
| 1161 | nd->intent.open.flags = open_flags; | ||
| 1162 | nd->intent.open.create_mode = 0; | ||
| 1163 | err = do_path_lookup(dfd, name, lookup_flags|LOOKUP_OPEN, nd); | ||
| 1164 | if (IS_ERR(nd->intent.open.file)) { | ||
| 1165 | if (err == 0) { | ||
| 1166 | err = PTR_ERR(nd->intent.open.file); | ||
| 1167 | path_put(&nd->path); | ||
| 1168 | } | ||
| 1169 | } else if (err != 0) | ||
| 1170 | release_open_intent(nd); | ||
| 1171 | return err; | ||
| 1172 | } | ||
| 1173 | |||
| 1174 | static struct dentry *__lookup_hash(struct qstr *name, | 1142 | static struct dentry *__lookup_hash(struct qstr *name, |
| 1175 | struct dentry *base, struct nameidata *nd) | 1143 | struct dentry *base, struct nameidata *nd) |
| 1176 | { | 1144 | { |
| @@ -1191,7 +1159,17 @@ static struct dentry *__lookup_hash(struct qstr *name, | |||
| 1191 | goto out; | 1159 | goto out; |
| 1192 | } | 1160 | } |
| 1193 | 1161 | ||
| 1194 | dentry = cached_lookup(base, name, nd); | 1162 | dentry = __d_lookup(base, name); |
| 1163 | |||
| 1164 | /* lockess __d_lookup may fail due to concurrent d_move() | ||
| 1165 | * in some unrelated directory, so try with d_lookup | ||
| 1166 | */ | ||
| 1167 | if (!dentry) | ||
| 1168 | dentry = d_lookup(base, name); | ||
| 1169 | |||
| 1170 | if (dentry && dentry->d_op && dentry->d_op->d_revalidate) | ||
| 1171 | dentry = do_revalidate(dentry, nd); | ||
| 1172 | |||
| 1195 | if (!dentry) { | 1173 | if (!dentry) { |
| 1196 | struct dentry *new; | 1174 | struct dentry *new; |
| 1197 | 1175 | ||
| @@ -1223,7 +1201,7 @@ static struct dentry *lookup_hash(struct nameidata *nd) | |||
| 1223 | { | 1201 | { |
| 1224 | int err; | 1202 | int err; |
| 1225 | 1203 | ||
| 1226 | err = inode_permission(nd->path.dentry->d_inode, MAY_EXEC); | 1204 | err = exec_permission(nd->path.dentry->d_inode); |
| 1227 | if (err) | 1205 | if (err) |
| 1228 | return ERR_PTR(err); | 1206 | return ERR_PTR(err); |
| 1229 | return __lookup_hash(&nd->last, nd->path.dentry, nd); | 1207 | return __lookup_hash(&nd->last, nd->path.dentry, nd); |
| @@ -1273,7 +1251,7 @@ struct dentry *lookup_one_len(const char *name, struct dentry *base, int len) | |||
| 1273 | if (err) | 1251 | if (err) |
| 1274 | return ERR_PTR(err); | 1252 | return ERR_PTR(err); |
| 1275 | 1253 | ||
| 1276 | err = inode_permission(base->d_inode, MAY_EXEC); | 1254 | err = exec_permission(base->d_inode); |
| 1277 | if (err) | 1255 | if (err) |
| 1278 | return ERR_PTR(err); | 1256 | return ERR_PTR(err); |
| 1279 | return __lookup_hash(&this, base, NULL); | 1257 | return __lookup_hash(&this, base, NULL); |
| @@ -1511,69 +1489,45 @@ int may_open(struct path *path, int acc_mode, int flag) | |||
| 1511 | if (error) | 1489 | if (error) |
| 1512 | return error; | 1490 | return error; |
| 1513 | 1491 | ||
| 1514 | error = ima_path_check(path, acc_mode ? | ||
| 1515 | acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC) : | ||
| 1516 | ACC_MODE(flag) & (MAY_READ | MAY_WRITE), | ||
| 1517 | IMA_COUNT_UPDATE); | ||
| 1518 | |||
| 1519 | if (error) | ||
| 1520 | return error; | ||
| 1521 | /* | 1492 | /* |
| 1522 | * An append-only file must be opened in append mode for writing. | 1493 | * An append-only file must be opened in append mode for writing. |
| 1523 | */ | 1494 | */ |
| 1524 | if (IS_APPEND(inode)) { | 1495 | if (IS_APPEND(inode)) { |
| 1525 | error = -EPERM; | ||
| 1526 | if ((flag & FMODE_WRITE) && !(flag & O_APPEND)) | 1496 | if ((flag & FMODE_WRITE) && !(flag & O_APPEND)) |
| 1527 | goto err_out; | 1497 | return -EPERM; |
| 1528 | if (flag & O_TRUNC) | 1498 | if (flag & O_TRUNC) |
| 1529 | goto err_out; | 1499 | return -EPERM; |
| 1530 | } | 1500 | } |
| 1531 | 1501 | ||
| 1532 | /* O_NOATIME can only be set by the owner or superuser */ | 1502 | /* O_NOATIME can only be set by the owner or superuser */ |
| 1533 | if (flag & O_NOATIME) | 1503 | if (flag & O_NOATIME && !is_owner_or_cap(inode)) |
| 1534 | if (!is_owner_or_cap(inode)) { | 1504 | return -EPERM; |
| 1535 | error = -EPERM; | ||
| 1536 | goto err_out; | ||
| 1537 | } | ||
| 1538 | 1505 | ||
| 1539 | /* | 1506 | /* |
| 1540 | * Ensure there are no outstanding leases on the file. | 1507 | * Ensure there are no outstanding leases on the file. |
| 1541 | */ | 1508 | */ |
| 1542 | error = break_lease(inode, flag); | 1509 | return break_lease(inode, flag); |
| 1543 | if (error) | 1510 | } |
| 1544 | goto err_out; | ||
| 1545 | |||
| 1546 | if (flag & O_TRUNC) { | ||
| 1547 | error = get_write_access(inode); | ||
| 1548 | if (error) | ||
| 1549 | goto err_out; | ||
| 1550 | |||
| 1551 | /* | ||
| 1552 | * Refuse to truncate files with mandatory locks held on them. | ||
| 1553 | */ | ||
| 1554 | error = locks_verify_locked(inode); | ||
| 1555 | if (!error) | ||
| 1556 | error = security_path_truncate(path, 0, | ||
| 1557 | ATTR_MTIME|ATTR_CTIME|ATTR_OPEN); | ||
| 1558 | if (!error) { | ||
| 1559 | vfs_dq_init(inode); | ||
| 1560 | |||
| 1561 | error = do_truncate(dentry, 0, | ||
| 1562 | ATTR_MTIME|ATTR_CTIME|ATTR_OPEN, | ||
| 1563 | NULL); | ||
| 1564 | } | ||
| 1565 | put_write_access(inode); | ||
| 1566 | if (error) | ||
| 1567 | goto err_out; | ||
| 1568 | } else | ||
| 1569 | if (flag & FMODE_WRITE) | ||
| 1570 | vfs_dq_init(inode); | ||
| 1571 | 1511 | ||
| 1572 | return 0; | 1512 | static int handle_truncate(struct path *path) |
| 1573 | err_out: | 1513 | { |
| 1574 | ima_counts_put(path, acc_mode ? | 1514 | struct inode *inode = path->dentry->d_inode; |
| 1575 | acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC) : | 1515 | int error = get_write_access(inode); |
| 1576 | ACC_MODE(flag) & (MAY_READ | MAY_WRITE)); | 1516 | if (error) |
| 1517 | return error; | ||
| 1518 | /* | ||
| 1519 | * Refuse to truncate files with mandatory locks held on them. | ||
| 1520 | */ | ||
| 1521 | error = locks_verify_locked(inode); | ||
| 1522 | if (!error) | ||
| 1523 | error = security_path_truncate(path, 0, | ||
| 1524 | ATTR_MTIME|ATTR_CTIME|ATTR_OPEN); | ||
| 1525 | if (!error) { | ||
| 1526 | error = do_truncate(path->dentry, 0, | ||
| 1527 | ATTR_MTIME|ATTR_CTIME|ATTR_OPEN, | ||
| 1528 | NULL); | ||
| 1529 | } | ||
| 1530 | put_write_access(inode); | ||
| 1577 | return error; | 1531 | return error; |
| 1578 | } | 1532 | } |
| 1579 | 1533 | ||
| @@ -1628,7 +1582,7 @@ static inline int open_to_namei_flags(int flag) | |||
| 1628 | return flag; | 1582 | return flag; |
| 1629 | } | 1583 | } |
| 1630 | 1584 | ||
| 1631 | static int open_will_write_to_fs(int flag, struct inode *inode) | 1585 | static int open_will_truncate(int flag, struct inode *inode) |
| 1632 | { | 1586 | { |
| 1633 | /* | 1587 | /* |
| 1634 | * We'll never write to the fs underlying | 1588 | * We'll never write to the fs underlying |
| @@ -1650,10 +1604,10 @@ struct file *do_filp_open(int dfd, const char *pathname, | |||
| 1650 | struct file *filp; | 1604 | struct file *filp; |
| 1651 | struct nameidata nd; | 1605 | struct nameidata nd; |
| 1652 | int error; | 1606 | int error; |
| 1653 | struct path path; | 1607 | struct path path, save; |
| 1654 | struct dentry *dir; | 1608 | struct dentry *dir; |
| 1655 | int count = 0; | 1609 | int count = 0; |
| 1656 | int will_write; | 1610 | int will_truncate; |
| 1657 | int flag = open_to_namei_flags(open_flag); | 1611 | int flag = open_to_namei_flags(open_flag); |
| 1658 | 1612 | ||
| 1659 | /* | 1613 | /* |
| @@ -1681,8 +1635,22 @@ struct file *do_filp_open(int dfd, const char *pathname, | |||
| 1681 | * The simplest case - just a plain lookup. | 1635 | * The simplest case - just a plain lookup. |
| 1682 | */ | 1636 | */ |
| 1683 | if (!(flag & O_CREAT)) { | 1637 | if (!(flag & O_CREAT)) { |
| 1684 | error = path_lookup_open(dfd, pathname, lookup_flags(flag), | 1638 | filp = get_empty_filp(); |
| 1685 | &nd, flag); | 1639 | |
| 1640 | if (filp == NULL) | ||
| 1641 | return ERR_PTR(-ENFILE); | ||
| 1642 | nd.intent.open.file = filp; | ||
| 1643 | nd.intent.open.flags = flag; | ||
| 1644 | nd.intent.open.create_mode = 0; | ||
| 1645 | error = do_path_lookup(dfd, pathname, | ||
| 1646 | lookup_flags(flag)|LOOKUP_OPEN, &nd); | ||
| 1647 | if (IS_ERR(nd.intent.open.file)) { | ||
| 1648 | if (error == 0) { | ||
| 1649 | error = PTR_ERR(nd.intent.open.file); | ||
| 1650 | path_put(&nd.path); | ||
| 1651 | } | ||
| 1652 | } else if (error) | ||
| 1653 | release_open_intent(&nd); | ||
| 1686 | if (error) | 1654 | if (error) |
| 1687 | return ERR_PTR(error); | 1655 | return ERR_PTR(error); |
| 1688 | goto ok; | 1656 | goto ok; |
| @@ -1758,13 +1726,17 @@ do_last: | |||
| 1758 | goto exit; | 1726 | goto exit; |
| 1759 | } | 1727 | } |
| 1760 | filp = nameidata_to_filp(&nd, open_flag); | 1728 | filp = nameidata_to_filp(&nd, open_flag); |
| 1761 | if (IS_ERR(filp)) | ||
| 1762 | ima_counts_put(&nd.path, | ||
| 1763 | acc_mode & (MAY_READ | MAY_WRITE | | ||
| 1764 | MAY_EXEC)); | ||
| 1765 | mnt_drop_write(nd.path.mnt); | 1729 | mnt_drop_write(nd.path.mnt); |
| 1766 | if (nd.root.mnt) | 1730 | if (nd.root.mnt) |
| 1767 | path_put(&nd.root); | 1731 | path_put(&nd.root); |
| 1732 | if (!IS_ERR(filp)) { | ||
| 1733 | error = ima_path_check(&filp->f_path, filp->f_mode & | ||
| 1734 | (MAY_READ | MAY_WRITE | MAY_EXEC)); | ||
| 1735 | if (error) { | ||
| 1736 | fput(filp); | ||
| 1737 | filp = ERR_PTR(error); | ||
| 1738 | } | ||
| 1739 | } | ||
| 1768 | return filp; | 1740 | return filp; |
| 1769 | } | 1741 | } |
| 1770 | 1742 | ||
| @@ -1792,7 +1764,7 @@ do_last: | |||
| 1792 | 1764 | ||
| 1793 | path_to_nameidata(&path, &nd); | 1765 | path_to_nameidata(&path, &nd); |
| 1794 | error = -EISDIR; | 1766 | error = -EISDIR; |
| 1795 | if (path.dentry->d_inode && S_ISDIR(path.dentry->d_inode->i_mode)) | 1767 | if (S_ISDIR(path.dentry->d_inode->i_mode)) |
| 1796 | goto exit; | 1768 | goto exit; |
| 1797 | ok: | 1769 | ok: |
| 1798 | /* | 1770 | /* |
| @@ -1805,28 +1777,45 @@ ok: | |||
| 1805 | * be avoided. Taking this mnt write here | 1777 | * be avoided. Taking this mnt write here |
| 1806 | * ensures that (2) can not occur. | 1778 | * ensures that (2) can not occur. |
| 1807 | */ | 1779 | */ |
| 1808 | will_write = open_will_write_to_fs(flag, nd.path.dentry->d_inode); | 1780 | will_truncate = open_will_truncate(flag, nd.path.dentry->d_inode); |
| 1809 | if (will_write) { | 1781 | if (will_truncate) { |
| 1810 | error = mnt_want_write(nd.path.mnt); | 1782 | error = mnt_want_write(nd.path.mnt); |
| 1811 | if (error) | 1783 | if (error) |
| 1812 | goto exit; | 1784 | goto exit; |
| 1813 | } | 1785 | } |
| 1814 | error = may_open(&nd.path, acc_mode, flag); | 1786 | error = may_open(&nd.path, acc_mode, flag); |
| 1815 | if (error) { | 1787 | if (error) { |
| 1816 | if (will_write) | 1788 | if (will_truncate) |
| 1817 | mnt_drop_write(nd.path.mnt); | 1789 | mnt_drop_write(nd.path.mnt); |
| 1818 | goto exit; | 1790 | goto exit; |
| 1819 | } | 1791 | } |
| 1820 | filp = nameidata_to_filp(&nd, open_flag); | 1792 | filp = nameidata_to_filp(&nd, open_flag); |
| 1821 | if (IS_ERR(filp)) | 1793 | if (!IS_ERR(filp)) { |
| 1822 | ima_counts_put(&nd.path, | 1794 | error = ima_path_check(&filp->f_path, filp->f_mode & |
| 1823 | acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC)); | 1795 | (MAY_READ | MAY_WRITE | MAY_EXEC)); |
| 1796 | if (error) { | ||
| 1797 | fput(filp); | ||
| 1798 | filp = ERR_PTR(error); | ||
| 1799 | } | ||
| 1800 | } | ||
| 1801 | if (!IS_ERR(filp)) { | ||
| 1802 | if (acc_mode & MAY_WRITE) | ||
| 1803 | vfs_dq_init(nd.path.dentry->d_inode); | ||
| 1804 | |||
| 1805 | if (will_truncate) { | ||
| 1806 | error = handle_truncate(&nd.path); | ||
| 1807 | if (error) { | ||
| 1808 | fput(filp); | ||
| 1809 | filp = ERR_PTR(error); | ||
| 1810 | } | ||
| 1811 | } | ||
| 1812 | } | ||
| 1824 | /* | 1813 | /* |
| 1825 | * It is now safe to drop the mnt write | 1814 | * It is now safe to drop the mnt write |
| 1826 | * because the filp has had a write taken | 1815 | * because the filp has had a write taken |
| 1827 | * on its behalf. | 1816 | * on its behalf. |
| 1828 | */ | 1817 | */ |
| 1829 | if (will_write) | 1818 | if (will_truncate) |
| 1830 | mnt_drop_write(nd.path.mnt); | 1819 | mnt_drop_write(nd.path.mnt); |
| 1831 | if (nd.root.mnt) | 1820 | if (nd.root.mnt) |
| 1832 | path_put(&nd.root); | 1821 | path_put(&nd.root); |
| @@ -1863,7 +1852,18 @@ do_link: | |||
| 1863 | error = security_inode_follow_link(path.dentry, &nd); | 1852 | error = security_inode_follow_link(path.dentry, &nd); |
| 1864 | if (error) | 1853 | if (error) |
| 1865 | goto exit_dput; | 1854 | goto exit_dput; |
| 1855 | save = nd.path; | ||
| 1856 | path_get(&save); | ||
| 1866 | error = __do_follow_link(&path, &nd); | 1857 | error = __do_follow_link(&path, &nd); |
| 1858 | if (error == -ESTALE) { | ||
| 1859 | /* nd.path had been dropped */ | ||
| 1860 | nd.path = save; | ||
| 1861 | path_get(&nd.path); | ||
| 1862 | nd.flags |= LOOKUP_REVAL; | ||
| 1863 | error = __do_follow_link(&path, &nd); | ||
| 1864 | } | ||
| 1865 | path_put(&save); | ||
| 1866 | path_put(&path); | ||
| 1867 | if (error) { | 1867 | if (error) { |
| 1868 | /* Does someone understand code flow here? Or it is only | 1868 | /* Does someone understand code flow here? Or it is only |
| 1869 | * me so stupid? Anathema to whoever designed this non-sense | 1869 | * me so stupid? Anathema to whoever designed this non-sense |
diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig index 2a77bc25d5af..59e5673b4597 100644 --- a/fs/nfs/Kconfig +++ b/fs/nfs/Kconfig | |||
| @@ -90,7 +90,7 @@ config ROOT_NFS | |||
| 90 | If you want your system to mount its root file system via NFS, | 90 | If you want your system to mount its root file system via NFS, |
| 91 | choose Y here. This is common practice for managing systems | 91 | choose Y here. This is common practice for managing systems |
| 92 | without local permanent storage. For details, read | 92 | without local permanent storage. For details, read |
| 93 | <file:Documentation/filesystems/nfsroot.txt>. | 93 | <file:Documentation/filesystems/nfs/nfsroot.txt>. |
| 94 | 94 | ||
| 95 | Most people say N here. | 95 | Most people say N here. |
| 96 | 96 | ||
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 293fa0528a6e..73ab220354df 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c | |||
| @@ -78,11 +78,6 @@ nfs4_callback_svc(void *vrqstp) | |||
| 78 | 78 | ||
| 79 | set_freezable(); | 79 | set_freezable(); |
| 80 | 80 | ||
| 81 | /* | ||
| 82 | * FIXME: do we really need to run this under the BKL? If so, please | ||
| 83 | * add a comment about what it's intended to protect. | ||
| 84 | */ | ||
| 85 | lock_kernel(); | ||
| 86 | while (!kthread_should_stop()) { | 81 | while (!kthread_should_stop()) { |
| 87 | /* | 82 | /* |
| 88 | * Listen for a request on the socket | 83 | * Listen for a request on the socket |
| @@ -104,7 +99,6 @@ nfs4_callback_svc(void *vrqstp) | |||
| 104 | preverr = err; | 99 | preverr = err; |
| 105 | svc_process(rqstp); | 100 | svc_process(rqstp); |
| 106 | } | 101 | } |
| 107 | unlock_kernel(); | ||
| 108 | return 0; | 102 | return 0; |
| 109 | } | 103 | } |
| 110 | 104 | ||
| @@ -160,11 +154,6 @@ nfs41_callback_svc(void *vrqstp) | |||
| 160 | 154 | ||
| 161 | set_freezable(); | 155 | set_freezable(); |
| 162 | 156 | ||
| 163 | /* | ||
| 164 | * FIXME: do we really need to run this under the BKL? If so, please | ||
| 165 | * add a comment about what it's intended to protect. | ||
| 166 | */ | ||
| 167 | lock_kernel(); | ||
| 168 | while (!kthread_should_stop()) { | 157 | while (!kthread_should_stop()) { |
| 169 | prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE); | 158 | prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE); |
| 170 | spin_lock_bh(&serv->sv_cb_lock); | 159 | spin_lock_bh(&serv->sv_cb_lock); |
| @@ -183,7 +172,6 @@ nfs41_callback_svc(void *vrqstp) | |||
| 183 | } | 172 | } |
| 184 | finish_wait(&serv->sv_cb_waitq, &wq); | 173 | finish_wait(&serv->sv_cb_waitq, &wq); |
| 185 | } | 174 | } |
| 186 | unlock_kernel(); | ||
| 187 | return 0; | 175 | return 0; |
| 188 | } | 176 | } |
| 189 | 177 | ||
| @@ -397,6 +385,7 @@ static int nfs_callback_authenticate(struct svc_rqst *rqstp) | |||
| 397 | */ | 385 | */ |
| 398 | static struct svc_version *nfs4_callback_version[] = { | 386 | static struct svc_version *nfs4_callback_version[] = { |
| 399 | [1] = &nfs4_callback_version1, | 387 | [1] = &nfs4_callback_version1, |
| 388 | [4] = &nfs4_callback_version4, | ||
| 400 | }; | 389 | }; |
| 401 | 390 | ||
| 402 | static struct svc_stat nfs4_callback_stats; | 391 | static struct svc_stat nfs4_callback_stats; |
diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h index 07baa8254ca1..d4036be0b589 100644 --- a/fs/nfs/callback.h +++ b/fs/nfs/callback.h | |||
| @@ -106,6 +106,19 @@ struct cb_sequenceres { | |||
| 106 | extern unsigned nfs4_callback_sequence(struct cb_sequenceargs *args, | 106 | extern unsigned nfs4_callback_sequence(struct cb_sequenceargs *args, |
| 107 | struct cb_sequenceres *res); | 107 | struct cb_sequenceres *res); |
| 108 | 108 | ||
| 109 | extern int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation, | ||
| 110 | const nfs4_stateid *stateid); | ||
| 111 | |||
| 112 | #define RCA4_TYPE_MASK_RDATA_DLG 0 | ||
| 113 | #define RCA4_TYPE_MASK_WDATA_DLG 1 | ||
| 114 | |||
| 115 | struct cb_recallanyargs { | ||
| 116 | struct sockaddr *craa_addr; | ||
| 117 | uint32_t craa_objs_to_keep; | ||
| 118 | uint32_t craa_type_mask; | ||
| 119 | }; | ||
| 120 | |||
| 121 | extern unsigned nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy); | ||
| 109 | #endif /* CONFIG_NFS_V4_1 */ | 122 | #endif /* CONFIG_NFS_V4_1 */ |
| 110 | 123 | ||
| 111 | extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res); | 124 | extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res); |
| @@ -114,8 +127,9 @@ extern __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy); | |||
| 114 | #ifdef CONFIG_NFS_V4 | 127 | #ifdef CONFIG_NFS_V4 |
| 115 | extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt); | 128 | extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt); |
| 116 | extern void nfs_callback_down(int minorversion); | 129 | extern void nfs_callback_down(int minorversion); |
| 130 | extern int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation, | ||
| 131 | const nfs4_stateid *stateid); | ||
| 117 | #endif /* CONFIG_NFS_V4 */ | 132 | #endif /* CONFIG_NFS_V4 */ |
| 118 | |||
| 119 | /* | 133 | /* |
| 120 | * nfs41: Callbacks are expected to not cause substantial latency, | 134 | * nfs41: Callbacks are expected to not cause substantial latency, |
| 121 | * so we limit their concurrency to 1 by setting up the maximum number | 135 | * so we limit their concurrency to 1 by setting up the maximum number |
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index b7da1f54da68..defa9b4c470e 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c | |||
| @@ -61,6 +61,16 @@ out: | |||
| 61 | return res->status; | 61 | return res->status; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | static int (*nfs_validate_delegation_stateid(struct nfs_client *clp))(struct nfs_delegation *, const nfs4_stateid *) | ||
| 65 | { | ||
| 66 | #if defined(CONFIG_NFS_V4_1) | ||
| 67 | if (clp->cl_minorversion > 0) | ||
| 68 | return nfs41_validate_delegation_stateid; | ||
| 69 | #endif | ||
| 70 | return nfs4_validate_delegation_stateid; | ||
| 71 | } | ||
| 72 | |||
| 73 | |||
| 64 | __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy) | 74 | __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy) |
| 65 | { | 75 | { |
| 66 | struct nfs_client *clp; | 76 | struct nfs_client *clp; |
| @@ -81,7 +91,8 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy) | |||
| 81 | inode = nfs_delegation_find_inode(clp, &args->fh); | 91 | inode = nfs_delegation_find_inode(clp, &args->fh); |
| 82 | if (inode != NULL) { | 92 | if (inode != NULL) { |
| 83 | /* Set up a helper thread to actually return the delegation */ | 93 | /* Set up a helper thread to actually return the delegation */ |
| 84 | switch(nfs_async_inode_return_delegation(inode, &args->stateid)) { | 94 | switch (nfs_async_inode_return_delegation(inode, &args->stateid, |
| 95 | nfs_validate_delegation_stateid(clp))) { | ||
| 85 | case 0: | 96 | case 0: |
| 86 | res = 0; | 97 | res = 0; |
| 87 | break; | 98 | break; |
| @@ -102,8 +113,31 @@ out: | |||
| 102 | return res; | 113 | return res; |
| 103 | } | 114 | } |
| 104 | 115 | ||
| 116 | int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid) | ||
| 117 | { | ||
| 118 | if (delegation == NULL || memcmp(delegation->stateid.data, stateid->data, | ||
| 119 | sizeof(delegation->stateid.data)) != 0) | ||
| 120 | return 0; | ||
| 121 | return 1; | ||
| 122 | } | ||
| 123 | |||
| 105 | #if defined(CONFIG_NFS_V4_1) | 124 | #if defined(CONFIG_NFS_V4_1) |
| 106 | 125 | ||
| 126 | int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid) | ||
| 127 | { | ||
| 128 | if (delegation == NULL) | ||
| 129 | return 0; | ||
| 130 | |||
| 131 | /* seqid is 4-bytes long */ | ||
| 132 | if (((u32 *) &stateid->data)[0] != 0) | ||
| 133 | return 0; | ||
| 134 | if (memcmp(&delegation->stateid.data[4], &stateid->data[4], | ||
| 135 | sizeof(stateid->data)-4)) | ||
| 136 | return 0; | ||
| 137 | |||
| 138 | return 1; | ||
| 139 | } | ||
| 140 | |||
| 107 | /* | 141 | /* |
| 108 | * Validate the sequenceID sent by the server. | 142 | * Validate the sequenceID sent by the server. |
| 109 | * Return success if the sequenceID is one more than what we last saw on | 143 | * Return success if the sequenceID is one more than what we last saw on |
| @@ -227,4 +261,32 @@ out: | |||
| 227 | return res->csr_status; | 261 | return res->csr_status; |
| 228 | } | 262 | } |
| 229 | 263 | ||
| 264 | unsigned nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy) | ||
| 265 | { | ||
| 266 | struct nfs_client *clp; | ||
| 267 | int status; | ||
| 268 | fmode_t flags = 0; | ||
| 269 | |||
| 270 | status = htonl(NFS4ERR_OP_NOT_IN_SESSION); | ||
| 271 | clp = nfs_find_client(args->craa_addr, 4); | ||
| 272 | if (clp == NULL) | ||
| 273 | goto out; | ||
| 274 | |||
| 275 | dprintk("NFS: RECALL_ANY callback request from %s\n", | ||
| 276 | rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR)); | ||
| 277 | |||
| 278 | if (test_bit(RCA4_TYPE_MASK_RDATA_DLG, (const unsigned long *) | ||
| 279 | &args->craa_type_mask)) | ||
| 280 | flags = FMODE_READ; | ||
| 281 | if (test_bit(RCA4_TYPE_MASK_WDATA_DLG, (const unsigned long *) | ||
| 282 | &args->craa_type_mask)) | ||
| 283 | flags |= FMODE_WRITE; | ||
| 284 | |||
| 285 | if (flags) | ||
| 286 | nfs_expire_all_delegation_types(clp, flags); | ||
| 287 | status = htonl(NFS4_OK); | ||
| 288 | out: | ||
| 289 | dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); | ||
| 290 | return status; | ||
| 291 | } | ||
| 230 | #endif /* CONFIG_NFS_V4_1 */ | 292 | #endif /* CONFIG_NFS_V4_1 */ |
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c index 76b0aa0f73bf..8e1a2511c8be 100644 --- a/fs/nfs/callback_xdr.c +++ b/fs/nfs/callback_xdr.c | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | #if defined(CONFIG_NFS_V4_1) | 23 | #if defined(CONFIG_NFS_V4_1) |
| 24 | #define CB_OP_SEQUENCE_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \ | 24 | #define CB_OP_SEQUENCE_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \ |
| 25 | 4 + 1 + 3) | 25 | 4 + 1 + 3) |
| 26 | #define CB_OP_RECALLANY_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) | ||
| 26 | #endif /* CONFIG_NFS_V4_1 */ | 27 | #endif /* CONFIG_NFS_V4_1 */ |
| 27 | 28 | ||
| 28 | #define NFSDBG_FACILITY NFSDBG_CALLBACK | 29 | #define NFSDBG_FACILITY NFSDBG_CALLBACK |
| @@ -326,6 +327,25 @@ out_free: | |||
| 326 | goto out; | 327 | goto out; |
| 327 | } | 328 | } |
| 328 | 329 | ||
| 330 | static unsigned decode_recallany_args(struct svc_rqst *rqstp, | ||
| 331 | struct xdr_stream *xdr, | ||
| 332 | struct cb_recallanyargs *args) | ||
| 333 | { | ||
| 334 | uint32_t *p; | ||
| 335 | |||
| 336 | args->craa_addr = svc_addr(rqstp); | ||
| 337 | p = read_buf(xdr, 4); | ||
| 338 | if (unlikely(p == NULL)) | ||
| 339 | return htonl(NFS4ERR_BADXDR); | ||
| 340 | args->craa_objs_to_keep = ntohl(*p++); | ||
| 341 | p = read_buf(xdr, 4); | ||
| 342 | if (unlikely(p == NULL)) | ||
| 343 | return htonl(NFS4ERR_BADXDR); | ||
| 344 | args->craa_type_mask = ntohl(*p); | ||
| 345 | |||
| 346 | return 0; | ||
| 347 | } | ||
| 348 | |||
| 329 | #endif /* CONFIG_NFS_V4_1 */ | 349 | #endif /* CONFIG_NFS_V4_1 */ |
| 330 | 350 | ||
| 331 | static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) | 351 | static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) |
| @@ -533,6 +553,7 @@ preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op) | |||
| 533 | case OP_CB_GETATTR: | 553 | case OP_CB_GETATTR: |
| 534 | case OP_CB_RECALL: | 554 | case OP_CB_RECALL: |
| 535 | case OP_CB_SEQUENCE: | 555 | case OP_CB_SEQUENCE: |
| 556 | case OP_CB_RECALL_ANY: | ||
| 536 | *op = &callback_ops[op_nr]; | 557 | *op = &callback_ops[op_nr]; |
| 537 | break; | 558 | break; |
| 538 | 559 | ||
| @@ -540,7 +561,6 @@ preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op) | |||
| 540 | case OP_CB_NOTIFY_DEVICEID: | 561 | case OP_CB_NOTIFY_DEVICEID: |
| 541 | case OP_CB_NOTIFY: | 562 | case OP_CB_NOTIFY: |
| 542 | case OP_CB_PUSH_DELEG: | 563 | case OP_CB_PUSH_DELEG: |
| 543 | case OP_CB_RECALL_ANY: | ||
| 544 | case OP_CB_RECALLABLE_OBJ_AVAIL: | 564 | case OP_CB_RECALLABLE_OBJ_AVAIL: |
| 545 | case OP_CB_RECALL_SLOT: | 565 | case OP_CB_RECALL_SLOT: |
| 546 | case OP_CB_WANTS_CANCELLED: | 566 | case OP_CB_WANTS_CANCELLED: |
| @@ -688,6 +708,11 @@ static struct callback_op callback_ops[] = { | |||
| 688 | .encode_res = (callback_encode_res_t)encode_cb_sequence_res, | 708 | .encode_res = (callback_encode_res_t)encode_cb_sequence_res, |
| 689 | .res_maxsize = CB_OP_SEQUENCE_RES_MAXSZ, | 709 | .res_maxsize = CB_OP_SEQUENCE_RES_MAXSZ, |
| 690 | }, | 710 | }, |
| 711 | [OP_CB_RECALL_ANY] = { | ||
| 712 | .process_op = (callback_process_op_t)nfs4_callback_recallany, | ||
| 713 | .decode_args = (callback_decode_arg_t)decode_recallany_args, | ||
| 714 | .res_maxsize = CB_OP_RECALLANY_RES_MAXSZ, | ||
| 715 | }, | ||
| 691 | #endif /* CONFIG_NFS_V4_1 */ | 716 | #endif /* CONFIG_NFS_V4_1 */ |
| 692 | }; | 717 | }; |
| 693 | 718 | ||
| @@ -718,3 +743,10 @@ struct svc_version nfs4_callback_version1 = { | |||
| 718 | .vs_dispatch = NULL, | 743 | .vs_dispatch = NULL, |
| 719 | }; | 744 | }; |
| 720 | 745 | ||
| 746 | struct svc_version nfs4_callback_version4 = { | ||
| 747 | .vs_vers = 4, | ||
| 748 | .vs_nproc = ARRAY_SIZE(nfs4_callback_procedures1), | ||
| 749 | .vs_proc = nfs4_callback_procedures1, | ||
| 750 | .vs_xdrsize = NFS4_CALLBACK_XDRSIZE, | ||
| 751 | .vs_dispatch = NULL, | ||
| 752 | }; | ||
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 99ea196f071f..ee77713ce68b 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
| @@ -1260,10 +1260,20 @@ error: | |||
| 1260 | static void nfs4_session_set_rwsize(struct nfs_server *server) | 1260 | static void nfs4_session_set_rwsize(struct nfs_server *server) |
| 1261 | { | 1261 | { |
| 1262 | #ifdef CONFIG_NFS_V4_1 | 1262 | #ifdef CONFIG_NFS_V4_1 |
| 1263 | struct nfs4_session *sess; | ||
| 1264 | u32 server_resp_sz; | ||
| 1265 | u32 server_rqst_sz; | ||
| 1266 | |||
| 1263 | if (!nfs4_has_session(server->nfs_client)) | 1267 | if (!nfs4_has_session(server->nfs_client)) |
| 1264 | return; | 1268 | return; |
| 1265 | server->rsize = server->nfs_client->cl_session->fc_attrs.max_resp_sz; | 1269 | sess = server->nfs_client->cl_session; |
| 1266 | server->wsize = server->nfs_client->cl_session->fc_attrs.max_rqst_sz; | 1270 | server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead; |
| 1271 | server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead; | ||
| 1272 | |||
| 1273 | if (server->rsize > server_resp_sz) | ||
| 1274 | server->rsize = server_resp_sz; | ||
| 1275 | if (server->wsize > server_rqst_sz) | ||
| 1276 | server->wsize = server_rqst_sz; | ||
| 1267 | #endif /* CONFIG_NFS_V4_1 */ | 1277 | #endif /* CONFIG_NFS_V4_1 */ |
| 1268 | } | 1278 | } |
| 1269 | 1279 | ||
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 6dd48a4405b4..2563bebc4c67 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c | |||
| @@ -92,7 +92,7 @@ out: | |||
| 92 | return status; | 92 | return status; |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | static void nfs_delegation_claim_opens(struct inode *inode, const nfs4_stateid *stateid) | 95 | static int nfs_delegation_claim_opens(struct inode *inode, const nfs4_stateid *stateid) |
| 96 | { | 96 | { |
| 97 | struct nfs_inode *nfsi = NFS_I(inode); | 97 | struct nfs_inode *nfsi = NFS_I(inode); |
| 98 | struct nfs_open_context *ctx; | 98 | struct nfs_open_context *ctx; |
| @@ -116,10 +116,11 @@ again: | |||
| 116 | err = nfs_delegation_claim_locks(ctx, state); | 116 | err = nfs_delegation_claim_locks(ctx, state); |
| 117 | put_nfs_open_context(ctx); | 117 | put_nfs_open_context(ctx); |
| 118 | if (err != 0) | 118 | if (err != 0) |
| 119 | return; | 119 | return err; |
| 120 | goto again; | 120 | goto again; |
| 121 | } | 121 | } |
| 122 | spin_unlock(&inode->i_lock); | 122 | spin_unlock(&inode->i_lock); |
| 123 | return 0; | ||
| 123 | } | 124 | } |
| 124 | 125 | ||
| 125 | /* | 126 | /* |
| @@ -261,30 +262,34 @@ static void nfs_msync_inode(struct inode *inode) | |||
| 261 | /* | 262 | /* |
| 262 | * Basic procedure for returning a delegation to the server | 263 | * Basic procedure for returning a delegation to the server |
| 263 | */ | 264 | */ |
| 264 | static int __nfs_inode_return_delegation(struct inode *inode, struct nfs_delegation *delegation) | 265 | static int __nfs_inode_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync) |
| 265 | { | 266 | { |
| 266 | struct nfs_inode *nfsi = NFS_I(inode); | 267 | struct nfs_inode *nfsi = NFS_I(inode); |
| 268 | int err; | ||
| 267 | 269 | ||
| 268 | nfs_msync_inode(inode); | ||
| 269 | /* | 270 | /* |
| 270 | * Guard against new delegated open/lock/unlock calls and against | 271 | * Guard against new delegated open/lock/unlock calls and against |
| 271 | * state recovery | 272 | * state recovery |
| 272 | */ | 273 | */ |
| 273 | down_write(&nfsi->rwsem); | 274 | down_write(&nfsi->rwsem); |
| 274 | nfs_delegation_claim_opens(inode, &delegation->stateid); | 275 | err = nfs_delegation_claim_opens(inode, &delegation->stateid); |
| 275 | up_write(&nfsi->rwsem); | 276 | up_write(&nfsi->rwsem); |
| 276 | nfs_msync_inode(inode); | 277 | if (err) |
| 278 | goto out; | ||
| 277 | 279 | ||
| 278 | return nfs_do_return_delegation(inode, delegation, 1); | 280 | err = nfs_do_return_delegation(inode, delegation, issync); |
| 281 | out: | ||
| 282 | return err; | ||
| 279 | } | 283 | } |
| 280 | 284 | ||
| 281 | /* | 285 | /* |
| 282 | * Return all delegations that have been marked for return | 286 | * Return all delegations that have been marked for return |
| 283 | */ | 287 | */ |
| 284 | void nfs_client_return_marked_delegations(struct nfs_client *clp) | 288 | int nfs_client_return_marked_delegations(struct nfs_client *clp) |
| 285 | { | 289 | { |
| 286 | struct nfs_delegation *delegation; | 290 | struct nfs_delegation *delegation; |
| 287 | struct inode *inode; | 291 | struct inode *inode; |
| 292 | int err = 0; | ||
| 288 | 293 | ||
| 289 | restart: | 294 | restart: |
| 290 | rcu_read_lock(); | 295 | rcu_read_lock(); |
| @@ -298,12 +303,18 @@ restart: | |||
| 298 | delegation = nfs_detach_delegation_locked(NFS_I(inode), NULL); | 303 | delegation = nfs_detach_delegation_locked(NFS_I(inode), NULL); |
| 299 | spin_unlock(&clp->cl_lock); | 304 | spin_unlock(&clp->cl_lock); |
| 300 | rcu_read_unlock(); | 305 | rcu_read_unlock(); |
| 301 | if (delegation != NULL) | 306 | if (delegation != NULL) { |
| 302 | __nfs_inode_return_delegation(inode, delegation); | 307 | filemap_flush(inode->i_mapping); |
| 308 | err = __nfs_inode_return_delegation(inode, delegation, 0); | ||
| 309 | } | ||
| 303 | iput(inode); | 310 | iput(inode); |
| 304 | goto restart; | 311 | if (!err) |
| 312 | goto restart; | ||
| 313 | set_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state); | ||
| 314 | return err; | ||
| 305 | } | 315 | } |
| 306 | rcu_read_unlock(); | 316 | rcu_read_unlock(); |
| 317 | return 0; | ||
| 307 | } | 318 | } |
| 308 | 319 | ||
| 309 | /* | 320 | /* |
| @@ -338,8 +349,10 @@ int nfs_inode_return_delegation(struct inode *inode) | |||
| 338 | spin_lock(&clp->cl_lock); | 349 | spin_lock(&clp->cl_lock); |
| 339 | delegation = nfs_detach_delegation_locked(nfsi, NULL); | 350 | delegation = nfs_detach_delegation_locked(nfsi, NULL); |
| 340 | spin_unlock(&clp->cl_lock); | 351 | spin_unlock(&clp->cl_lock); |
| 341 | if (delegation != NULL) | 352 | if (delegation != NULL) { |
| 342 | err = __nfs_inode_return_delegation(inode, delegation); | 353 | nfs_msync_inode(inode); |
| 354 | err = __nfs_inode_return_delegation(inode, delegation, 1); | ||
| 355 | } | ||
| 343 | } | 356 | } |
| 344 | return err; | 357 | return err; |
| 345 | } | 358 | } |
| @@ -368,33 +381,47 @@ void nfs_super_return_all_delegations(struct super_block *sb) | |||
| 368 | spin_unlock(&delegation->lock); | 381 | spin_unlock(&delegation->lock); |
| 369 | } | 382 | } |
| 370 | rcu_read_unlock(); | 383 | rcu_read_unlock(); |
| 371 | nfs_client_return_marked_delegations(clp); | 384 | if (nfs_client_return_marked_delegations(clp) != 0) |
| 385 | nfs4_schedule_state_manager(clp); | ||
| 372 | } | 386 | } |
| 373 | 387 | ||
| 374 | static void nfs_client_mark_return_all_delegations(struct nfs_client *clp) | 388 | static |
| 389 | void nfs_client_mark_return_all_delegation_types(struct nfs_client *clp, fmode_t flags) | ||
| 375 | { | 390 | { |
| 376 | struct nfs_delegation *delegation; | 391 | struct nfs_delegation *delegation; |
| 377 | 392 | ||
| 378 | rcu_read_lock(); | 393 | rcu_read_lock(); |
| 379 | list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) { | 394 | list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) { |
| 380 | set_bit(NFS_DELEGATION_RETURN, &delegation->flags); | 395 | if ((delegation->type == (FMODE_READ|FMODE_WRITE)) && !(flags & FMODE_WRITE)) |
| 381 | set_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state); | 396 | continue; |
| 397 | if (delegation->type & flags) | ||
| 398 | nfs_mark_return_delegation(clp, delegation); | ||
| 382 | } | 399 | } |
| 383 | rcu_read_unlock(); | 400 | rcu_read_unlock(); |
| 384 | } | 401 | } |
| 385 | 402 | ||
| 403 | static void nfs_client_mark_return_all_delegations(struct nfs_client *clp) | ||
| 404 | { | ||
| 405 | nfs_client_mark_return_all_delegation_types(clp, FMODE_READ|FMODE_WRITE); | ||
| 406 | } | ||
| 407 | |||
| 386 | static void nfs_delegation_run_state_manager(struct nfs_client *clp) | 408 | static void nfs_delegation_run_state_manager(struct nfs_client *clp) |
| 387 | { | 409 | { |
| 388 | if (test_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) | 410 | if (test_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) |
| 389 | nfs4_schedule_state_manager(clp); | 411 | nfs4_schedule_state_manager(clp); |
| 390 | } | 412 | } |
| 391 | 413 | ||
| 392 | void nfs_expire_all_delegations(struct nfs_client *clp) | 414 | void nfs_expire_all_delegation_types(struct nfs_client *clp, fmode_t flags) |
| 393 | { | 415 | { |
| 394 | nfs_client_mark_return_all_delegations(clp); | 416 | nfs_client_mark_return_all_delegation_types(clp, flags); |
| 395 | nfs_delegation_run_state_manager(clp); | 417 | nfs_delegation_run_state_manager(clp); |
| 396 | } | 418 | } |
| 397 | 419 | ||
| 420 | void nfs_expire_all_delegations(struct nfs_client *clp) | ||
| 421 | { | ||
| 422 | nfs_expire_all_delegation_types(clp, FMODE_READ|FMODE_WRITE); | ||
| 423 | } | ||
| 424 | |||
| 398 | /* | 425 | /* |
| 399 | * Return all delegations following an NFS4ERR_CB_PATH_DOWN error. | 426 | * Return all delegations following an NFS4ERR_CB_PATH_DOWN error. |
| 400 | */ | 427 | */ |
| @@ -413,8 +440,7 @@ static void nfs_client_mark_return_unreferenced_delegations(struct nfs_client *c | |||
| 413 | list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) { | 440 | list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) { |
| 414 | if (test_and_clear_bit(NFS_DELEGATION_REFERENCED, &delegation->flags)) | 441 | if (test_and_clear_bit(NFS_DELEGATION_REFERENCED, &delegation->flags)) |
| 415 | continue; | 442 | continue; |
| 416 | set_bit(NFS_DELEGATION_RETURN, &delegation->flags); | 443 | nfs_mark_return_delegation(clp, delegation); |
| 417 | set_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state); | ||
| 418 | } | 444 | } |
| 419 | rcu_read_unlock(); | 445 | rcu_read_unlock(); |
| 420 | } | 446 | } |
| @@ -428,18 +454,21 @@ void nfs_expire_unreferenced_delegations(struct nfs_client *clp) | |||
| 428 | /* | 454 | /* |
| 429 | * Asynchronous delegation recall! | 455 | * Asynchronous delegation recall! |
| 430 | */ | 456 | */ |
| 431 | int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid) | 457 | int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid, |
| 458 | int (*validate_stateid)(struct nfs_delegation *delegation, | ||
| 459 | const nfs4_stateid *stateid)) | ||
| 432 | { | 460 | { |
| 433 | struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; | 461 | struct nfs_client *clp = NFS_SERVER(inode)->nfs_client; |
| 434 | struct nfs_delegation *delegation; | 462 | struct nfs_delegation *delegation; |
| 435 | 463 | ||
| 436 | rcu_read_lock(); | 464 | rcu_read_lock(); |
| 437 | delegation = rcu_dereference(NFS_I(inode)->delegation); | 465 | delegation = rcu_dereference(NFS_I(inode)->delegation); |
| 438 | if (delegation == NULL || memcmp(delegation->stateid.data, stateid->data, | 466 | |
| 439 | sizeof(delegation->stateid.data)) != 0) { | 467 | if (!validate_stateid(delegation, stateid)) { |
| 440 | rcu_read_unlock(); | 468 | rcu_read_unlock(); |
| 441 | return -ENOENT; | 469 | return -ENOENT; |
| 442 | } | 470 | } |
| 471 | |||
| 443 | nfs_mark_return_delegation(clp, delegation); | 472 | nfs_mark_return_delegation(clp, delegation); |
| 444 | rcu_read_unlock(); | 473 | rcu_read_unlock(); |
| 445 | nfs_delegation_run_state_manager(clp); | 474 | nfs_delegation_run_state_manager(clp); |
diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h index 09f383795174..944b627ec6e1 100644 --- a/fs/nfs/delegation.h +++ b/fs/nfs/delegation.h | |||
| @@ -34,15 +34,18 @@ enum { | |||
| 34 | int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); | 34 | int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); |
| 35 | void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); | 35 | void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res); |
| 36 | int nfs_inode_return_delegation(struct inode *inode); | 36 | int nfs_inode_return_delegation(struct inode *inode); |
| 37 | int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid); | 37 | int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid, |
| 38 | int (*validate_stateid)(struct nfs_delegation *delegation, | ||
| 39 | const nfs4_stateid *stateid)); | ||
| 38 | void nfs_inode_return_delegation_noreclaim(struct inode *inode); | 40 | void nfs_inode_return_delegation_noreclaim(struct inode *inode); |
| 39 | 41 | ||
| 40 | struct inode *nfs_delegation_find_inode(struct nfs_client *clp, const struct nfs_fh *fhandle); | 42 | struct inode *nfs_delegation_find_inode(struct nfs_client *clp, const struct nfs_fh *fhandle); |
| 41 | void nfs_super_return_all_delegations(struct super_block *sb); | 43 | void nfs_super_return_all_delegations(struct super_block *sb); |
| 42 | void nfs_expire_all_delegations(struct nfs_client *clp); | 44 | void nfs_expire_all_delegations(struct nfs_client *clp); |
| 45 | void nfs_expire_all_delegation_types(struct nfs_client *clp, fmode_t flags); | ||
| 43 | void nfs_expire_unreferenced_delegations(struct nfs_client *clp); | 46 | void nfs_expire_unreferenced_delegations(struct nfs_client *clp); |
| 44 | void nfs_handle_cb_pathdown(struct nfs_client *clp); | 47 | void nfs_handle_cb_pathdown(struct nfs_client *clp); |
| 45 | void nfs_client_return_marked_delegations(struct nfs_client *clp); | 48 | int nfs_client_return_marked_delegations(struct nfs_client *clp); |
| 46 | 49 | ||
| 47 | void nfs_delegation_mark_reclaim(struct nfs_client *clp); | 50 | void nfs_delegation_mark_reclaim(struct nfs_client *clp); |
| 48 | void nfs_delegation_reap_unclaimed(struct nfs_client *clp); | 51 | void nfs_delegation_reap_unclaimed(struct nfs_client *clp); |
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 7cb298525eef..2c5ace4f00a7 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
| @@ -1579,55 +1579,46 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 1579 | struct dentry *dentry = NULL, *rehash = NULL; | 1579 | struct dentry *dentry = NULL, *rehash = NULL; |
| 1580 | int error = -EBUSY; | 1580 | int error = -EBUSY; |
| 1581 | 1581 | ||
| 1582 | /* | ||
| 1583 | * To prevent any new references to the target during the rename, | ||
| 1584 | * we unhash the dentry and free the inode in advance. | ||
| 1585 | */ | ||
| 1586 | if (!d_unhashed(new_dentry)) { | ||
| 1587 | d_drop(new_dentry); | ||
| 1588 | rehash = new_dentry; | ||
| 1589 | } | ||
| 1590 | |||
| 1591 | dfprintk(VFS, "NFS: rename(%s/%s -> %s/%s, ct=%d)\n", | 1582 | dfprintk(VFS, "NFS: rename(%s/%s -> %s/%s, ct=%d)\n", |
| 1592 | old_dentry->d_parent->d_name.name, old_dentry->d_name.name, | 1583 | old_dentry->d_parent->d_name.name, old_dentry->d_name.name, |
| 1593 | new_dentry->d_parent->d_name.name, new_dentry->d_name.name, | 1584 | new_dentry->d_parent->d_name.name, new_dentry->d_name.name, |
| 1594 | atomic_read(&new_dentry->d_count)); | 1585 | atomic_read(&new_dentry->d_count)); |
| 1595 | 1586 | ||
| 1596 | /* | 1587 | /* |
| 1597 | * First check whether the target is busy ... we can't | 1588 | * For non-directories, check whether the target is busy and if so, |
| 1598 | * safely do _any_ rename if the target is in use. | 1589 | * make a copy of the dentry and then do a silly-rename. If the |
| 1599 | * | 1590 | * silly-rename succeeds, the copied dentry is hashed and becomes |
| 1600 | * For files, make a copy of the dentry and then do a | 1591 | * the new target. |
| 1601 | * silly-rename. If the silly-rename succeeds, the | ||
| 1602 | * copied dentry is hashed and becomes the new target. | ||
| 1603 | */ | 1592 | */ |
| 1604 | if (!new_inode) | 1593 | if (new_inode && !S_ISDIR(new_inode->i_mode)) { |
| 1605 | goto go_ahead; | 1594 | /* |
| 1606 | if (S_ISDIR(new_inode->i_mode)) { | 1595 | * To prevent any new references to the target during the |
| 1607 | error = -EISDIR; | 1596 | * rename, we unhash the dentry in advance. |
| 1608 | if (!S_ISDIR(old_inode->i_mode)) | 1597 | */ |
| 1609 | goto out; | 1598 | if (!d_unhashed(new_dentry)) { |
| 1610 | } else if (atomic_read(&new_dentry->d_count) > 2) { | 1599 | d_drop(new_dentry); |
| 1611 | int err; | 1600 | rehash = new_dentry; |
| 1612 | /* copy the target dentry's name */ | 1601 | } |
| 1613 | dentry = d_alloc(new_dentry->d_parent, | 1602 | |
| 1614 | &new_dentry->d_name); | 1603 | if (atomic_read(&new_dentry->d_count) > 2) { |
| 1615 | if (!dentry) | 1604 | int err; |
| 1616 | goto out; | 1605 | |
| 1606 | /* copy the target dentry's name */ | ||
| 1607 | dentry = d_alloc(new_dentry->d_parent, | ||
| 1608 | &new_dentry->d_name); | ||
| 1609 | if (!dentry) | ||
| 1610 | goto out; | ||
| 1617 | 1611 | ||
| 1618 | /* silly-rename the existing target ... */ | 1612 | /* silly-rename the existing target ... */ |
| 1619 | err = nfs_sillyrename(new_dir, new_dentry); | 1613 | err = nfs_sillyrename(new_dir, new_dentry); |
| 1620 | if (!err) { | 1614 | if (err) |
| 1621 | new_dentry = rehash = dentry; | 1615 | goto out; |
| 1616 | |||
| 1617 | new_dentry = dentry; | ||
| 1622 | new_inode = NULL; | 1618 | new_inode = NULL; |
| 1623 | /* instantiate the replacement target */ | 1619 | } |
| 1624 | d_instantiate(new_dentry, NULL); | ||
| 1625 | } else if (atomic_read(&new_dentry->d_count) > 1) | ||
| 1626 | /* dentry still busy? */ | ||
| 1627 | goto out; | ||
| 1628 | } | 1620 | } |
| 1629 | 1621 | ||
| 1630 | go_ahead: | ||
| 1631 | /* | 1622 | /* |
| 1632 | * ... prune child dentries and writebacks if needed. | 1623 | * ... prune child dentries and writebacks if needed. |
| 1633 | */ | 1624 | */ |
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c index f4d54ba97cc6..95e1ca765d47 100644 --- a/fs/nfs/dns_resolve.c +++ b/fs/nfs/dns_resolve.c | |||
| @@ -146,7 +146,7 @@ static int nfs_dns_show(struct seq_file *m, struct cache_detail *cd, | |||
| 146 | return 0; | 146 | return 0; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | struct nfs_dns_ent *nfs_dns_lookup(struct cache_detail *cd, | 149 | static struct nfs_dns_ent *nfs_dns_lookup(struct cache_detail *cd, |
| 150 | struct nfs_dns_ent *key) | 150 | struct nfs_dns_ent *key) |
| 151 | { | 151 | { |
| 152 | struct cache_head *ch; | 152 | struct cache_head *ch; |
| @@ -159,7 +159,7 @@ struct nfs_dns_ent *nfs_dns_lookup(struct cache_detail *cd, | |||
| 159 | return container_of(ch, struct nfs_dns_ent, h); | 159 | return container_of(ch, struct nfs_dns_ent, h); |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | struct nfs_dns_ent *nfs_dns_update(struct cache_detail *cd, | 162 | static struct nfs_dns_ent *nfs_dns_update(struct cache_detail *cd, |
| 163 | struct nfs_dns_ent *new, | 163 | struct nfs_dns_ent *new, |
| 164 | struct nfs_dns_ent *key) | 164 | struct nfs_dns_ent *key) |
| 165 | { | 165 | { |
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index e21b1bb9972f..29e464d23b32 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
| @@ -30,6 +30,15 @@ static inline int nfs4_has_session(const struct nfs_client *clp) | |||
| 30 | return 0; | 30 | return 0; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | static inline int nfs4_has_persistent_session(const struct nfs_client *clp) | ||
| 34 | { | ||
| 35 | #ifdef CONFIG_NFS_V4_1 | ||
| 36 | if (nfs4_has_session(clp)) | ||
| 37 | return (clp->cl_session->flags & SESSION4_PERSIST); | ||
| 38 | #endif /* CONFIG_NFS_V4_1 */ | ||
| 39 | return 0; | ||
| 40 | } | ||
| 41 | |||
| 33 | struct nfs_clone_mount { | 42 | struct nfs_clone_mount { |
| 34 | const struct super_block *sb; | 43 | const struct super_block *sb; |
| 35 | const struct dentry *dentry; | 44 | const struct dentry *dentry; |
| @@ -156,6 +165,7 @@ struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentr | |||
| 156 | 165 | ||
| 157 | /* callback_xdr.c */ | 166 | /* callback_xdr.c */ |
| 158 | extern struct svc_version nfs4_callback_version1; | 167 | extern struct svc_version nfs4_callback_version1; |
| 168 | extern struct svc_version nfs4_callback_version4; | ||
| 159 | 169 | ||
| 160 | /* pagelist.c */ | 170 | /* pagelist.c */ |
| 161 | extern int __init nfs_init_nfspagecache(void); | 171 | extern int __init nfs_init_nfspagecache(void); |
| @@ -177,24 +187,14 @@ extern __be32 * nfs_decode_dirent(__be32 *, struct nfs_entry *, int); | |||
| 177 | extern struct rpc_procinfo nfs3_procedures[]; | 187 | extern struct rpc_procinfo nfs3_procedures[]; |
| 178 | extern __be32 *nfs3_decode_dirent(__be32 *, struct nfs_entry *, int); | 188 | extern __be32 *nfs3_decode_dirent(__be32 *, struct nfs_entry *, int); |
| 179 | 189 | ||
| 180 | /* nfs4proc.c */ | ||
| 181 | static inline void nfs4_restart_rpc(struct rpc_task *task, | ||
| 182 | const struct nfs_client *clp) | ||
| 183 | { | ||
| 184 | #ifdef CONFIG_NFS_V4_1 | ||
| 185 | if (nfs4_has_session(clp) && | ||
| 186 | test_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state)) { | ||
| 187 | rpc_restart_call_prepare(task); | ||
| 188 | return; | ||
| 189 | } | ||
| 190 | #endif /* CONFIG_NFS_V4_1 */ | ||
| 191 | rpc_restart_call(task); | ||
| 192 | } | ||
| 193 | |||
| 194 | /* nfs4xdr.c */ | 190 | /* nfs4xdr.c */ |
| 195 | #ifdef CONFIG_NFS_V4 | 191 | #ifdef CONFIG_NFS_V4 |
| 196 | extern __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus); | 192 | extern __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus); |
| 197 | #endif | 193 | #endif |
| 194 | #ifdef CONFIG_NFS_V4_1 | ||
| 195 | extern const u32 nfs41_maxread_overhead; | ||
| 196 | extern const u32 nfs41_maxwrite_overhead; | ||
| 197 | #endif | ||
| 198 | 198 | ||
| 199 | /* nfs4proc.c */ | 199 | /* nfs4proc.c */ |
| 200 | #ifdef CONFIG_NFS_V4 | 200 | #ifdef CONFIG_NFS_V4 |
| @@ -273,20 +273,6 @@ extern int _nfs4_call_sync_session(struct nfs_server *server, | |||
| 273 | struct nfs4_sequence_res *res, | 273 | struct nfs4_sequence_res *res, |
| 274 | int cache_reply); | 274 | int cache_reply); |
| 275 | 275 | ||
| 276 | #ifdef CONFIG_NFS_V4_1 | ||
| 277 | extern void nfs41_sequence_free_slot(const struct nfs_client *, | ||
| 278 | struct nfs4_sequence_res *res); | ||
| 279 | #endif /* CONFIG_NFS_V4_1 */ | ||
| 280 | |||
| 281 | static inline void nfs4_sequence_free_slot(const struct nfs_client *clp, | ||
| 282 | struct nfs4_sequence_res *res) | ||
| 283 | { | ||
| 284 | #ifdef CONFIG_NFS_V4_1 | ||
| 285 | if (nfs4_has_session(clp)) | ||
| 286 | nfs41_sequence_free_slot(clp, res); | ||
| 287 | #endif /* CONFIG_NFS_V4_1 */ | ||
| 288 | } | ||
| 289 | |||
| 290 | /* | 276 | /* |
| 291 | * Determine the device name as a string | 277 | * Determine the device name as a string |
| 292 | */ | 278 | */ |
| @@ -380,3 +366,15 @@ unsigned int nfs_page_array_len(unsigned int base, size_t len) | |||
| 380 | return ((unsigned long)len + (unsigned long)base + | 366 | return ((unsigned long)len + (unsigned long)base + |
| 381 | PAGE_SIZE - 1) >> PAGE_SHIFT; | 367 | PAGE_SIZE - 1) >> PAGE_SHIFT; |
| 382 | } | 368 | } |
| 369 | |||
| 370 | /* | ||
| 371 | * Helper for restarting RPC calls in the possible presence of NFSv4.1 | ||
| 372 | * sessions. | ||
| 373 | */ | ||
| 374 | static inline void nfs_restart_rpc(struct rpc_task *task, const struct nfs_client *clp) | ||
| 375 | { | ||
| 376 | if (nfs4_has_session(clp)) | ||
| 377 | rpc_restart_call_prepare(task); | ||
| 378 | else | ||
| 379 | rpc_restart_call(task); | ||
| 380 | } | ||
diff --git a/fs/nfs/iostat.h b/fs/nfs/iostat.h index ceda50aad73c..46d779abafd3 100644 --- a/fs/nfs/iostat.h +++ b/fs/nfs/iostat.h | |||
| @@ -25,13 +25,7 @@ struct nfs_iostats { | |||
| 25 | static inline void nfs_inc_server_stats(const struct nfs_server *server, | 25 | static inline void nfs_inc_server_stats(const struct nfs_server *server, |
| 26 | enum nfs_stat_eventcounters stat) | 26 | enum nfs_stat_eventcounters stat) |
| 27 | { | 27 | { |
| 28 | struct nfs_iostats *iostats; | 28 | this_cpu_inc(server->io_stats->events[stat]); |
| 29 | int cpu; | ||
| 30 | |||
| 31 | cpu = get_cpu(); | ||
| 32 | iostats = per_cpu_ptr(server->io_stats, cpu); | ||
| 33 | iostats->events[stat]++; | ||
| 34 | put_cpu(); | ||
| 35 | } | 29 | } |
| 36 | 30 | ||
| 37 | static inline void nfs_inc_stats(const struct inode *inode, | 31 | static inline void nfs_inc_stats(const struct inode *inode, |
| @@ -44,13 +38,7 @@ static inline void nfs_add_server_stats(const struct nfs_server *server, | |||
| 44 | enum nfs_stat_bytecounters stat, | 38 | enum nfs_stat_bytecounters stat, |
| 45 | unsigned long addend) | 39 | unsigned long addend) |
| 46 | { | 40 | { |
| 47 | struct nfs_iostats *iostats; | 41 | this_cpu_add(server->io_stats->bytes[stat], addend); |
| 48 | int cpu; | ||
| 49 | |||
| 50 | cpu = get_cpu(); | ||
| 51 | iostats = per_cpu_ptr(server->io_stats, cpu); | ||
| 52 | iostats->bytes[stat] += addend; | ||
| 53 | put_cpu(); | ||
| 54 | } | 42 | } |
| 55 | 43 | ||
| 56 | static inline void nfs_add_stats(const struct inode *inode, | 44 | static inline void nfs_add_stats(const struct inode *inode, |
| @@ -65,13 +53,7 @@ static inline void nfs_add_fscache_stats(struct inode *inode, | |||
| 65 | enum nfs_stat_fscachecounters stat, | 53 | enum nfs_stat_fscachecounters stat, |
| 66 | unsigned long addend) | 54 | unsigned long addend) |
| 67 | { | 55 | { |
| 68 | struct nfs_iostats *iostats; | 56 | this_cpu_add(NFS_SERVER(inode)->io_stats->fscache[stat], addend); |
| 69 | int cpu; | ||
| 70 | |||
| 71 | cpu = get_cpu(); | ||
| 72 | iostats = per_cpu_ptr(NFS_SERVER(inode)->io_stats, cpu); | ||
| 73 | iostats->fscache[stat] += addend; | ||
| 74 | put_cpu(); | ||
| 75 | } | 57 | } |
| 76 | #endif | 58 | #endif |
| 77 | 59 | ||
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 6ea07a3c75d4..865265bdca03 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h | |||
| @@ -44,7 +44,8 @@ enum nfs4_client_state { | |||
| 44 | NFS4CLNT_RECLAIM_REBOOT, | 44 | NFS4CLNT_RECLAIM_REBOOT, |
| 45 | NFS4CLNT_RECLAIM_NOGRACE, | 45 | NFS4CLNT_RECLAIM_NOGRACE, |
| 46 | NFS4CLNT_DELEGRETURN, | 46 | NFS4CLNT_DELEGRETURN, |
| 47 | NFS4CLNT_SESSION_SETUP, | 47 | NFS4CLNT_SESSION_RESET, |
| 48 | NFS4CLNT_SESSION_DRAINING, | ||
| 48 | }; | 49 | }; |
| 49 | 50 | ||
| 50 | /* | 51 | /* |
| @@ -107,6 +108,10 @@ enum { | |||
| 107 | NFS_OWNER_RECLAIM_NOGRACE | 108 | NFS_OWNER_RECLAIM_NOGRACE |
| 108 | }; | 109 | }; |
| 109 | 110 | ||
| 111 | #define NFS_LOCK_NEW 0 | ||
| 112 | #define NFS_LOCK_RECLAIM 1 | ||
| 113 | #define NFS_LOCK_EXPIRED 2 | ||
| 114 | |||
| 110 | /* | 115 | /* |
| 111 | * struct nfs4_state maintains the client-side state for a given | 116 | * struct nfs4_state maintains the client-side state for a given |
| 112 | * (state_owner,inode) tuple (OPEN) or state_owner (LOCK). | 117 | * (state_owner,inode) tuple (OPEN) or state_owner (LOCK). |
| @@ -180,6 +185,7 @@ struct nfs4_state_recovery_ops { | |||
| 180 | int (*recover_lock)(struct nfs4_state *, struct file_lock *); | 185 | int (*recover_lock)(struct nfs4_state *, struct file_lock *); |
| 181 | int (*establish_clid)(struct nfs_client *, struct rpc_cred *); | 186 | int (*establish_clid)(struct nfs_client *, struct rpc_cred *); |
| 182 | struct rpc_cred * (*get_clid_cred)(struct nfs_client *); | 187 | struct rpc_cred * (*get_clid_cred)(struct nfs_client *); |
| 188 | int (*reclaim_complete)(struct nfs_client *); | ||
| 183 | }; | 189 | }; |
| 184 | 190 | ||
| 185 | struct nfs4_state_maintenance_ops { | 191 | struct nfs4_state_maintenance_ops { |
| @@ -200,9 +206,11 @@ extern ssize_t nfs4_listxattr(struct dentry *, char *, size_t); | |||
| 200 | /* nfs4proc.c */ | 206 | /* nfs4proc.c */ |
| 201 | extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *); | 207 | extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *); |
| 202 | extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct rpc_cred *); | 208 | extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct rpc_cred *); |
| 209 | extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred); | ||
| 203 | extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *); | 210 | extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *); |
| 204 | extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *); | 211 | extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *); |
| 205 | extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *); | 212 | extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *); |
| 213 | extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *); | ||
| 206 | extern int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait); | 214 | extern int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait); |
| 207 | extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); | 215 | extern struct dentry *nfs4_atomic_open(struct inode *, struct dentry *, struct nameidata *); |
| 208 | extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); | 216 | extern int nfs4_open_revalidate(struct inode *, struct dentry *, int, struct nameidata *); |
| @@ -218,9 +226,11 @@ extern int nfs4_setup_sequence(struct nfs_client *clp, | |||
| 218 | int cache_reply, struct rpc_task *task); | 226 | int cache_reply, struct rpc_task *task); |
| 219 | extern void nfs4_destroy_session(struct nfs4_session *session); | 227 | extern void nfs4_destroy_session(struct nfs4_session *session); |
| 220 | extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp); | 228 | extern struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp); |
| 221 | extern int nfs4_proc_create_session(struct nfs_client *, int reset); | 229 | extern int nfs4_proc_create_session(struct nfs_client *); |
| 222 | extern int nfs4_proc_destroy_session(struct nfs4_session *); | 230 | extern int nfs4_proc_destroy_session(struct nfs4_session *); |
| 223 | extern int nfs4_init_session(struct nfs_server *server); | 231 | extern int nfs4_init_session(struct nfs_server *server); |
| 232 | extern int nfs4_proc_get_lease_time(struct nfs_client *clp, | ||
| 233 | struct nfs_fsinfo *fsinfo); | ||
| 224 | #else /* CONFIG_NFS_v4_1 */ | 234 | #else /* CONFIG_NFS_v4_1 */ |
| 225 | static inline int nfs4_setup_sequence(struct nfs_client *clp, | 235 | static inline int nfs4_setup_sequence(struct nfs_client *clp, |
| 226 | struct nfs4_sequence_args *args, struct nfs4_sequence_res *res, | 236 | struct nfs4_sequence_args *args, struct nfs4_sequence_res *res, |
| @@ -267,6 +277,7 @@ extern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t); | |||
| 267 | extern void nfs4_schedule_state_recovery(struct nfs_client *); | 277 | extern void nfs4_schedule_state_recovery(struct nfs_client *); |
| 268 | extern void nfs4_schedule_state_manager(struct nfs_client *); | 278 | extern void nfs4_schedule_state_manager(struct nfs_client *); |
| 269 | extern int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *state); | 279 | extern int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *state); |
| 280 | extern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags); | ||
| 270 | extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp); | 281 | extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp); |
| 271 | extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl); | 282 | extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl); |
| 272 | extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t); | 283 | extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t); |
| @@ -275,6 +286,7 @@ extern struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter); | |||
| 275 | extern int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task); | 286 | extern int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task); |
| 276 | extern void nfs_increment_open_seqid(int status, struct nfs_seqid *seqid); | 287 | extern void nfs_increment_open_seqid(int status, struct nfs_seqid *seqid); |
| 277 | extern void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid); | 288 | extern void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid); |
| 289 | extern void nfs_release_seqid(struct nfs_seqid *seqid); | ||
| 278 | extern void nfs_free_seqid(struct nfs_seqid *seqid); | 290 | extern void nfs_free_seqid(struct nfs_seqid *seqid); |
| 279 | 291 | ||
| 280 | extern const nfs4_stateid zero_stateid; | 292 | extern const nfs4_stateid zero_stateid; |
| @@ -287,6 +299,7 @@ struct nfs4_mount_data; | |||
| 287 | 299 | ||
| 288 | /* callback_xdr.c */ | 300 | /* callback_xdr.c */ |
| 289 | extern struct svc_version nfs4_callback_version1; | 301 | extern struct svc_version nfs4_callback_version1; |
| 302 | extern struct svc_version nfs4_callback_version4; | ||
| 290 | 303 | ||
| 291 | #else | 304 | #else |
| 292 | 305 | ||
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 741a562177fc..198d51d17c13 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
| @@ -64,6 +64,7 @@ | |||
| 64 | 64 | ||
| 65 | struct nfs4_opendata; | 65 | struct nfs4_opendata; |
| 66 | static int _nfs4_proc_open(struct nfs4_opendata *data); | 66 | static int _nfs4_proc_open(struct nfs4_opendata *data); |
| 67 | static int _nfs4_recover_proc_open(struct nfs4_opendata *data); | ||
| 67 | static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *); | 68 | static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *); |
| 68 | static int nfs4_async_handle_error(struct rpc_task *, const struct nfs_server *, struct nfs4_state *); | 69 | static int nfs4_async_handle_error(struct rpc_task *, const struct nfs_server *, struct nfs4_state *); |
| 69 | static int _nfs4_proc_lookup(struct inode *dir, const struct qstr *name, struct nfs_fh *fhandle, struct nfs_fattr *fattr); | 70 | static int _nfs4_proc_lookup(struct inode *dir, const struct qstr *name, struct nfs_fh *fhandle, struct nfs_fattr *fattr); |
| @@ -270,11 +271,18 @@ static int nfs4_handle_exception(const struct nfs_server *server, int errorcode, | |||
| 270 | case -NFS4ERR_SEQ_MISORDERED: | 271 | case -NFS4ERR_SEQ_MISORDERED: |
| 271 | dprintk("%s ERROR: %d Reset session\n", __func__, | 272 | dprintk("%s ERROR: %d Reset session\n", __func__, |
| 272 | errorcode); | 273 | errorcode); |
| 273 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | 274 | nfs4_schedule_state_recovery(clp); |
| 274 | exception->retry = 1; | 275 | exception->retry = 1; |
| 275 | /* FALLTHROUGH */ | 276 | break; |
| 276 | #endif /* !defined(CONFIG_NFS_V4_1) */ | 277 | #endif /* !defined(CONFIG_NFS_V4_1) */ |
| 277 | case -NFS4ERR_FILE_OPEN: | 278 | case -NFS4ERR_FILE_OPEN: |
| 279 | if (exception->timeout > HZ) { | ||
| 280 | /* We have retried a decent amount, time to | ||
| 281 | * fail | ||
| 282 | */ | ||
| 283 | ret = -EBUSY; | ||
| 284 | break; | ||
| 285 | } | ||
| 278 | case -NFS4ERR_GRACE: | 286 | case -NFS4ERR_GRACE: |
| 279 | case -NFS4ERR_DELAY: | 287 | case -NFS4ERR_DELAY: |
| 280 | ret = nfs4_delay(server->client, &exception->timeout); | 288 | ret = nfs4_delay(server->client, &exception->timeout); |
| @@ -311,48 +319,67 @@ static void renew_lease(const struct nfs_server *server, unsigned long timestamp | |||
| 311 | * so we need to scan down from highest_used_slotid to 0 looking for the now | 319 | * so we need to scan down from highest_used_slotid to 0 looking for the now |
| 312 | * highest slotid in use. | 320 | * highest slotid in use. |
| 313 | * If none found, highest_used_slotid is set to -1. | 321 | * If none found, highest_used_slotid is set to -1. |
| 322 | * | ||
| 323 | * Must be called while holding tbl->slot_tbl_lock | ||
| 314 | */ | 324 | */ |
| 315 | static void | 325 | static void |
| 316 | nfs4_free_slot(struct nfs4_slot_table *tbl, u8 free_slotid) | 326 | nfs4_free_slot(struct nfs4_slot_table *tbl, u8 free_slotid) |
| 317 | { | 327 | { |
| 318 | int slotid = free_slotid; | 328 | int slotid = free_slotid; |
| 319 | 329 | ||
| 320 | spin_lock(&tbl->slot_tbl_lock); | ||
| 321 | /* clear used bit in bitmap */ | 330 | /* clear used bit in bitmap */ |
| 322 | __clear_bit(slotid, tbl->used_slots); | 331 | __clear_bit(slotid, tbl->used_slots); |
| 323 | 332 | ||
| 324 | /* update highest_used_slotid when it is freed */ | 333 | /* update highest_used_slotid when it is freed */ |
| 325 | if (slotid == tbl->highest_used_slotid) { | 334 | if (slotid == tbl->highest_used_slotid) { |
| 326 | slotid = find_last_bit(tbl->used_slots, tbl->max_slots); | 335 | slotid = find_last_bit(tbl->used_slots, tbl->max_slots); |
| 327 | if (slotid >= 0 && slotid < tbl->max_slots) | 336 | if (slotid < tbl->max_slots) |
| 328 | tbl->highest_used_slotid = slotid; | 337 | tbl->highest_used_slotid = slotid; |
| 329 | else | 338 | else |
| 330 | tbl->highest_used_slotid = -1; | 339 | tbl->highest_used_slotid = -1; |
| 331 | } | 340 | } |
| 332 | rpc_wake_up_next(&tbl->slot_tbl_waitq); | ||
| 333 | spin_unlock(&tbl->slot_tbl_lock); | ||
| 334 | dprintk("%s: free_slotid %u highest_used_slotid %d\n", __func__, | 341 | dprintk("%s: free_slotid %u highest_used_slotid %d\n", __func__, |
| 335 | free_slotid, tbl->highest_used_slotid); | 342 | free_slotid, tbl->highest_used_slotid); |
| 336 | } | 343 | } |
| 337 | 344 | ||
| 338 | void nfs41_sequence_free_slot(const struct nfs_client *clp, | 345 | /* |
| 339 | struct nfs4_sequence_res *res) | 346 | * Signal state manager thread if session is drained |
| 347 | */ | ||
| 348 | static void nfs41_check_drain_session_complete(struct nfs4_session *ses) | ||
| 340 | { | 349 | { |
| 341 | struct nfs4_slot_table *tbl; | 350 | struct rpc_task *task; |
| 342 | 351 | ||
| 343 | if (!nfs4_has_session(clp)) { | 352 | if (!test_bit(NFS4CLNT_SESSION_DRAINING, &ses->clp->cl_state)) { |
| 344 | dprintk("%s: No session\n", __func__); | 353 | task = rpc_wake_up_next(&ses->fc_slot_table.slot_tbl_waitq); |
| 354 | if (task) | ||
| 355 | rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED); | ||
| 345 | return; | 356 | return; |
| 346 | } | 357 | } |
| 358 | |||
| 359 | if (ses->fc_slot_table.highest_used_slotid != -1) | ||
| 360 | return; | ||
| 361 | |||
| 362 | dprintk("%s COMPLETE: Session Drained\n", __func__); | ||
| 363 | complete(&ses->complete); | ||
| 364 | } | ||
| 365 | |||
| 366 | static void nfs41_sequence_free_slot(const struct nfs_client *clp, | ||
| 367 | struct nfs4_sequence_res *res) | ||
| 368 | { | ||
| 369 | struct nfs4_slot_table *tbl; | ||
| 370 | |||
| 347 | tbl = &clp->cl_session->fc_slot_table; | 371 | tbl = &clp->cl_session->fc_slot_table; |
| 348 | if (res->sr_slotid == NFS4_MAX_SLOT_TABLE) { | 372 | if (res->sr_slotid == NFS4_MAX_SLOT_TABLE) { |
| 349 | dprintk("%s: No slot\n", __func__); | ||
| 350 | /* just wake up the next guy waiting since | 373 | /* just wake up the next guy waiting since |
| 351 | * we may have not consumed a slot after all */ | 374 | * we may have not consumed a slot after all */ |
| 352 | rpc_wake_up_next(&tbl->slot_tbl_waitq); | 375 | dprintk("%s: No slot\n", __func__); |
| 353 | return; | 376 | return; |
| 354 | } | 377 | } |
| 378 | |||
| 379 | spin_lock(&tbl->slot_tbl_lock); | ||
| 355 | nfs4_free_slot(tbl, res->sr_slotid); | 380 | nfs4_free_slot(tbl, res->sr_slotid); |
| 381 | nfs41_check_drain_session_complete(clp->cl_session); | ||
| 382 | spin_unlock(&tbl->slot_tbl_lock); | ||
| 356 | res->sr_slotid = NFS4_MAX_SLOT_TABLE; | 383 | res->sr_slotid = NFS4_MAX_SLOT_TABLE; |
| 357 | } | 384 | } |
| 358 | 385 | ||
| @@ -377,10 +404,10 @@ static void nfs41_sequence_done(struct nfs_client *clp, | |||
| 377 | if (res->sr_slotid == NFS4_MAX_SLOT_TABLE) | 404 | if (res->sr_slotid == NFS4_MAX_SLOT_TABLE) |
| 378 | goto out; | 405 | goto out; |
| 379 | 406 | ||
| 380 | tbl = &clp->cl_session->fc_slot_table; | 407 | /* Check the SEQUENCE operation status */ |
| 381 | slot = tbl->slots + res->sr_slotid; | ||
| 382 | |||
| 383 | if (res->sr_status == 0) { | 408 | if (res->sr_status == 0) { |
| 409 | tbl = &clp->cl_session->fc_slot_table; | ||
| 410 | slot = tbl->slots + res->sr_slotid; | ||
| 384 | /* Update the slot's sequence and clientid lease timer */ | 411 | /* Update the slot's sequence and clientid lease timer */ |
| 385 | ++slot->seq_nr; | 412 | ++slot->seq_nr; |
| 386 | timestamp = res->sr_renewal_time; | 413 | timestamp = res->sr_renewal_time; |
| @@ -388,7 +415,8 @@ static void nfs41_sequence_done(struct nfs_client *clp, | |||
| 388 | if (time_before(clp->cl_last_renewal, timestamp)) | 415 | if (time_before(clp->cl_last_renewal, timestamp)) |
| 389 | clp->cl_last_renewal = timestamp; | 416 | clp->cl_last_renewal = timestamp; |
| 390 | spin_unlock(&clp->cl_lock); | 417 | spin_unlock(&clp->cl_lock); |
| 391 | return; | 418 | /* Check sequence flags */ |
| 419 | nfs41_handle_sequence_flag_errors(clp, res->sr_status_flags); | ||
| 392 | } | 420 | } |
| 393 | out: | 421 | out: |
| 394 | /* The session may be reset by one of the error handlers. */ | 422 | /* The session may be reset by one of the error handlers. */ |
| @@ -407,7 +435,7 @@ out: | |||
| 407 | * Note: must be called with under the slot_tbl_lock. | 435 | * Note: must be called with under the slot_tbl_lock. |
| 408 | */ | 436 | */ |
| 409 | static u8 | 437 | static u8 |
| 410 | nfs4_find_slot(struct nfs4_slot_table *tbl, struct rpc_task *task) | 438 | nfs4_find_slot(struct nfs4_slot_table *tbl) |
| 411 | { | 439 | { |
| 412 | int slotid; | 440 | int slotid; |
| 413 | u8 ret_id = NFS4_MAX_SLOT_TABLE; | 441 | u8 ret_id = NFS4_MAX_SLOT_TABLE; |
| @@ -429,24 +457,6 @@ out: | |||
| 429 | return ret_id; | 457 | return ret_id; |
| 430 | } | 458 | } |
| 431 | 459 | ||
| 432 | static int nfs4_recover_session(struct nfs4_session *session) | ||
| 433 | { | ||
| 434 | struct nfs_client *clp = session->clp; | ||
| 435 | unsigned int loop; | ||
| 436 | int ret; | ||
| 437 | |||
| 438 | for (loop = NFS4_MAX_LOOP_ON_RECOVER; loop != 0; loop--) { | ||
| 439 | ret = nfs4_wait_clnt_recover(clp); | ||
| 440 | if (ret != 0) | ||
| 441 | break; | ||
| 442 | if (!test_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state)) | ||
| 443 | break; | ||
| 444 | nfs4_schedule_state_manager(clp); | ||
| 445 | ret = -EIO; | ||
| 446 | } | ||
| 447 | return ret; | ||
| 448 | } | ||
| 449 | |||
| 450 | static int nfs41_setup_sequence(struct nfs4_session *session, | 460 | static int nfs41_setup_sequence(struct nfs4_session *session, |
| 451 | struct nfs4_sequence_args *args, | 461 | struct nfs4_sequence_args *args, |
| 452 | struct nfs4_sequence_res *res, | 462 | struct nfs4_sequence_res *res, |
| @@ -455,7 +465,6 @@ static int nfs41_setup_sequence(struct nfs4_session *session, | |||
| 455 | { | 465 | { |
| 456 | struct nfs4_slot *slot; | 466 | struct nfs4_slot *slot; |
| 457 | struct nfs4_slot_table *tbl; | 467 | struct nfs4_slot_table *tbl; |
| 458 | int status = 0; | ||
| 459 | u8 slotid; | 468 | u8 slotid; |
| 460 | 469 | ||
| 461 | dprintk("--> %s\n", __func__); | 470 | dprintk("--> %s\n", __func__); |
| @@ -468,24 +477,27 @@ static int nfs41_setup_sequence(struct nfs4_session *session, | |||
| 468 | tbl = &session->fc_slot_table; | 477 | tbl = &session->fc_slot_table; |
| 469 | 478 | ||
| 470 | spin_lock(&tbl->slot_tbl_lock); | 479 | spin_lock(&tbl->slot_tbl_lock); |
| 471 | if (test_bit(NFS4CLNT_SESSION_SETUP, &session->clp->cl_state)) { | 480 | if (test_bit(NFS4CLNT_SESSION_DRAINING, &session->clp->cl_state) && |
| 472 | if (tbl->highest_used_slotid != -1) { | 481 | !rpc_task_has_priority(task, RPC_PRIORITY_PRIVILEGED)) { |
| 473 | rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL); | 482 | /* |
| 474 | spin_unlock(&tbl->slot_tbl_lock); | 483 | * The state manager will wait until the slot table is empty. |
| 475 | dprintk("<-- %s: Session reset: draining\n", __func__); | 484 | * Schedule the reset thread |
| 476 | return -EAGAIN; | 485 | */ |
| 477 | } | 486 | rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL); |
| 487 | spin_unlock(&tbl->slot_tbl_lock); | ||
| 488 | dprintk("%s Schedule Session Reset\n", __func__); | ||
| 489 | return -EAGAIN; | ||
| 490 | } | ||
| 478 | 491 | ||
| 479 | /* The slot table is empty; start the reset thread */ | 492 | if (!rpc_queue_empty(&tbl->slot_tbl_waitq) && |
| 480 | dprintk("%s Session Reset\n", __func__); | 493 | !rpc_task_has_priority(task, RPC_PRIORITY_PRIVILEGED)) { |
| 494 | rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL); | ||
| 481 | spin_unlock(&tbl->slot_tbl_lock); | 495 | spin_unlock(&tbl->slot_tbl_lock); |
| 482 | status = nfs4_recover_session(session); | 496 | dprintk("%s enforce FIFO order\n", __func__); |
| 483 | if (status) | 497 | return -EAGAIN; |
| 484 | return status; | ||
| 485 | spin_lock(&tbl->slot_tbl_lock); | ||
| 486 | } | 498 | } |
| 487 | 499 | ||
| 488 | slotid = nfs4_find_slot(tbl, task); | 500 | slotid = nfs4_find_slot(tbl); |
| 489 | if (slotid == NFS4_MAX_SLOT_TABLE) { | 501 | if (slotid == NFS4_MAX_SLOT_TABLE) { |
| 490 | rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL); | 502 | rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL); |
| 491 | spin_unlock(&tbl->slot_tbl_lock); | 503 | spin_unlock(&tbl->slot_tbl_lock); |
| @@ -494,6 +506,7 @@ static int nfs41_setup_sequence(struct nfs4_session *session, | |||
| 494 | } | 506 | } |
| 495 | spin_unlock(&tbl->slot_tbl_lock); | 507 | spin_unlock(&tbl->slot_tbl_lock); |
| 496 | 508 | ||
| 509 | rpc_task_set_priority(task, RPC_PRIORITY_NORMAL); | ||
| 497 | slot = tbl->slots + slotid; | 510 | slot = tbl->slots + slotid; |
| 498 | args->sa_session = session; | 511 | args->sa_session = session; |
| 499 | args->sa_slotid = slotid; | 512 | args->sa_slotid = slotid; |
| @@ -527,7 +540,7 @@ int nfs4_setup_sequence(struct nfs_client *clp, | |||
| 527 | goto out; | 540 | goto out; |
| 528 | ret = nfs41_setup_sequence(clp->cl_session, args, res, cache_reply, | 541 | ret = nfs41_setup_sequence(clp->cl_session, args, res, cache_reply, |
| 529 | task); | 542 | task); |
| 530 | if (ret != -EAGAIN) { | 543 | if (ret && ret != -EAGAIN) { |
| 531 | /* terminate rpc task */ | 544 | /* terminate rpc task */ |
| 532 | task->tk_status = ret; | 545 | task->tk_status = ret; |
| 533 | task->tk_action = NULL; | 546 | task->tk_action = NULL; |
| @@ -556,12 +569,17 @@ static void nfs41_call_sync_prepare(struct rpc_task *task, void *calldata) | |||
| 556 | rpc_call_start(task); | 569 | rpc_call_start(task); |
| 557 | } | 570 | } |
| 558 | 571 | ||
| 572 | static void nfs41_call_priv_sync_prepare(struct rpc_task *task, void *calldata) | ||
| 573 | { | ||
| 574 | rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED); | ||
| 575 | nfs41_call_sync_prepare(task, calldata); | ||
| 576 | } | ||
| 577 | |||
| 559 | static void nfs41_call_sync_done(struct rpc_task *task, void *calldata) | 578 | static void nfs41_call_sync_done(struct rpc_task *task, void *calldata) |
| 560 | { | 579 | { |
| 561 | struct nfs41_call_sync_data *data = calldata; | 580 | struct nfs41_call_sync_data *data = calldata; |
| 562 | 581 | ||
| 563 | nfs41_sequence_done(data->clp, data->seq_res, task->tk_status); | 582 | nfs41_sequence_done(data->clp, data->seq_res, task->tk_status); |
| 564 | nfs41_sequence_free_slot(data->clp, data->seq_res); | ||
| 565 | } | 583 | } |
| 566 | 584 | ||
| 567 | struct rpc_call_ops nfs41_call_sync_ops = { | 585 | struct rpc_call_ops nfs41_call_sync_ops = { |
| @@ -569,12 +587,18 @@ struct rpc_call_ops nfs41_call_sync_ops = { | |||
| 569 | .rpc_call_done = nfs41_call_sync_done, | 587 | .rpc_call_done = nfs41_call_sync_done, |
| 570 | }; | 588 | }; |
| 571 | 589 | ||
| 590 | struct rpc_call_ops nfs41_call_priv_sync_ops = { | ||
| 591 | .rpc_call_prepare = nfs41_call_priv_sync_prepare, | ||
| 592 | .rpc_call_done = nfs41_call_sync_done, | ||
| 593 | }; | ||
| 594 | |||
| 572 | static int nfs4_call_sync_sequence(struct nfs_client *clp, | 595 | static int nfs4_call_sync_sequence(struct nfs_client *clp, |
| 573 | struct rpc_clnt *clnt, | 596 | struct rpc_clnt *clnt, |
| 574 | struct rpc_message *msg, | 597 | struct rpc_message *msg, |
| 575 | struct nfs4_sequence_args *args, | 598 | struct nfs4_sequence_args *args, |
| 576 | struct nfs4_sequence_res *res, | 599 | struct nfs4_sequence_res *res, |
| 577 | int cache_reply) | 600 | int cache_reply, |
| 601 | int privileged) | ||
| 578 | { | 602 | { |
| 579 | int ret; | 603 | int ret; |
| 580 | struct rpc_task *task; | 604 | struct rpc_task *task; |
| @@ -592,6 +616,8 @@ static int nfs4_call_sync_sequence(struct nfs_client *clp, | |||
| 592 | }; | 616 | }; |
| 593 | 617 | ||
| 594 | res->sr_slotid = NFS4_MAX_SLOT_TABLE; | 618 | res->sr_slotid = NFS4_MAX_SLOT_TABLE; |
| 619 | if (privileged) | ||
| 620 | task_setup.callback_ops = &nfs41_call_priv_sync_ops; | ||
| 595 | task = rpc_run_task(&task_setup); | 621 | task = rpc_run_task(&task_setup); |
| 596 | if (IS_ERR(task)) | 622 | if (IS_ERR(task)) |
| 597 | ret = PTR_ERR(task); | 623 | ret = PTR_ERR(task); |
| @@ -609,7 +635,7 @@ int _nfs4_call_sync_session(struct nfs_server *server, | |||
| 609 | int cache_reply) | 635 | int cache_reply) |
| 610 | { | 636 | { |
| 611 | return nfs4_call_sync_sequence(server->nfs_client, server->client, | 637 | return nfs4_call_sync_sequence(server->nfs_client, server->client, |
| 612 | msg, args, res, cache_reply); | 638 | msg, args, res, cache_reply, 0); |
| 613 | } | 639 | } |
| 614 | 640 | ||
| 615 | #endif /* CONFIG_NFS_V4_1 */ | 641 | #endif /* CONFIG_NFS_V4_1 */ |
| @@ -637,15 +663,6 @@ static void nfs4_sequence_done(const struct nfs_server *server, | |||
| 637 | #endif /* CONFIG_NFS_V4_1 */ | 663 | #endif /* CONFIG_NFS_V4_1 */ |
| 638 | } | 664 | } |
| 639 | 665 | ||
| 640 | /* no restart, therefore free slot here */ | ||
| 641 | static void nfs4_sequence_done_free_slot(const struct nfs_server *server, | ||
| 642 | struct nfs4_sequence_res *res, | ||
| 643 | int rpc_status) | ||
| 644 | { | ||
| 645 | nfs4_sequence_done(server, res, rpc_status); | ||
| 646 | nfs4_sequence_free_slot(server->nfs_client, res); | ||
| 647 | } | ||
| 648 | |||
| 649 | static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo) | 666 | static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo) |
| 650 | { | 667 | { |
| 651 | struct nfs_inode *nfsi = NFS_I(dir); | 668 | struct nfs_inode *nfsi = NFS_I(dir); |
| @@ -720,9 +737,15 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path, | |||
| 720 | p->o_arg.bitmask = server->attr_bitmask; | 737 | p->o_arg.bitmask = server->attr_bitmask; |
| 721 | p->o_arg.claim = NFS4_OPEN_CLAIM_NULL; | 738 | p->o_arg.claim = NFS4_OPEN_CLAIM_NULL; |
| 722 | if (flags & O_EXCL) { | 739 | if (flags & O_EXCL) { |
| 723 | u32 *s = (u32 *) p->o_arg.u.verifier.data; | 740 | if (nfs4_has_persistent_session(server->nfs_client)) { |
| 724 | s[0] = jiffies; | 741 | /* GUARDED */ |
| 725 | s[1] = current->pid; | 742 | p->o_arg.u.attrs = &p->attrs; |
| 743 | memcpy(&p->attrs, attrs, sizeof(p->attrs)); | ||
| 744 | } else { /* EXCLUSIVE4_1 */ | ||
| 745 | u32 *s = (u32 *) p->o_arg.u.verifier.data; | ||
| 746 | s[0] = jiffies; | ||
| 747 | s[1] = current->pid; | ||
| 748 | } | ||
| 726 | } else if (flags & O_CREAT) { | 749 | } else if (flags & O_CREAT) { |
| 727 | p->o_arg.u.attrs = &p->attrs; | 750 | p->o_arg.u.attrs = &p->attrs; |
| 728 | memcpy(&p->attrs, attrs, sizeof(p->attrs)); | 751 | memcpy(&p->attrs, attrs, sizeof(p->attrs)); |
| @@ -776,13 +799,16 @@ static int can_open_cached(struct nfs4_state *state, fmode_t mode, int open_mode | |||
| 776 | goto out; | 799 | goto out; |
| 777 | switch (mode & (FMODE_READ|FMODE_WRITE)) { | 800 | switch (mode & (FMODE_READ|FMODE_WRITE)) { |
| 778 | case FMODE_READ: | 801 | case FMODE_READ: |
| 779 | ret |= test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0; | 802 | ret |= test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0 |
| 803 | && state->n_rdonly != 0; | ||
| 780 | break; | 804 | break; |
| 781 | case FMODE_WRITE: | 805 | case FMODE_WRITE: |
| 782 | ret |= test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0; | 806 | ret |= test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0 |
| 807 | && state->n_wronly != 0; | ||
| 783 | break; | 808 | break; |
| 784 | case FMODE_READ|FMODE_WRITE: | 809 | case FMODE_READ|FMODE_WRITE: |
| 785 | ret |= test_bit(NFS_O_RDWR_STATE, &state->flags) != 0; | 810 | ret |= test_bit(NFS_O_RDWR_STATE, &state->flags) != 0 |
| 811 | && state->n_rdwr != 0; | ||
| 786 | } | 812 | } |
| 787 | out: | 813 | out: |
| 788 | return ret; | 814 | return ret; |
| @@ -1047,7 +1073,7 @@ static int nfs4_open_recover_helper(struct nfs4_opendata *opendata, fmode_t fmod | |||
| 1047 | memset(&opendata->o_res, 0, sizeof(opendata->o_res)); | 1073 | memset(&opendata->o_res, 0, sizeof(opendata->o_res)); |
| 1048 | memset(&opendata->c_res, 0, sizeof(opendata->c_res)); | 1074 | memset(&opendata->c_res, 0, sizeof(opendata->c_res)); |
| 1049 | nfs4_init_opendata_res(opendata); | 1075 | nfs4_init_opendata_res(opendata); |
| 1050 | ret = _nfs4_proc_open(opendata); | 1076 | ret = _nfs4_recover_proc_open(opendata); |
| 1051 | if (ret != 0) | 1077 | if (ret != 0) |
| 1052 | return ret; | 1078 | return ret; |
| 1053 | newstate = nfs4_opendata_to_nfs4_state(opendata); | 1079 | newstate = nfs4_opendata_to_nfs4_state(opendata); |
| @@ -1183,6 +1209,14 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state | |||
| 1183 | case -ENOENT: | 1209 | case -ENOENT: |
| 1184 | case -ESTALE: | 1210 | case -ESTALE: |
| 1185 | goto out; | 1211 | goto out; |
| 1212 | case -NFS4ERR_BADSESSION: | ||
| 1213 | case -NFS4ERR_BADSLOT: | ||
| 1214 | case -NFS4ERR_BAD_HIGH_SLOT: | ||
| 1215 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: | ||
| 1216 | case -NFS4ERR_DEADSESSION: | ||
| 1217 | nfs4_schedule_state_recovery( | ||
| 1218 | server->nfs_client); | ||
| 1219 | goto out; | ||
| 1186 | case -NFS4ERR_STALE_CLIENTID: | 1220 | case -NFS4ERR_STALE_CLIENTID: |
| 1187 | case -NFS4ERR_STALE_STATEID: | 1221 | case -NFS4ERR_STALE_STATEID: |
| 1188 | case -NFS4ERR_EXPIRED: | 1222 | case -NFS4ERR_EXPIRED: |
| @@ -1330,14 +1364,20 @@ out_no_action: | |||
| 1330 | 1364 | ||
| 1331 | } | 1365 | } |
| 1332 | 1366 | ||
| 1367 | static void nfs4_recover_open_prepare(struct rpc_task *task, void *calldata) | ||
| 1368 | { | ||
| 1369 | rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED); | ||
| 1370 | nfs4_open_prepare(task, calldata); | ||
| 1371 | } | ||
| 1372 | |||
| 1333 | static void nfs4_open_done(struct rpc_task *task, void *calldata) | 1373 | static void nfs4_open_done(struct rpc_task *task, void *calldata) |
| 1334 | { | 1374 | { |
| 1335 | struct nfs4_opendata *data = calldata; | 1375 | struct nfs4_opendata *data = calldata; |
| 1336 | 1376 | ||
| 1337 | data->rpc_status = task->tk_status; | 1377 | data->rpc_status = task->tk_status; |
| 1338 | 1378 | ||
| 1339 | nfs4_sequence_done_free_slot(data->o_arg.server, &data->o_res.seq_res, | 1379 | nfs4_sequence_done(data->o_arg.server, &data->o_res.seq_res, |
| 1340 | task->tk_status); | 1380 | task->tk_status); |
| 1341 | 1381 | ||
| 1342 | if (RPC_ASSASSINATED(task)) | 1382 | if (RPC_ASSASSINATED(task)) |
| 1343 | return; | 1383 | return; |
| @@ -1388,10 +1428,13 @@ static const struct rpc_call_ops nfs4_open_ops = { | |||
| 1388 | .rpc_release = nfs4_open_release, | 1428 | .rpc_release = nfs4_open_release, |
| 1389 | }; | 1429 | }; |
| 1390 | 1430 | ||
| 1391 | /* | 1431 | static const struct rpc_call_ops nfs4_recover_open_ops = { |
| 1392 | * Note: On error, nfs4_proc_open will free the struct nfs4_opendata | 1432 | .rpc_call_prepare = nfs4_recover_open_prepare, |
| 1393 | */ | 1433 | .rpc_call_done = nfs4_open_done, |
| 1394 | static int _nfs4_proc_open(struct nfs4_opendata *data) | 1434 | .rpc_release = nfs4_open_release, |
| 1435 | }; | ||
| 1436 | |||
| 1437 | static int nfs4_run_open_task(struct nfs4_opendata *data, int isrecover) | ||
| 1395 | { | 1438 | { |
| 1396 | struct inode *dir = data->dir->d_inode; | 1439 | struct inode *dir = data->dir->d_inode; |
| 1397 | struct nfs_server *server = NFS_SERVER(dir); | 1440 | struct nfs_server *server = NFS_SERVER(dir); |
| @@ -1418,21 +1461,57 @@ static int _nfs4_proc_open(struct nfs4_opendata *data) | |||
| 1418 | data->rpc_done = 0; | 1461 | data->rpc_done = 0; |
| 1419 | data->rpc_status = 0; | 1462 | data->rpc_status = 0; |
| 1420 | data->cancelled = 0; | 1463 | data->cancelled = 0; |
| 1464 | if (isrecover) | ||
| 1465 | task_setup_data.callback_ops = &nfs4_recover_open_ops; | ||
| 1421 | task = rpc_run_task(&task_setup_data); | 1466 | task = rpc_run_task(&task_setup_data); |
| 1422 | if (IS_ERR(task)) | 1467 | if (IS_ERR(task)) |
| 1423 | return PTR_ERR(task); | 1468 | return PTR_ERR(task); |
| 1424 | status = nfs4_wait_for_completion_rpc_task(task); | 1469 | status = nfs4_wait_for_completion_rpc_task(task); |
| 1425 | if (status != 0) { | 1470 | if (status != 0) { |
| 1426 | data->cancelled = 1; | 1471 | data->cancelled = 1; |
| 1427 | smp_wmb(); | 1472 | smp_wmb(); |
| 1428 | } else | 1473 | } else |
| 1429 | status = data->rpc_status; | 1474 | status = data->rpc_status; |
| 1430 | rpc_put_task(task); | 1475 | rpc_put_task(task); |
| 1476 | |||
| 1477 | return status; | ||
| 1478 | } | ||
| 1479 | |||
| 1480 | static int _nfs4_recover_proc_open(struct nfs4_opendata *data) | ||
| 1481 | { | ||
| 1482 | struct inode *dir = data->dir->d_inode; | ||
| 1483 | struct nfs_openres *o_res = &data->o_res; | ||
| 1484 | int status; | ||
| 1485 | |||
| 1486 | status = nfs4_run_open_task(data, 1); | ||
| 1431 | if (status != 0 || !data->rpc_done) | 1487 | if (status != 0 || !data->rpc_done) |
| 1432 | return status; | 1488 | return status; |
| 1433 | 1489 | ||
| 1434 | if (o_res->fh.size == 0) | 1490 | nfs_refresh_inode(dir, o_res->dir_attr); |
| 1435 | _nfs4_proc_lookup(dir, o_arg->name, &o_res->fh, o_res->f_attr); | 1491 | |
| 1492 | if (o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) { | ||
| 1493 | status = _nfs4_proc_open_confirm(data); | ||
| 1494 | if (status != 0) | ||
| 1495 | return status; | ||
| 1496 | } | ||
| 1497 | |||
| 1498 | return status; | ||
| 1499 | } | ||
| 1500 | |||
| 1501 | /* | ||
| 1502 | * Note: On error, nfs4_proc_open will free the struct nfs4_opendata | ||
| 1503 | */ | ||
| 1504 | static int _nfs4_proc_open(struct nfs4_opendata *data) | ||
| 1505 | { | ||
| 1506 | struct inode *dir = data->dir->d_inode; | ||
| 1507 | struct nfs_server *server = NFS_SERVER(dir); | ||
| 1508 | struct nfs_openargs *o_arg = &data->o_arg; | ||
| 1509 | struct nfs_openres *o_res = &data->o_res; | ||
| 1510 | int status; | ||
| 1511 | |||
| 1512 | status = nfs4_run_open_task(data, 0); | ||
| 1513 | if (status != 0 || !data->rpc_done) | ||
| 1514 | return status; | ||
| 1436 | 1515 | ||
| 1437 | if (o_arg->open_flags & O_CREAT) { | 1516 | if (o_arg->open_flags & O_CREAT) { |
| 1438 | update_changeattr(dir, &o_res->cinfo); | 1517 | update_changeattr(dir, &o_res->cinfo); |
| @@ -1488,7 +1567,7 @@ static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *s | |||
| 1488 | return ret; | 1567 | return ret; |
| 1489 | } | 1568 | } |
| 1490 | 1569 | ||
| 1491 | static inline int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state) | 1570 | static int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4_state *state) |
| 1492 | { | 1571 | { |
| 1493 | struct nfs_server *server = NFS_SERVER(state->inode); | 1572 | struct nfs_server *server = NFS_SERVER(state->inode); |
| 1494 | struct nfs4_exception exception = { }; | 1573 | struct nfs4_exception exception = { }; |
| @@ -1496,10 +1575,16 @@ static inline int nfs4_do_open_expired(struct nfs_open_context *ctx, struct nfs4 | |||
| 1496 | 1575 | ||
| 1497 | do { | 1576 | do { |
| 1498 | err = _nfs4_open_expired(ctx, state); | 1577 | err = _nfs4_open_expired(ctx, state); |
| 1499 | if (err != -NFS4ERR_DELAY) | 1578 | switch (err) { |
| 1500 | break; | 1579 | default: |
| 1501 | nfs4_handle_exception(server, err, &exception); | 1580 | goto out; |
| 1581 | case -NFS4ERR_GRACE: | ||
| 1582 | case -NFS4ERR_DELAY: | ||
| 1583 | nfs4_handle_exception(server, err, &exception); | ||
| 1584 | err = 0; | ||
| 1585 | } | ||
| 1502 | } while (exception.retry); | 1586 | } while (exception.retry); |
| 1587 | out: | ||
| 1503 | return err; | 1588 | return err; |
| 1504 | } | 1589 | } |
| 1505 | 1590 | ||
| @@ -1712,6 +1797,18 @@ static void nfs4_free_closedata(void *data) | |||
| 1712 | kfree(calldata); | 1797 | kfree(calldata); |
| 1713 | } | 1798 | } |
| 1714 | 1799 | ||
| 1800 | static void nfs4_close_clear_stateid_flags(struct nfs4_state *state, | ||
| 1801 | fmode_t fmode) | ||
| 1802 | { | ||
| 1803 | spin_lock(&state->owner->so_lock); | ||
| 1804 | if (!(fmode & FMODE_READ)) | ||
| 1805 | clear_bit(NFS_O_RDONLY_STATE, &state->flags); | ||
| 1806 | if (!(fmode & FMODE_WRITE)) | ||
| 1807 | clear_bit(NFS_O_WRONLY_STATE, &state->flags); | ||
| 1808 | clear_bit(NFS_O_RDWR_STATE, &state->flags); | ||
| 1809 | spin_unlock(&state->owner->so_lock); | ||
| 1810 | } | ||
| 1811 | |||
| 1715 | static void nfs4_close_done(struct rpc_task *task, void *data) | 1812 | static void nfs4_close_done(struct rpc_task *task, void *data) |
| 1716 | { | 1813 | { |
| 1717 | struct nfs4_closedata *calldata = data; | 1814 | struct nfs4_closedata *calldata = data; |
| @@ -1728,6 +1825,8 @@ static void nfs4_close_done(struct rpc_task *task, void *data) | |||
| 1728 | case 0: | 1825 | case 0: |
| 1729 | nfs_set_open_stateid(state, &calldata->res.stateid, 0); | 1826 | nfs_set_open_stateid(state, &calldata->res.stateid, 0); |
| 1730 | renew_lease(server, calldata->timestamp); | 1827 | renew_lease(server, calldata->timestamp); |
| 1828 | nfs4_close_clear_stateid_flags(state, | ||
| 1829 | calldata->arg.fmode); | ||
| 1731 | break; | 1830 | break; |
| 1732 | case -NFS4ERR_STALE_STATEID: | 1831 | case -NFS4ERR_STALE_STATEID: |
| 1733 | case -NFS4ERR_OLD_STATEID: | 1832 | case -NFS4ERR_OLD_STATEID: |
| @@ -1736,12 +1835,10 @@ static void nfs4_close_done(struct rpc_task *task, void *data) | |||
| 1736 | if (calldata->arg.fmode == 0) | 1835 | if (calldata->arg.fmode == 0) |
| 1737 | break; | 1836 | break; |
| 1738 | default: | 1837 | default: |
| 1739 | if (nfs4_async_handle_error(task, server, state) == -EAGAIN) { | 1838 | if (nfs4_async_handle_error(task, server, state) == -EAGAIN) |
| 1740 | nfs4_restart_rpc(task, server->nfs_client); | 1839 | rpc_restart_call_prepare(task); |
| 1741 | return; | ||
| 1742 | } | ||
| 1743 | } | 1840 | } |
| 1744 | nfs4_sequence_free_slot(server->nfs_client, &calldata->res.seq_res); | 1841 | nfs_release_seqid(calldata->arg.seqid); |
| 1745 | nfs_refresh_inode(calldata->inode, calldata->res.fattr); | 1842 | nfs_refresh_inode(calldata->inode, calldata->res.fattr); |
| 1746 | } | 1843 | } |
| 1747 | 1844 | ||
| @@ -1749,38 +1846,39 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data) | |||
| 1749 | { | 1846 | { |
| 1750 | struct nfs4_closedata *calldata = data; | 1847 | struct nfs4_closedata *calldata = data; |
| 1751 | struct nfs4_state *state = calldata->state; | 1848 | struct nfs4_state *state = calldata->state; |
| 1752 | int clear_rd, clear_wr, clear_rdwr; | 1849 | int call_close = 0; |
| 1753 | 1850 | ||
| 1754 | if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0) | 1851 | if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0) |
| 1755 | return; | 1852 | return; |
| 1756 | 1853 | ||
| 1757 | clear_rd = clear_wr = clear_rdwr = 0; | 1854 | task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE]; |
| 1855 | calldata->arg.fmode = FMODE_READ|FMODE_WRITE; | ||
| 1758 | spin_lock(&state->owner->so_lock); | 1856 | spin_lock(&state->owner->so_lock); |
| 1759 | /* Calculate the change in open mode */ | 1857 | /* Calculate the change in open mode */ |
| 1760 | if (state->n_rdwr == 0) { | 1858 | if (state->n_rdwr == 0) { |
| 1761 | if (state->n_rdonly == 0) { | 1859 | if (state->n_rdonly == 0) { |
| 1762 | clear_rd |= test_and_clear_bit(NFS_O_RDONLY_STATE, &state->flags); | 1860 | call_close |= test_bit(NFS_O_RDONLY_STATE, &state->flags); |
| 1763 | clear_rdwr |= test_and_clear_bit(NFS_O_RDWR_STATE, &state->flags); | 1861 | call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags); |
| 1862 | calldata->arg.fmode &= ~FMODE_READ; | ||
| 1764 | } | 1863 | } |
| 1765 | if (state->n_wronly == 0) { | 1864 | if (state->n_wronly == 0) { |
| 1766 | clear_wr |= test_and_clear_bit(NFS_O_WRONLY_STATE, &state->flags); | 1865 | call_close |= test_bit(NFS_O_WRONLY_STATE, &state->flags); |
| 1767 | clear_rdwr |= test_and_clear_bit(NFS_O_RDWR_STATE, &state->flags); | 1866 | call_close |= test_bit(NFS_O_RDWR_STATE, &state->flags); |
| 1867 | calldata->arg.fmode &= ~FMODE_WRITE; | ||
| 1768 | } | 1868 | } |
| 1769 | } | 1869 | } |
| 1770 | spin_unlock(&state->owner->so_lock); | 1870 | spin_unlock(&state->owner->so_lock); |
| 1771 | if (!clear_rd && !clear_wr && !clear_rdwr) { | 1871 | |
| 1872 | if (!call_close) { | ||
| 1772 | /* Note: exit _without_ calling nfs4_close_done */ | 1873 | /* Note: exit _without_ calling nfs4_close_done */ |
| 1773 | task->tk_action = NULL; | 1874 | task->tk_action = NULL; |
| 1774 | return; | 1875 | return; |
| 1775 | } | 1876 | } |
| 1877 | |||
| 1878 | if (calldata->arg.fmode == 0) | ||
| 1879 | task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CLOSE]; | ||
| 1880 | |||
| 1776 | nfs_fattr_init(calldata->res.fattr); | 1881 | nfs_fattr_init(calldata->res.fattr); |
| 1777 | if (test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0) { | ||
| 1778 | task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE]; | ||
| 1779 | calldata->arg.fmode = FMODE_READ; | ||
| 1780 | } else if (test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0) { | ||
| 1781 | task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE]; | ||
| 1782 | calldata->arg.fmode = FMODE_WRITE; | ||
| 1783 | } | ||
| 1784 | calldata->timestamp = jiffies; | 1882 | calldata->timestamp = jiffies; |
| 1785 | if (nfs4_setup_sequence((NFS_SERVER(calldata->inode))->nfs_client, | 1883 | if (nfs4_setup_sequence((NFS_SERVER(calldata->inode))->nfs_client, |
| 1786 | &calldata->arg.seq_args, &calldata->res.seq_res, | 1884 | &calldata->arg.seq_args, &calldata->res.seq_res, |
| @@ -1832,8 +1930,6 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait) | |||
| 1832 | calldata->state = state; | 1930 | calldata->state = state; |
| 1833 | calldata->arg.fh = NFS_FH(state->inode); | 1931 | calldata->arg.fh = NFS_FH(state->inode); |
| 1834 | calldata->arg.stateid = &state->open_stateid; | 1932 | calldata->arg.stateid = &state->open_stateid; |
| 1835 | if (nfs4_has_session(server->nfs_client)) | ||
| 1836 | memset(calldata->arg.stateid->data, 0, 4); /* clear seqid */ | ||
| 1837 | /* Serialization for the sequence id */ | 1933 | /* Serialization for the sequence id */ |
| 1838 | calldata->arg.seqid = nfs_alloc_seqid(&state->owner->so_seqid); | 1934 | calldata->arg.seqid = nfs_alloc_seqid(&state->owner->so_seqid); |
| 1839 | if (calldata->arg.seqid == NULL) | 1935 | if (calldata->arg.seqid == NULL) |
| @@ -1981,7 +2077,7 @@ out_drop: | |||
| 1981 | return 0; | 2077 | return 0; |
| 1982 | } | 2078 | } |
| 1983 | 2079 | ||
| 1984 | void nfs4_close_context(struct nfs_open_context *ctx, int is_sync) | 2080 | static void nfs4_close_context(struct nfs_open_context *ctx, int is_sync) |
| 1985 | { | 2081 | { |
| 1986 | if (ctx->state == NULL) | 2082 | if (ctx->state == NULL) |
| 1987 | return; | 2083 | return; |
| @@ -2532,7 +2628,6 @@ static int nfs4_proc_unlink_done(struct rpc_task *task, struct inode *dir) | |||
| 2532 | nfs4_sequence_done(res->server, &res->seq_res, task->tk_status); | 2628 | nfs4_sequence_done(res->server, &res->seq_res, task->tk_status); |
| 2533 | if (nfs4_async_handle_error(task, res->server, NULL) == -EAGAIN) | 2629 | if (nfs4_async_handle_error(task, res->server, NULL) == -EAGAIN) |
| 2534 | return 0; | 2630 | return 0; |
| 2535 | nfs4_sequence_free_slot(res->server->nfs_client, &res->seq_res); | ||
| 2536 | update_changeattr(dir, &res->cinfo); | 2631 | update_changeattr(dir, &res->cinfo); |
| 2537 | nfs_post_op_update_inode(dir, &res->dir_attr); | 2632 | nfs_post_op_update_inode(dir, &res->dir_attr); |
| 2538 | return 1; | 2633 | return 1; |
| @@ -2971,11 +3066,10 @@ static int nfs4_read_done(struct rpc_task *task, struct nfs_read_data *data) | |||
| 2971 | 3066 | ||
| 2972 | dprintk("--> %s\n", __func__); | 3067 | dprintk("--> %s\n", __func__); |
| 2973 | 3068 | ||
| 2974 | /* nfs4_sequence_free_slot called in the read rpc_call_done */ | ||
| 2975 | nfs4_sequence_done(server, &data->res.seq_res, task->tk_status); | 3069 | nfs4_sequence_done(server, &data->res.seq_res, task->tk_status); |
| 2976 | 3070 | ||
| 2977 | if (nfs4_async_handle_error(task, server, data->args.context->state) == -EAGAIN) { | 3071 | if (nfs4_async_handle_error(task, server, data->args.context->state) == -EAGAIN) { |
| 2978 | nfs4_restart_rpc(task, server->nfs_client); | 3072 | nfs_restart_rpc(task, server->nfs_client); |
| 2979 | return -EAGAIN; | 3073 | return -EAGAIN; |
| 2980 | } | 3074 | } |
| 2981 | 3075 | ||
| @@ -2995,12 +3089,11 @@ static int nfs4_write_done(struct rpc_task *task, struct nfs_write_data *data) | |||
| 2995 | { | 3089 | { |
| 2996 | struct inode *inode = data->inode; | 3090 | struct inode *inode = data->inode; |
| 2997 | 3091 | ||
| 2998 | /* slot is freed in nfs_writeback_done */ | ||
| 2999 | nfs4_sequence_done(NFS_SERVER(inode), &data->res.seq_res, | 3092 | nfs4_sequence_done(NFS_SERVER(inode), &data->res.seq_res, |
| 3000 | task->tk_status); | 3093 | task->tk_status); |
| 3001 | 3094 | ||
| 3002 | if (nfs4_async_handle_error(task, NFS_SERVER(inode), data->args.context->state) == -EAGAIN) { | 3095 | if (nfs4_async_handle_error(task, NFS_SERVER(inode), data->args.context->state) == -EAGAIN) { |
| 3003 | nfs4_restart_rpc(task, NFS_SERVER(inode)->nfs_client); | 3096 | nfs_restart_rpc(task, NFS_SERVER(inode)->nfs_client); |
| 3004 | return -EAGAIN; | 3097 | return -EAGAIN; |
| 3005 | } | 3098 | } |
| 3006 | if (task->tk_status >= 0) { | 3099 | if (task->tk_status >= 0) { |
| @@ -3028,11 +3121,9 @@ static int nfs4_commit_done(struct rpc_task *task, struct nfs_write_data *data) | |||
| 3028 | nfs4_sequence_done(NFS_SERVER(inode), &data->res.seq_res, | 3121 | nfs4_sequence_done(NFS_SERVER(inode), &data->res.seq_res, |
| 3029 | task->tk_status); | 3122 | task->tk_status); |
| 3030 | if (nfs4_async_handle_error(task, NFS_SERVER(inode), NULL) == -EAGAIN) { | 3123 | if (nfs4_async_handle_error(task, NFS_SERVER(inode), NULL) == -EAGAIN) { |
| 3031 | nfs4_restart_rpc(task, NFS_SERVER(inode)->nfs_client); | 3124 | nfs_restart_rpc(task, NFS_SERVER(inode)->nfs_client); |
| 3032 | return -EAGAIN; | 3125 | return -EAGAIN; |
| 3033 | } | 3126 | } |
| 3034 | nfs4_sequence_free_slot(NFS_SERVER(inode)->nfs_client, | ||
| 3035 | &data->res.seq_res); | ||
| 3036 | nfs_refresh_inode(inode, data->res.fattr); | 3127 | nfs_refresh_inode(inode, data->res.fattr); |
| 3037 | return 0; | 3128 | return 0; |
| 3038 | } | 3129 | } |
| @@ -3350,7 +3441,7 @@ _nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server, | |||
| 3350 | case -NFS4ERR_SEQ_MISORDERED: | 3441 | case -NFS4ERR_SEQ_MISORDERED: |
| 3351 | dprintk("%s ERROR %d, Reset session\n", __func__, | 3442 | dprintk("%s ERROR %d, Reset session\n", __func__, |
| 3352 | task->tk_status); | 3443 | task->tk_status); |
| 3353 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | 3444 | nfs4_schedule_state_recovery(clp); |
| 3354 | task->tk_status = 0; | 3445 | task->tk_status = 0; |
| 3355 | return -EAGAIN; | 3446 | return -EAGAIN; |
| 3356 | #endif /* CONFIG_NFS_V4_1 */ | 3447 | #endif /* CONFIG_NFS_V4_1 */ |
| @@ -3483,12 +3574,23 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) | |||
| 3483 | { | 3574 | { |
| 3484 | struct nfs4_delegreturndata *data = calldata; | 3575 | struct nfs4_delegreturndata *data = calldata; |
| 3485 | 3576 | ||
| 3486 | nfs4_sequence_done_free_slot(data->res.server, &data->res.seq_res, | 3577 | nfs4_sequence_done(data->res.server, &data->res.seq_res, |
| 3487 | task->tk_status); | 3578 | task->tk_status); |
| 3488 | 3579 | ||
| 3489 | data->rpc_status = task->tk_status; | 3580 | switch (task->tk_status) { |
| 3490 | if (data->rpc_status == 0) | 3581 | case -NFS4ERR_STALE_STATEID: |
| 3582 | case -NFS4ERR_EXPIRED: | ||
| 3583 | case 0: | ||
| 3491 | renew_lease(data->res.server, data->timestamp); | 3584 | renew_lease(data->res.server, data->timestamp); |
| 3585 | break; | ||
| 3586 | default: | ||
| 3587 | if (nfs4_async_handle_error(task, data->res.server, NULL) == | ||
| 3588 | -EAGAIN) { | ||
| 3589 | nfs_restart_rpc(task, data->res.server->nfs_client); | ||
| 3590 | return; | ||
| 3591 | } | ||
| 3592 | } | ||
| 3593 | data->rpc_status = task->tk_status; | ||
| 3492 | } | 3594 | } |
| 3493 | 3595 | ||
| 3494 | static void nfs4_delegreturn_release(void *calldata) | 3596 | static void nfs4_delegreturn_release(void *calldata) |
| @@ -3741,11 +3843,9 @@ static void nfs4_locku_done(struct rpc_task *task, void *data) | |||
| 3741 | break; | 3843 | break; |
| 3742 | default: | 3844 | default: |
| 3743 | if (nfs4_async_handle_error(task, calldata->server, NULL) == -EAGAIN) | 3845 | if (nfs4_async_handle_error(task, calldata->server, NULL) == -EAGAIN) |
| 3744 | nfs4_restart_rpc(task, | 3846 | nfs_restart_rpc(task, |
| 3745 | calldata->server->nfs_client); | 3847 | calldata->server->nfs_client); |
| 3746 | } | 3848 | } |
| 3747 | nfs4_sequence_free_slot(calldata->server->nfs_client, | ||
| 3748 | &calldata->res.seq_res); | ||
| 3749 | } | 3849 | } |
| 3750 | 3850 | ||
| 3751 | static void nfs4_locku_prepare(struct rpc_task *task, void *data) | 3851 | static void nfs4_locku_prepare(struct rpc_task *task, void *data) |
| @@ -3921,14 +4021,20 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata) | |||
| 3921 | dprintk("%s: done!, ret = %d\n", __func__, data->rpc_status); | 4021 | dprintk("%s: done!, ret = %d\n", __func__, data->rpc_status); |
| 3922 | } | 4022 | } |
| 3923 | 4023 | ||
| 4024 | static void nfs4_recover_lock_prepare(struct rpc_task *task, void *calldata) | ||
| 4025 | { | ||
| 4026 | rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED); | ||
| 4027 | nfs4_lock_prepare(task, calldata); | ||
| 4028 | } | ||
| 4029 | |||
| 3924 | static void nfs4_lock_done(struct rpc_task *task, void *calldata) | 4030 | static void nfs4_lock_done(struct rpc_task *task, void *calldata) |
| 3925 | { | 4031 | { |
| 3926 | struct nfs4_lockdata *data = calldata; | 4032 | struct nfs4_lockdata *data = calldata; |
| 3927 | 4033 | ||
| 3928 | dprintk("%s: begin!\n", __func__); | 4034 | dprintk("%s: begin!\n", __func__); |
| 3929 | 4035 | ||
| 3930 | nfs4_sequence_done_free_slot(data->server, &data->res.seq_res, | 4036 | nfs4_sequence_done(data->server, &data->res.seq_res, |
| 3931 | task->tk_status); | 4037 | task->tk_status); |
| 3932 | 4038 | ||
| 3933 | data->rpc_status = task->tk_status; | 4039 | data->rpc_status = task->tk_status; |
| 3934 | if (RPC_ASSASSINATED(task)) | 4040 | if (RPC_ASSASSINATED(task)) |
| @@ -3976,7 +4082,13 @@ static const struct rpc_call_ops nfs4_lock_ops = { | |||
| 3976 | .rpc_release = nfs4_lock_release, | 4082 | .rpc_release = nfs4_lock_release, |
| 3977 | }; | 4083 | }; |
| 3978 | 4084 | ||
| 3979 | static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *fl, int reclaim) | 4085 | static const struct rpc_call_ops nfs4_recover_lock_ops = { |
| 4086 | .rpc_call_prepare = nfs4_recover_lock_prepare, | ||
| 4087 | .rpc_call_done = nfs4_lock_done, | ||
| 4088 | .rpc_release = nfs4_lock_release, | ||
| 4089 | }; | ||
| 4090 | |||
| 4091 | static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *fl, int recovery_type) | ||
| 3980 | { | 4092 | { |
| 3981 | struct nfs4_lockdata *data; | 4093 | struct nfs4_lockdata *data; |
| 3982 | struct rpc_task *task; | 4094 | struct rpc_task *task; |
| @@ -4000,8 +4112,11 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f | |||
| 4000 | return -ENOMEM; | 4112 | return -ENOMEM; |
| 4001 | if (IS_SETLKW(cmd)) | 4113 | if (IS_SETLKW(cmd)) |
| 4002 | data->arg.block = 1; | 4114 | data->arg.block = 1; |
| 4003 | if (reclaim != 0) | 4115 | if (recovery_type > NFS_LOCK_NEW) { |
| 4004 | data->arg.reclaim = 1; | 4116 | if (recovery_type == NFS_LOCK_RECLAIM) |
| 4117 | data->arg.reclaim = NFS_LOCK_RECLAIM; | ||
| 4118 | task_setup_data.callback_ops = &nfs4_recover_lock_ops; | ||
| 4119 | } | ||
| 4005 | msg.rpc_argp = &data->arg, | 4120 | msg.rpc_argp = &data->arg, |
| 4006 | msg.rpc_resp = &data->res, | 4121 | msg.rpc_resp = &data->res, |
| 4007 | task_setup_data.callback_data = data; | 4122 | task_setup_data.callback_data = data; |
| @@ -4028,7 +4143,7 @@ static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request | |||
| 4028 | /* Cache the lock if possible... */ | 4143 | /* Cache the lock if possible... */ |
| 4029 | if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) | 4144 | if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) |
| 4030 | return 0; | 4145 | return 0; |
| 4031 | err = _nfs4_do_setlk(state, F_SETLK, request, 1); | 4146 | err = _nfs4_do_setlk(state, F_SETLK, request, NFS_LOCK_RECLAIM); |
| 4032 | if (err != -NFS4ERR_DELAY) | 4147 | if (err != -NFS4ERR_DELAY) |
| 4033 | break; | 4148 | break; |
| 4034 | nfs4_handle_exception(server, err, &exception); | 4149 | nfs4_handle_exception(server, err, &exception); |
| @@ -4048,11 +4163,17 @@ static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request | |||
| 4048 | do { | 4163 | do { |
| 4049 | if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) | 4164 | if (test_bit(NFS_DELEGATED_STATE, &state->flags) != 0) |
| 4050 | return 0; | 4165 | return 0; |
| 4051 | err = _nfs4_do_setlk(state, F_SETLK, request, 0); | 4166 | err = _nfs4_do_setlk(state, F_SETLK, request, NFS_LOCK_EXPIRED); |
| 4052 | if (err != -NFS4ERR_DELAY) | 4167 | switch (err) { |
| 4053 | break; | 4168 | default: |
| 4054 | nfs4_handle_exception(server, err, &exception); | 4169 | goto out; |
| 4170 | case -NFS4ERR_GRACE: | ||
| 4171 | case -NFS4ERR_DELAY: | ||
| 4172 | nfs4_handle_exception(server, err, &exception); | ||
| 4173 | err = 0; | ||
| 4174 | } | ||
| 4055 | } while (exception.retry); | 4175 | } while (exception.retry); |
| 4176 | out: | ||
| 4056 | return err; | 4177 | return err; |
| 4057 | } | 4178 | } |
| 4058 | 4179 | ||
| @@ -4078,7 +4199,7 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock | |||
| 4078 | status = do_vfs_lock(request->fl_file, request); | 4199 | status = do_vfs_lock(request->fl_file, request); |
| 4079 | goto out_unlock; | 4200 | goto out_unlock; |
| 4080 | } | 4201 | } |
| 4081 | status = _nfs4_do_setlk(state, cmd, request, 0); | 4202 | status = _nfs4_do_setlk(state, cmd, request, NFS_LOCK_NEW); |
| 4082 | if (status != 0) | 4203 | if (status != 0) |
| 4083 | goto out_unlock; | 4204 | goto out_unlock; |
| 4084 | /* Note: we always want to sleep here! */ | 4205 | /* Note: we always want to sleep here! */ |
| @@ -4161,7 +4282,7 @@ int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl) | |||
| 4161 | if (err != 0) | 4282 | if (err != 0) |
| 4162 | goto out; | 4283 | goto out; |
| 4163 | do { | 4284 | do { |
| 4164 | err = _nfs4_do_setlk(state, F_SETLK, fl, 0); | 4285 | err = _nfs4_do_setlk(state, F_SETLK, fl, NFS_LOCK_NEW); |
| 4165 | switch (err) { | 4286 | switch (err) { |
| 4166 | default: | 4287 | default: |
| 4167 | printk(KERN_ERR "%s: unhandled error %d.\n", | 4288 | printk(KERN_ERR "%s: unhandled error %d.\n", |
| @@ -4172,6 +4293,11 @@ int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl) | |||
| 4172 | case -NFS4ERR_EXPIRED: | 4293 | case -NFS4ERR_EXPIRED: |
| 4173 | case -NFS4ERR_STALE_CLIENTID: | 4294 | case -NFS4ERR_STALE_CLIENTID: |
| 4174 | case -NFS4ERR_STALE_STATEID: | 4295 | case -NFS4ERR_STALE_STATEID: |
| 4296 | case -NFS4ERR_BADSESSION: | ||
| 4297 | case -NFS4ERR_BADSLOT: | ||
| 4298 | case -NFS4ERR_BAD_HIGH_SLOT: | ||
| 4299 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: | ||
| 4300 | case -NFS4ERR_DEADSESSION: | ||
| 4175 | nfs4_schedule_state_recovery(server->nfs_client); | 4301 | nfs4_schedule_state_recovery(server->nfs_client); |
| 4176 | goto out; | 4302 | goto out; |
| 4177 | case -ERESTARTSYS: | 4303 | case -ERESTARTSYS: |
| @@ -4296,7 +4422,7 @@ int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name, | |||
| 4296 | * NFS4ERR_BADSESSION in the sequence operation, and will therefore | 4422 | * NFS4ERR_BADSESSION in the sequence operation, and will therefore |
| 4297 | * be in some phase of session reset. | 4423 | * be in some phase of session reset. |
| 4298 | */ | 4424 | */ |
| 4299 | static int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred) | 4425 | int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred) |
| 4300 | { | 4426 | { |
| 4301 | nfs4_verifier verifier; | 4427 | nfs4_verifier verifier; |
| 4302 | struct nfs41_exchange_id_args args = { | 4428 | struct nfs41_exchange_id_args args = { |
| @@ -4318,6 +4444,9 @@ static int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred) | |||
| 4318 | dprintk("--> %s\n", __func__); | 4444 | dprintk("--> %s\n", __func__); |
| 4319 | BUG_ON(clp == NULL); | 4445 | BUG_ON(clp == NULL); |
| 4320 | 4446 | ||
| 4447 | /* Remove server-only flags */ | ||
| 4448 | args.flags &= ~EXCHGID4_FLAG_CONFIRMED_R; | ||
| 4449 | |||
| 4321 | p = (u32 *)verifier.data; | 4450 | p = (u32 *)verifier.data; |
| 4322 | *p++ = htonl((u32)clp->cl_boot_time.tv_sec); | 4451 | *p++ = htonl((u32)clp->cl_boot_time.tv_sec); |
| 4323 | *p = htonl((u32)clp->cl_boot_time.tv_nsec); | 4452 | *p = htonl((u32)clp->cl_boot_time.tv_nsec); |
| @@ -4361,11 +4490,12 @@ static void nfs4_get_lease_time_prepare(struct rpc_task *task, | |||
| 4361 | (struct nfs4_get_lease_time_data *)calldata; | 4490 | (struct nfs4_get_lease_time_data *)calldata; |
| 4362 | 4491 | ||
| 4363 | dprintk("--> %s\n", __func__); | 4492 | dprintk("--> %s\n", __func__); |
| 4493 | rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED); | ||
| 4364 | /* just setup sequence, do not trigger session recovery | 4494 | /* just setup sequence, do not trigger session recovery |
| 4365 | since we're invoked within one */ | 4495 | since we're invoked within one */ |
| 4366 | ret = nfs41_setup_sequence(data->clp->cl_session, | 4496 | ret = nfs41_setup_sequence(data->clp->cl_session, |
| 4367 | &data->args->la_seq_args, | 4497 | &data->args->la_seq_args, |
| 4368 | &data->res->lr_seq_res, 0, task); | 4498 | &data->res->lr_seq_res, 0, task); |
| 4369 | 4499 | ||
| 4370 | BUG_ON(ret == -EAGAIN); | 4500 | BUG_ON(ret == -EAGAIN); |
| 4371 | rpc_call_start(task); | 4501 | rpc_call_start(task); |
| @@ -4389,10 +4519,9 @@ static void nfs4_get_lease_time_done(struct rpc_task *task, void *calldata) | |||
| 4389 | dprintk("%s Retry: tk_status %d\n", __func__, task->tk_status); | 4519 | dprintk("%s Retry: tk_status %d\n", __func__, task->tk_status); |
| 4390 | rpc_delay(task, NFS4_POLL_RETRY_MIN); | 4520 | rpc_delay(task, NFS4_POLL_RETRY_MIN); |
| 4391 | task->tk_status = 0; | 4521 | task->tk_status = 0; |
| 4392 | nfs4_restart_rpc(task, data->clp); | 4522 | nfs_restart_rpc(task, data->clp); |
| 4393 | return; | 4523 | return; |
| 4394 | } | 4524 | } |
| 4395 | nfs41_sequence_free_slot(data->clp, &data->res->lr_seq_res); | ||
| 4396 | dprintk("<-- %s\n", __func__); | 4525 | dprintk("<-- %s\n", __func__); |
| 4397 | } | 4526 | } |
| 4398 | 4527 | ||
| @@ -4465,7 +4594,6 @@ static int nfs4_reset_slot_table(struct nfs4_slot_table *tbl, int max_slots, | |||
| 4465 | spin_lock(&tbl->slot_tbl_lock); | 4594 | spin_lock(&tbl->slot_tbl_lock); |
| 4466 | for (i = 0; i < max_slots; ++i) | 4595 | for (i = 0; i < max_slots; ++i) |
| 4467 | tbl->slots[i].seq_nr = ivalue; | 4596 | tbl->slots[i].seq_nr = ivalue; |
| 4468 | tbl->highest_used_slotid = -1; | ||
| 4469 | spin_unlock(&tbl->slot_tbl_lock); | 4597 | spin_unlock(&tbl->slot_tbl_lock); |
| 4470 | dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__, | 4598 | dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__, |
| 4471 | tbl, tbl->slots, tbl->max_slots); | 4599 | tbl, tbl->slots, tbl->max_slots); |
| @@ -4515,7 +4643,6 @@ static void nfs4_destroy_slot_tables(struct nfs4_session *session) | |||
| 4515 | static int nfs4_init_slot_table(struct nfs4_slot_table *tbl, | 4643 | static int nfs4_init_slot_table(struct nfs4_slot_table *tbl, |
| 4516 | int max_slots, int ivalue) | 4644 | int max_slots, int ivalue) |
| 4517 | { | 4645 | { |
| 4518 | int i; | ||
| 4519 | struct nfs4_slot *slot; | 4646 | struct nfs4_slot *slot; |
| 4520 | int ret = -ENOMEM; | 4647 | int ret = -ENOMEM; |
| 4521 | 4648 | ||
| @@ -4526,18 +4653,9 @@ static int nfs4_init_slot_table(struct nfs4_slot_table *tbl, | |||
| 4526 | slot = kcalloc(max_slots, sizeof(struct nfs4_slot), GFP_KERNEL); | 4653 | slot = kcalloc(max_slots, sizeof(struct nfs4_slot), GFP_KERNEL); |
| 4527 | if (!slot) | 4654 | if (!slot) |
| 4528 | goto out; | 4655 | goto out; |
| 4529 | for (i = 0; i < max_slots; ++i) | ||
| 4530 | slot[i].seq_nr = ivalue; | ||
| 4531 | ret = 0; | 4656 | ret = 0; |
| 4532 | 4657 | ||
| 4533 | spin_lock(&tbl->slot_tbl_lock); | 4658 | spin_lock(&tbl->slot_tbl_lock); |
| 4534 | if (tbl->slots != NULL) { | ||
| 4535 | spin_unlock(&tbl->slot_tbl_lock); | ||
| 4536 | dprintk("%s: slot table already initialized. tbl=%p slots=%p\n", | ||
| 4537 | __func__, tbl, tbl->slots); | ||
| 4538 | WARN_ON(1); | ||
| 4539 | goto out_free; | ||
| 4540 | } | ||
| 4541 | tbl->max_slots = max_slots; | 4659 | tbl->max_slots = max_slots; |
| 4542 | tbl->slots = slot; | 4660 | tbl->slots = slot; |
| 4543 | tbl->highest_used_slotid = -1; /* no slot is currently used */ | 4661 | tbl->highest_used_slotid = -1; /* no slot is currently used */ |
| @@ -4547,10 +4665,6 @@ static int nfs4_init_slot_table(struct nfs4_slot_table *tbl, | |||
| 4547 | out: | 4665 | out: |
| 4548 | dprintk("<-- %s: return %d\n", __func__, ret); | 4666 | dprintk("<-- %s: return %d\n", __func__, ret); |
| 4549 | return ret; | 4667 | return ret; |
| 4550 | |||
| 4551 | out_free: | ||
| 4552 | kfree(slot); | ||
| 4553 | goto out; | ||
| 4554 | } | 4668 | } |
| 4555 | 4669 | ||
| 4556 | /* | 4670 | /* |
| @@ -4558,17 +4672,24 @@ out_free: | |||
| 4558 | */ | 4672 | */ |
| 4559 | static int nfs4_init_slot_tables(struct nfs4_session *session) | 4673 | static int nfs4_init_slot_tables(struct nfs4_session *session) |
| 4560 | { | 4674 | { |
| 4561 | int status; | 4675 | struct nfs4_slot_table *tbl; |
| 4676 | int status = 0; | ||
| 4562 | 4677 | ||
| 4563 | status = nfs4_init_slot_table(&session->fc_slot_table, | 4678 | tbl = &session->fc_slot_table; |
| 4564 | session->fc_attrs.max_reqs, 1); | 4679 | if (tbl->slots == NULL) { |
| 4565 | if (status) | 4680 | status = nfs4_init_slot_table(tbl, |
| 4566 | return status; | 4681 | session->fc_attrs.max_reqs, 1); |
| 4682 | if (status) | ||
| 4683 | return status; | ||
| 4684 | } | ||
| 4567 | 4685 | ||
| 4568 | status = nfs4_init_slot_table(&session->bc_slot_table, | 4686 | tbl = &session->bc_slot_table; |
| 4569 | session->bc_attrs.max_reqs, 0); | 4687 | if (tbl->slots == NULL) { |
| 4570 | if (status) | 4688 | status = nfs4_init_slot_table(tbl, |
| 4571 | nfs4_destroy_slot_tables(session); | 4689 | session->bc_attrs.max_reqs, 0); |
| 4690 | if (status) | ||
| 4691 | nfs4_destroy_slot_tables(session); | ||
| 4692 | } | ||
| 4572 | 4693 | ||
| 4573 | return status; | 4694 | return status; |
| 4574 | } | 4695 | } |
| @@ -4582,7 +4703,6 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp) | |||
| 4582 | if (!session) | 4703 | if (!session) |
| 4583 | return NULL; | 4704 | return NULL; |
| 4584 | 4705 | ||
| 4585 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | ||
| 4586 | /* | 4706 | /* |
| 4587 | * The create session reply races with the server back | 4707 | * The create session reply races with the server back |
| 4588 | * channel probe. Mark the client NFS_CS_SESSION_INITING | 4708 | * channel probe. Mark the client NFS_CS_SESSION_INITING |
| @@ -4590,12 +4710,15 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp) | |||
| 4590 | * nfs_client struct | 4710 | * nfs_client struct |
| 4591 | */ | 4711 | */ |
| 4592 | clp->cl_cons_state = NFS_CS_SESSION_INITING; | 4712 | clp->cl_cons_state = NFS_CS_SESSION_INITING; |
| 4713 | init_completion(&session->complete); | ||
| 4593 | 4714 | ||
| 4594 | tbl = &session->fc_slot_table; | 4715 | tbl = &session->fc_slot_table; |
| 4716 | tbl->highest_used_slotid = -1; | ||
| 4595 | spin_lock_init(&tbl->slot_tbl_lock); | 4717 | spin_lock_init(&tbl->slot_tbl_lock); |
| 4596 | rpc_init_wait_queue(&tbl->slot_tbl_waitq, "ForeChannel Slot table"); | 4718 | rpc_init_priority_wait_queue(&tbl->slot_tbl_waitq, "ForeChannel Slot table"); |
| 4597 | 4719 | ||
| 4598 | tbl = &session->bc_slot_table; | 4720 | tbl = &session->bc_slot_table; |
| 4721 | tbl->highest_used_slotid = -1; | ||
| 4599 | spin_lock_init(&tbl->slot_tbl_lock); | 4722 | spin_lock_init(&tbl->slot_tbl_lock); |
| 4600 | rpc_init_wait_queue(&tbl->slot_tbl_waitq, "BackChannel Slot table"); | 4723 | rpc_init_wait_queue(&tbl->slot_tbl_waitq, "BackChannel Slot table"); |
| 4601 | 4724 | ||
| @@ -4747,11 +4870,10 @@ static int _nfs4_proc_create_session(struct nfs_client *clp) | |||
| 4747 | * It is the responsibility of the caller to verify the session is | 4870 | * It is the responsibility of the caller to verify the session is |
| 4748 | * expired before calling this routine. | 4871 | * expired before calling this routine. |
| 4749 | */ | 4872 | */ |
| 4750 | int nfs4_proc_create_session(struct nfs_client *clp, int reset) | 4873 | int nfs4_proc_create_session(struct nfs_client *clp) |
| 4751 | { | 4874 | { |
| 4752 | int status; | 4875 | int status; |
| 4753 | unsigned *ptr; | 4876 | unsigned *ptr; |
| 4754 | struct nfs_fsinfo fsinfo; | ||
| 4755 | struct nfs4_session *session = clp->cl_session; | 4877 | struct nfs4_session *session = clp->cl_session; |
| 4756 | 4878 | ||
| 4757 | dprintk("--> %s clp=%p session=%p\n", __func__, clp, session); | 4879 | dprintk("--> %s clp=%p session=%p\n", __func__, clp, session); |
| @@ -4760,35 +4882,19 @@ int nfs4_proc_create_session(struct nfs_client *clp, int reset) | |||
| 4760 | if (status) | 4882 | if (status) |
| 4761 | goto out; | 4883 | goto out; |
| 4762 | 4884 | ||
| 4763 | /* Init or reset the fore channel */ | 4885 | /* Init and reset the fore channel */ |
| 4764 | if (reset) | 4886 | status = nfs4_init_slot_tables(session); |
| 4765 | status = nfs4_reset_slot_tables(session); | 4887 | dprintk("slot table initialization returned %d\n", status); |
| 4766 | else | 4888 | if (status) |
| 4767 | status = nfs4_init_slot_tables(session); | 4889 | goto out; |
| 4768 | dprintk("fore channel slot table initialization returned %d\n", status); | 4890 | status = nfs4_reset_slot_tables(session); |
| 4891 | dprintk("slot table reset returned %d\n", status); | ||
| 4769 | if (status) | 4892 | if (status) |
| 4770 | goto out; | 4893 | goto out; |
| 4771 | 4894 | ||
| 4772 | ptr = (unsigned *)&session->sess_id.data[0]; | 4895 | ptr = (unsigned *)&session->sess_id.data[0]; |
| 4773 | dprintk("%s client>seqid %d sessionid %u:%u:%u:%u\n", __func__, | 4896 | dprintk("%s client>seqid %d sessionid %u:%u:%u:%u\n", __func__, |
| 4774 | clp->cl_seqid, ptr[0], ptr[1], ptr[2], ptr[3]); | 4897 | clp->cl_seqid, ptr[0], ptr[1], ptr[2], ptr[3]); |
| 4775 | |||
| 4776 | if (reset) | ||
| 4777 | /* Lease time is aleady set */ | ||
| 4778 | goto out; | ||
| 4779 | |||
| 4780 | /* Get the lease time */ | ||
| 4781 | status = nfs4_proc_get_lease_time(clp, &fsinfo); | ||
| 4782 | if (status == 0) { | ||
| 4783 | /* Update lease time and schedule renewal */ | ||
| 4784 | spin_lock(&clp->cl_lock); | ||
| 4785 | clp->cl_lease_time = fsinfo.lease_time * HZ; | ||
| 4786 | clp->cl_last_renewal = jiffies; | ||
| 4787 | clear_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | ||
| 4788 | spin_unlock(&clp->cl_lock); | ||
| 4789 | |||
| 4790 | nfs4_schedule_state_renewal(clp); | ||
| 4791 | } | ||
| 4792 | out: | 4898 | out: |
| 4793 | dprintk("<-- %s\n", __func__); | 4899 | dprintk("<-- %s\n", __func__); |
| 4794 | return status; | 4900 | return status; |
| @@ -4827,13 +4933,24 @@ int nfs4_proc_destroy_session(struct nfs4_session *session) | |||
| 4827 | int nfs4_init_session(struct nfs_server *server) | 4933 | int nfs4_init_session(struct nfs_server *server) |
| 4828 | { | 4934 | { |
| 4829 | struct nfs_client *clp = server->nfs_client; | 4935 | struct nfs_client *clp = server->nfs_client; |
| 4936 | struct nfs4_session *session; | ||
| 4937 | unsigned int rsize, wsize; | ||
| 4830 | int ret; | 4938 | int ret; |
| 4831 | 4939 | ||
| 4832 | if (!nfs4_has_session(clp)) | 4940 | if (!nfs4_has_session(clp)) |
| 4833 | return 0; | 4941 | return 0; |
| 4834 | 4942 | ||
| 4835 | clp->cl_session->fc_attrs.max_rqst_sz = server->wsize; | 4943 | rsize = server->rsize; |
| 4836 | clp->cl_session->fc_attrs.max_resp_sz = server->rsize; | 4944 | if (rsize == 0) |
| 4945 | rsize = NFS_MAX_FILE_IO_SIZE; | ||
| 4946 | wsize = server->wsize; | ||
| 4947 | if (wsize == 0) | ||
| 4948 | wsize = NFS_MAX_FILE_IO_SIZE; | ||
| 4949 | |||
| 4950 | session = clp->cl_session; | ||
| 4951 | session->fc_attrs.max_rqst_sz = wsize + nfs41_maxwrite_overhead; | ||
| 4952 | session->fc_attrs.max_resp_sz = rsize + nfs41_maxread_overhead; | ||
| 4953 | |||
| 4837 | ret = nfs4_recover_expired_lease(server); | 4954 | ret = nfs4_recover_expired_lease(server); |
| 4838 | if (!ret) | 4955 | if (!ret) |
| 4839 | ret = nfs4_check_client_ready(clp); | 4956 | ret = nfs4_check_client_ready(clp); |
| @@ -4858,7 +4975,7 @@ static int nfs4_proc_sequence(struct nfs_client *clp, struct rpc_cred *cred) | |||
| 4858 | args.sa_cache_this = 0; | 4975 | args.sa_cache_this = 0; |
| 4859 | 4976 | ||
| 4860 | return nfs4_call_sync_sequence(clp, clp->cl_rpcclient, &msg, &args, | 4977 | return nfs4_call_sync_sequence(clp, clp->cl_rpcclient, &msg, &args, |
| 4861 | &res, 0); | 4978 | &res, args.sa_cache_this, 1); |
| 4862 | } | 4979 | } |
| 4863 | 4980 | ||
| 4864 | void nfs41_sequence_call_done(struct rpc_task *task, void *data) | 4981 | void nfs41_sequence_call_done(struct rpc_task *task, void *data) |
| @@ -4872,11 +4989,10 @@ void nfs41_sequence_call_done(struct rpc_task *task, void *data) | |||
| 4872 | 4989 | ||
| 4873 | if (_nfs4_async_handle_error(task, NULL, clp, NULL) | 4990 | if (_nfs4_async_handle_error(task, NULL, clp, NULL) |
| 4874 | == -EAGAIN) { | 4991 | == -EAGAIN) { |
| 4875 | nfs4_restart_rpc(task, clp); | 4992 | nfs_restart_rpc(task, clp); |
| 4876 | return; | 4993 | return; |
| 4877 | } | 4994 | } |
| 4878 | } | 4995 | } |
| 4879 | nfs41_sequence_free_slot(clp, task->tk_msg.rpc_resp); | ||
| 4880 | dprintk("%s rpc_cred %p\n", __func__, task->tk_msg.rpc_cred); | 4996 | dprintk("%s rpc_cred %p\n", __func__, task->tk_msg.rpc_cred); |
| 4881 | 4997 | ||
| 4882 | kfree(task->tk_msg.rpc_argp); | 4998 | kfree(task->tk_msg.rpc_argp); |
| @@ -4931,6 +5047,110 @@ static int nfs41_proc_async_sequence(struct nfs_client *clp, | |||
| 4931 | &nfs41_sequence_ops, (void *)clp); | 5047 | &nfs41_sequence_ops, (void *)clp); |
| 4932 | } | 5048 | } |
| 4933 | 5049 | ||
| 5050 | struct nfs4_reclaim_complete_data { | ||
| 5051 | struct nfs_client *clp; | ||
| 5052 | struct nfs41_reclaim_complete_args arg; | ||
| 5053 | struct nfs41_reclaim_complete_res res; | ||
| 5054 | }; | ||
| 5055 | |||
| 5056 | static void nfs4_reclaim_complete_prepare(struct rpc_task *task, void *data) | ||
| 5057 | { | ||
| 5058 | struct nfs4_reclaim_complete_data *calldata = data; | ||
| 5059 | |||
| 5060 | rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED); | ||
| 5061 | if (nfs4_setup_sequence(calldata->clp, &calldata->arg.seq_args, | ||
| 5062 | &calldata->res.seq_res, 0, task)) | ||
| 5063 | return; | ||
| 5064 | |||
| 5065 | rpc_call_start(task); | ||
| 5066 | } | ||
| 5067 | |||
| 5068 | static void nfs4_reclaim_complete_done(struct rpc_task *task, void *data) | ||
| 5069 | { | ||
| 5070 | struct nfs4_reclaim_complete_data *calldata = data; | ||
| 5071 | struct nfs_client *clp = calldata->clp; | ||
| 5072 | struct nfs4_sequence_res *res = &calldata->res.seq_res; | ||
| 5073 | |||
| 5074 | dprintk("--> %s\n", __func__); | ||
| 5075 | nfs41_sequence_done(clp, res, task->tk_status); | ||
| 5076 | switch (task->tk_status) { | ||
| 5077 | case 0: | ||
| 5078 | case -NFS4ERR_COMPLETE_ALREADY: | ||
| 5079 | break; | ||
| 5080 | case -NFS4ERR_BADSESSION: | ||
| 5081 | case -NFS4ERR_DEADSESSION: | ||
| 5082 | /* | ||
| 5083 | * Handle the session error, but do not retry the operation, as | ||
| 5084 | * we have no way of telling whether the clientid had to be | ||
| 5085 | * reset before we got our reply. If reset, a new wave of | ||
| 5086 | * reclaim operations will follow, containing their own reclaim | ||
| 5087 | * complete. We don't want our retry to get on the way of | ||
| 5088 | * recovery by incorrectly indicating to the server that we're | ||
| 5089 | * done reclaiming state since the process had to be restarted. | ||
| 5090 | */ | ||
| 5091 | _nfs4_async_handle_error(task, NULL, clp, NULL); | ||
| 5092 | break; | ||
| 5093 | default: | ||
| 5094 | if (_nfs4_async_handle_error( | ||
| 5095 | task, NULL, clp, NULL) == -EAGAIN) { | ||
| 5096 | rpc_restart_call_prepare(task); | ||
| 5097 | return; | ||
| 5098 | } | ||
| 5099 | } | ||
| 5100 | |||
| 5101 | dprintk("<-- %s\n", __func__); | ||
| 5102 | } | ||
| 5103 | |||
| 5104 | static void nfs4_free_reclaim_complete_data(void *data) | ||
| 5105 | { | ||
| 5106 | struct nfs4_reclaim_complete_data *calldata = data; | ||
| 5107 | |||
| 5108 | kfree(calldata); | ||
| 5109 | } | ||
| 5110 | |||
| 5111 | static const struct rpc_call_ops nfs4_reclaim_complete_call_ops = { | ||
| 5112 | .rpc_call_prepare = nfs4_reclaim_complete_prepare, | ||
| 5113 | .rpc_call_done = nfs4_reclaim_complete_done, | ||
| 5114 | .rpc_release = nfs4_free_reclaim_complete_data, | ||
| 5115 | }; | ||
| 5116 | |||
| 5117 | /* | ||
| 5118 | * Issue a global reclaim complete. | ||
| 5119 | */ | ||
| 5120 | static int nfs41_proc_reclaim_complete(struct nfs_client *clp) | ||
| 5121 | { | ||
| 5122 | struct nfs4_reclaim_complete_data *calldata; | ||
| 5123 | struct rpc_task *task; | ||
| 5124 | struct rpc_message msg = { | ||
| 5125 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RECLAIM_COMPLETE], | ||
| 5126 | }; | ||
| 5127 | struct rpc_task_setup task_setup_data = { | ||
| 5128 | .rpc_client = clp->cl_rpcclient, | ||
| 5129 | .rpc_message = &msg, | ||
| 5130 | .callback_ops = &nfs4_reclaim_complete_call_ops, | ||
| 5131 | .flags = RPC_TASK_ASYNC, | ||
| 5132 | }; | ||
| 5133 | int status = -ENOMEM; | ||
| 5134 | |||
| 5135 | dprintk("--> %s\n", __func__); | ||
| 5136 | calldata = kzalloc(sizeof(*calldata), GFP_KERNEL); | ||
| 5137 | if (calldata == NULL) | ||
| 5138 | goto out; | ||
| 5139 | calldata->clp = clp; | ||
| 5140 | calldata->arg.one_fs = 0; | ||
| 5141 | calldata->res.seq_res.sr_slotid = NFS4_MAX_SLOT_TABLE; | ||
| 5142 | |||
| 5143 | msg.rpc_argp = &calldata->arg; | ||
| 5144 | msg.rpc_resp = &calldata->res; | ||
| 5145 | task_setup_data.callback_data = calldata; | ||
| 5146 | task = rpc_run_task(&task_setup_data); | ||
| 5147 | if (IS_ERR(task)) | ||
| 5148 | status = PTR_ERR(task); | ||
| 5149 | rpc_put_task(task); | ||
| 5150 | out: | ||
| 5151 | dprintk("<-- %s status=%d\n", __func__, status); | ||
| 5152 | return status; | ||
| 5153 | } | ||
| 4934 | #endif /* CONFIG_NFS_V4_1 */ | 5154 | #endif /* CONFIG_NFS_V4_1 */ |
| 4935 | 5155 | ||
| 4936 | struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops = { | 5156 | struct nfs4_state_recovery_ops nfs40_reboot_recovery_ops = { |
| @@ -4948,8 +5168,9 @@ struct nfs4_state_recovery_ops nfs41_reboot_recovery_ops = { | |||
| 4948 | .state_flag_bit = NFS_STATE_RECLAIM_REBOOT, | 5168 | .state_flag_bit = NFS_STATE_RECLAIM_REBOOT, |
| 4949 | .recover_open = nfs4_open_reclaim, | 5169 | .recover_open = nfs4_open_reclaim, |
| 4950 | .recover_lock = nfs4_lock_reclaim, | 5170 | .recover_lock = nfs4_lock_reclaim, |
| 4951 | .establish_clid = nfs4_proc_exchange_id, | 5171 | .establish_clid = nfs41_init_clientid, |
| 4952 | .get_clid_cred = nfs4_get_exchange_id_cred, | 5172 | .get_clid_cred = nfs4_get_exchange_id_cred, |
| 5173 | .reclaim_complete = nfs41_proc_reclaim_complete, | ||
| 4953 | }; | 5174 | }; |
| 4954 | #endif /* CONFIG_NFS_V4_1 */ | 5175 | #endif /* CONFIG_NFS_V4_1 */ |
| 4955 | 5176 | ||
| @@ -4968,7 +5189,7 @@ struct nfs4_state_recovery_ops nfs41_nograce_recovery_ops = { | |||
| 4968 | .state_flag_bit = NFS_STATE_RECLAIM_NOGRACE, | 5189 | .state_flag_bit = NFS_STATE_RECLAIM_NOGRACE, |
| 4969 | .recover_open = nfs4_open_expired, | 5190 | .recover_open = nfs4_open_expired, |
| 4970 | .recover_lock = nfs4_lock_expired, | 5191 | .recover_lock = nfs4_lock_expired, |
| 4971 | .establish_clid = nfs4_proc_exchange_id, | 5192 | .establish_clid = nfs41_init_clientid, |
| 4972 | .get_clid_cred = nfs4_get_exchange_id_cred, | 5193 | .get_clid_cred = nfs4_get_exchange_id_cred, |
| 4973 | }; | 5194 | }; |
| 4974 | #endif /* CONFIG_NFS_V4_1 */ | 5195 | #endif /* CONFIG_NFS_V4_1 */ |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 2ef4fecf3984..6d263ed79e92 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
| @@ -116,6 +116,79 @@ struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp) | |||
| 116 | 116 | ||
| 117 | #if defined(CONFIG_NFS_V4_1) | 117 | #if defined(CONFIG_NFS_V4_1) |
| 118 | 118 | ||
| 119 | static int nfs41_setup_state_renewal(struct nfs_client *clp) | ||
| 120 | { | ||
| 121 | int status; | ||
| 122 | struct nfs_fsinfo fsinfo; | ||
| 123 | |||
| 124 | status = nfs4_proc_get_lease_time(clp, &fsinfo); | ||
| 125 | if (status == 0) { | ||
| 126 | /* Update lease time and schedule renewal */ | ||
| 127 | spin_lock(&clp->cl_lock); | ||
| 128 | clp->cl_lease_time = fsinfo.lease_time * HZ; | ||
| 129 | clp->cl_last_renewal = jiffies; | ||
| 130 | spin_unlock(&clp->cl_lock); | ||
| 131 | |||
| 132 | nfs4_schedule_state_renewal(clp); | ||
| 133 | } | ||
| 134 | |||
| 135 | return status; | ||
| 136 | } | ||
| 137 | |||
| 138 | static void nfs4_end_drain_session(struct nfs_client *clp) | ||
| 139 | { | ||
| 140 | struct nfs4_session *ses = clp->cl_session; | ||
| 141 | int max_slots; | ||
| 142 | |||
| 143 | if (test_and_clear_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state)) { | ||
| 144 | spin_lock(&ses->fc_slot_table.slot_tbl_lock); | ||
| 145 | max_slots = ses->fc_slot_table.max_slots; | ||
| 146 | while (max_slots--) { | ||
| 147 | struct rpc_task *task; | ||
| 148 | |||
| 149 | task = rpc_wake_up_next(&ses->fc_slot_table. | ||
| 150 | slot_tbl_waitq); | ||
| 151 | if (!task) | ||
| 152 | break; | ||
| 153 | rpc_task_set_priority(task, RPC_PRIORITY_PRIVILEGED); | ||
| 154 | } | ||
| 155 | spin_unlock(&ses->fc_slot_table.slot_tbl_lock); | ||
| 156 | } | ||
| 157 | } | ||
| 158 | |||
| 159 | static int nfs4_begin_drain_session(struct nfs_client *clp) | ||
| 160 | { | ||
| 161 | struct nfs4_session *ses = clp->cl_session; | ||
| 162 | struct nfs4_slot_table *tbl = &ses->fc_slot_table; | ||
| 163 | |||
| 164 | spin_lock(&tbl->slot_tbl_lock); | ||
| 165 | set_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state); | ||
| 166 | if (tbl->highest_used_slotid != -1) { | ||
| 167 | INIT_COMPLETION(ses->complete); | ||
| 168 | spin_unlock(&tbl->slot_tbl_lock); | ||
| 169 | return wait_for_completion_interruptible(&ses->complete); | ||
| 170 | } | ||
| 171 | spin_unlock(&tbl->slot_tbl_lock); | ||
| 172 | return 0; | ||
| 173 | } | ||
| 174 | |||
| 175 | int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) | ||
| 176 | { | ||
| 177 | int status; | ||
| 178 | |||
| 179 | nfs4_begin_drain_session(clp); | ||
| 180 | status = nfs4_proc_exchange_id(clp, cred); | ||
| 181 | if (status != 0) | ||
| 182 | goto out; | ||
| 183 | status = nfs4_proc_create_session(clp); | ||
| 184 | if (status != 0) | ||
| 185 | goto out; | ||
| 186 | nfs41_setup_state_renewal(clp); | ||
| 187 | nfs_mark_client_ready(clp, NFS_CS_READY); | ||
| 188 | out: | ||
| 189 | return status; | ||
| 190 | } | ||
| 191 | |||
| 119 | struct rpc_cred *nfs4_get_exchange_id_cred(struct nfs_client *clp) | 192 | struct rpc_cred *nfs4_get_exchange_id_cred(struct nfs_client *clp) |
| 120 | { | 193 | { |
| 121 | struct rpc_cred *cred; | 194 | struct rpc_cred *cred; |
| @@ -693,16 +766,21 @@ struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter) | |||
| 693 | return new; | 766 | return new; |
| 694 | } | 767 | } |
| 695 | 768 | ||
| 696 | void nfs_free_seqid(struct nfs_seqid *seqid) | 769 | void nfs_release_seqid(struct nfs_seqid *seqid) |
| 697 | { | 770 | { |
| 698 | if (!list_empty(&seqid->list)) { | 771 | if (!list_empty(&seqid->list)) { |
| 699 | struct rpc_sequence *sequence = seqid->sequence->sequence; | 772 | struct rpc_sequence *sequence = seqid->sequence->sequence; |
| 700 | 773 | ||
| 701 | spin_lock(&sequence->lock); | 774 | spin_lock(&sequence->lock); |
| 702 | list_del(&seqid->list); | 775 | list_del_init(&seqid->list); |
| 703 | spin_unlock(&sequence->lock); | 776 | spin_unlock(&sequence->lock); |
| 704 | rpc_wake_up(&sequence->wait); | 777 | rpc_wake_up(&sequence->wait); |
| 705 | } | 778 | } |
| 779 | } | ||
| 780 | |||
| 781 | void nfs_free_seqid(struct nfs_seqid *seqid) | ||
| 782 | { | ||
| 783 | nfs_release_seqid(seqid); | ||
| 706 | kfree(seqid); | 784 | kfree(seqid); |
| 707 | } | 785 | } |
| 708 | 786 | ||
| @@ -877,6 +955,10 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_ | |||
| 877 | case -NFS4ERR_EXPIRED: | 955 | case -NFS4ERR_EXPIRED: |
| 878 | case -NFS4ERR_NO_GRACE: | 956 | case -NFS4ERR_NO_GRACE: |
| 879 | case -NFS4ERR_STALE_CLIENTID: | 957 | case -NFS4ERR_STALE_CLIENTID: |
| 958 | case -NFS4ERR_BADSESSION: | ||
| 959 | case -NFS4ERR_BADSLOT: | ||
| 960 | case -NFS4ERR_BAD_HIGH_SLOT: | ||
| 961 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: | ||
| 880 | goto out; | 962 | goto out; |
| 881 | default: | 963 | default: |
| 882 | printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n", | 964 | printk(KERN_ERR "%s: unhandled error %d. Zeroing state\n", |
| @@ -959,6 +1041,10 @@ restart: | |||
| 959 | case -NFS4ERR_NO_GRACE: | 1041 | case -NFS4ERR_NO_GRACE: |
| 960 | nfs4_state_mark_reclaim_nograce(sp->so_client, state); | 1042 | nfs4_state_mark_reclaim_nograce(sp->so_client, state); |
| 961 | case -NFS4ERR_STALE_CLIENTID: | 1043 | case -NFS4ERR_STALE_CLIENTID: |
| 1044 | case -NFS4ERR_BADSESSION: | ||
| 1045 | case -NFS4ERR_BADSLOT: | ||
| 1046 | case -NFS4ERR_BAD_HIGH_SLOT: | ||
| 1047 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: | ||
| 962 | goto out_err; | 1048 | goto out_err; |
| 963 | } | 1049 | } |
| 964 | nfs4_put_open_state(state); | 1050 | nfs4_put_open_state(state); |
| @@ -1011,6 +1097,14 @@ static void nfs4_state_start_reclaim_reboot(struct nfs_client *clp) | |||
| 1011 | nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_reboot); | 1097 | nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_reboot); |
| 1012 | } | 1098 | } |
| 1013 | 1099 | ||
| 1100 | static void nfs4_reclaim_complete(struct nfs_client *clp, | ||
| 1101 | const struct nfs4_state_recovery_ops *ops) | ||
| 1102 | { | ||
| 1103 | /* Notify the server we're done reclaiming our state */ | ||
| 1104 | if (ops->reclaim_complete) | ||
| 1105 | (void)ops->reclaim_complete(clp); | ||
| 1106 | } | ||
| 1107 | |||
| 1014 | static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp) | 1108 | static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp) |
| 1015 | { | 1109 | { |
| 1016 | struct nfs4_state_owner *sp; | 1110 | struct nfs4_state_owner *sp; |
| @@ -1020,6 +1114,9 @@ static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp) | |||
| 1020 | if (!test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) | 1114 | if (!test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) |
| 1021 | return; | 1115 | return; |
| 1022 | 1116 | ||
| 1117 | nfs4_reclaim_complete(clp, | ||
| 1118 | nfs4_reboot_recovery_ops[clp->cl_minorversion]); | ||
| 1119 | |||
| 1023 | for (pos = rb_first(&clp->cl_state_owners); pos != NULL; pos = rb_next(pos)) { | 1120 | for (pos = rb_first(&clp->cl_state_owners); pos != NULL; pos = rb_next(pos)) { |
| 1024 | sp = rb_entry(pos, struct nfs4_state_owner, so_client_node); | 1121 | sp = rb_entry(pos, struct nfs4_state_owner, so_client_node); |
| 1025 | spin_lock(&sp->so_lock); | 1122 | spin_lock(&sp->so_lock); |
| @@ -1046,25 +1143,25 @@ static void nfs4_state_start_reclaim_nograce(struct nfs_client *clp) | |||
| 1046 | nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_nograce); | 1143 | nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_nograce); |
| 1047 | } | 1144 | } |
| 1048 | 1145 | ||
| 1049 | static void nfs4_state_end_reclaim_nograce(struct nfs_client *clp) | 1146 | static int nfs4_recovery_handle_error(struct nfs_client *clp, int error) |
| 1050 | { | ||
| 1051 | clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state); | ||
| 1052 | } | ||
| 1053 | |||
| 1054 | static void nfs4_recovery_handle_error(struct nfs_client *clp, int error) | ||
| 1055 | { | 1147 | { |
| 1056 | switch (error) { | 1148 | switch (error) { |
| 1057 | case -NFS4ERR_CB_PATH_DOWN: | 1149 | case -NFS4ERR_CB_PATH_DOWN: |
| 1058 | nfs_handle_cb_pathdown(clp); | 1150 | nfs_handle_cb_pathdown(clp); |
| 1059 | break; | 1151 | return 0; |
| 1152 | case -NFS4ERR_NO_GRACE: | ||
| 1153 | nfs4_state_end_reclaim_reboot(clp); | ||
| 1154 | return 0; | ||
| 1060 | case -NFS4ERR_STALE_CLIENTID: | 1155 | case -NFS4ERR_STALE_CLIENTID: |
| 1061 | case -NFS4ERR_LEASE_MOVED: | 1156 | case -NFS4ERR_LEASE_MOVED: |
| 1062 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | 1157 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
| 1158 | nfs4_state_end_reclaim_reboot(clp); | ||
| 1063 | nfs4_state_start_reclaim_reboot(clp); | 1159 | nfs4_state_start_reclaim_reboot(clp); |
| 1064 | break; | 1160 | break; |
| 1065 | case -NFS4ERR_EXPIRED: | 1161 | case -NFS4ERR_EXPIRED: |
| 1066 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | 1162 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
| 1067 | nfs4_state_start_reclaim_nograce(clp); | 1163 | nfs4_state_start_reclaim_nograce(clp); |
| 1164 | break; | ||
| 1068 | case -NFS4ERR_BADSESSION: | 1165 | case -NFS4ERR_BADSESSION: |
| 1069 | case -NFS4ERR_BADSLOT: | 1166 | case -NFS4ERR_BADSLOT: |
| 1070 | case -NFS4ERR_BAD_HIGH_SLOT: | 1167 | case -NFS4ERR_BAD_HIGH_SLOT: |
| @@ -1072,8 +1169,11 @@ static void nfs4_recovery_handle_error(struct nfs_client *clp, int error) | |||
| 1072 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: | 1169 | case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION: |
| 1073 | case -NFS4ERR_SEQ_FALSE_RETRY: | 1170 | case -NFS4ERR_SEQ_FALSE_RETRY: |
| 1074 | case -NFS4ERR_SEQ_MISORDERED: | 1171 | case -NFS4ERR_SEQ_MISORDERED: |
| 1075 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | 1172 | set_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state); |
| 1173 | /* Zero session reset errors */ | ||
| 1174 | return 0; | ||
| 1076 | } | 1175 | } |
| 1176 | return error; | ||
| 1077 | } | 1177 | } |
| 1078 | 1178 | ||
| 1079 | static int nfs4_do_reclaim(struct nfs_client *clp, const struct nfs4_state_recovery_ops *ops) | 1179 | static int nfs4_do_reclaim(struct nfs_client *clp, const struct nfs4_state_recovery_ops *ops) |
| @@ -1093,8 +1193,7 @@ restart: | |||
| 1093 | if (status < 0) { | 1193 | if (status < 0) { |
| 1094 | set_bit(ops->owner_flag_bit, &sp->so_flags); | 1194 | set_bit(ops->owner_flag_bit, &sp->so_flags); |
| 1095 | nfs4_put_state_owner(sp); | 1195 | nfs4_put_state_owner(sp); |
| 1096 | nfs4_recovery_handle_error(clp, status); | 1196 | return nfs4_recovery_handle_error(clp, status); |
| 1097 | return status; | ||
| 1098 | } | 1197 | } |
| 1099 | nfs4_put_state_owner(sp); | 1198 | nfs4_put_state_owner(sp); |
| 1100 | goto restart; | 1199 | goto restart; |
| @@ -1124,8 +1223,7 @@ static int nfs4_check_lease(struct nfs_client *clp) | |||
| 1124 | status = ops->renew_lease(clp, cred); | 1223 | status = ops->renew_lease(clp, cred); |
| 1125 | put_rpccred(cred); | 1224 | put_rpccred(cred); |
| 1126 | out: | 1225 | out: |
| 1127 | nfs4_recovery_handle_error(clp, status); | 1226 | return nfs4_recovery_handle_error(clp, status); |
| 1128 | return status; | ||
| 1129 | } | 1227 | } |
| 1130 | 1228 | ||
| 1131 | static int nfs4_reclaim_lease(struct nfs_client *clp) | 1229 | static int nfs4_reclaim_lease(struct nfs_client *clp) |
| @@ -1151,55 +1249,59 @@ static int nfs4_reclaim_lease(struct nfs_client *clp) | |||
| 1151 | } | 1249 | } |
| 1152 | 1250 | ||
| 1153 | #ifdef CONFIG_NFS_V4_1 | 1251 | #ifdef CONFIG_NFS_V4_1 |
| 1154 | static void nfs4_session_recovery_handle_error(struct nfs_client *clp, int err) | 1252 | void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags) |
| 1155 | { | 1253 | { |
| 1156 | switch (err) { | 1254 | if (!flags) |
| 1157 | case -NFS4ERR_STALE_CLIENTID: | 1255 | return; |
| 1256 | else if (flags & SEQ4_STATUS_RESTART_RECLAIM_NEEDED) { | ||
| 1158 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | 1257 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
| 1159 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | 1258 | nfs4_state_start_reclaim_reboot(clp); |
| 1160 | } | 1259 | nfs4_schedule_state_recovery(clp); |
| 1260 | } else if (flags & (SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED | | ||
| 1261 | SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED | | ||
| 1262 | SEQ4_STATUS_ADMIN_STATE_REVOKED | | ||
| 1263 | SEQ4_STATUS_RECALLABLE_STATE_REVOKED | | ||
| 1264 | SEQ4_STATUS_LEASE_MOVED)) { | ||
| 1265 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | ||
| 1266 | nfs4_state_start_reclaim_nograce(clp); | ||
| 1267 | nfs4_schedule_state_recovery(clp); | ||
| 1268 | } else if (flags & (SEQ4_STATUS_CB_PATH_DOWN | | ||
| 1269 | SEQ4_STATUS_BACKCHANNEL_FAULT | | ||
| 1270 | SEQ4_STATUS_CB_PATH_DOWN_SESSION)) | ||
| 1271 | nfs_expire_all_delegations(clp); | ||
| 1161 | } | 1272 | } |
| 1162 | 1273 | ||
| 1163 | static int nfs4_reset_session(struct nfs_client *clp) | 1274 | static int nfs4_reset_session(struct nfs_client *clp) |
| 1164 | { | 1275 | { |
| 1165 | int status; | 1276 | int status; |
| 1166 | 1277 | ||
| 1278 | nfs4_begin_drain_session(clp); | ||
| 1167 | status = nfs4_proc_destroy_session(clp->cl_session); | 1279 | status = nfs4_proc_destroy_session(clp->cl_session); |
| 1168 | if (status && status != -NFS4ERR_BADSESSION && | 1280 | if (status && status != -NFS4ERR_BADSESSION && |
| 1169 | status != -NFS4ERR_DEADSESSION) { | 1281 | status != -NFS4ERR_DEADSESSION) { |
| 1170 | nfs4_session_recovery_handle_error(clp, status); | 1282 | status = nfs4_recovery_handle_error(clp, status); |
| 1171 | goto out; | 1283 | goto out; |
| 1172 | } | 1284 | } |
| 1173 | 1285 | ||
| 1174 | memset(clp->cl_session->sess_id.data, 0, NFS4_MAX_SESSIONID_LEN); | 1286 | memset(clp->cl_session->sess_id.data, 0, NFS4_MAX_SESSIONID_LEN); |
| 1175 | status = nfs4_proc_create_session(clp, 1); | 1287 | status = nfs4_proc_create_session(clp); |
| 1176 | if (status) | 1288 | if (status) |
| 1177 | nfs4_session_recovery_handle_error(clp, status); | 1289 | status = nfs4_recovery_handle_error(clp, status); |
| 1178 | /* fall through*/ | ||
| 1179 | out: | ||
| 1180 | /* Wake up the next rpc task even on error */ | ||
| 1181 | rpc_wake_up_next(&clp->cl_session->fc_slot_table.slot_tbl_waitq); | ||
| 1182 | return status; | ||
| 1183 | } | ||
| 1184 | 1290 | ||
| 1185 | static int nfs4_initialize_session(struct nfs_client *clp) | 1291 | out: |
| 1186 | { | 1292 | /* |
| 1187 | int status; | 1293 | * Let the state manager reestablish state |
| 1294 | */ | ||
| 1295 | if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) && | ||
| 1296 | status == 0) | ||
| 1297 | nfs41_setup_state_renewal(clp); | ||
| 1188 | 1298 | ||
| 1189 | status = nfs4_proc_create_session(clp, 0); | ||
| 1190 | if (!status) { | ||
| 1191 | nfs_mark_client_ready(clp, NFS_CS_READY); | ||
| 1192 | } else if (status == -NFS4ERR_STALE_CLIENTID) { | ||
| 1193 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | ||
| 1194 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | ||
| 1195 | } else { | ||
| 1196 | nfs_mark_client_ready(clp, status); | ||
| 1197 | } | ||
| 1198 | return status; | 1299 | return status; |
| 1199 | } | 1300 | } |
| 1301 | |||
| 1200 | #else /* CONFIG_NFS_V4_1 */ | 1302 | #else /* CONFIG_NFS_V4_1 */ |
| 1201 | static int nfs4_reset_session(struct nfs_client *clp) { return 0; } | 1303 | static int nfs4_reset_session(struct nfs_client *clp) { return 0; } |
| 1202 | static int nfs4_initialize_session(struct nfs_client *clp) { return 0; } | 1304 | static int nfs4_end_drain_session(struct nfs_client *clp) { return 0; } |
| 1203 | #endif /* CONFIG_NFS_V4_1 */ | 1305 | #endif /* CONFIG_NFS_V4_1 */ |
| 1204 | 1306 | ||
| 1205 | /* Set NFS4CLNT_LEASE_EXPIRED for all v4.0 errors and for recoverable errors | 1307 | /* Set NFS4CLNT_LEASE_EXPIRED for all v4.0 errors and for recoverable errors |
| @@ -1234,7 +1336,8 @@ static void nfs4_state_manager(struct nfs_client *clp) | |||
| 1234 | status = nfs4_reclaim_lease(clp); | 1336 | status = nfs4_reclaim_lease(clp); |
| 1235 | if (status) { | 1337 | if (status) { |
| 1236 | nfs4_set_lease_expired(clp, status); | 1338 | nfs4_set_lease_expired(clp, status); |
| 1237 | if (status == -EAGAIN) | 1339 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, |
| 1340 | &clp->cl_state)) | ||
| 1238 | continue; | 1341 | continue; |
| 1239 | if (clp->cl_cons_state == | 1342 | if (clp->cl_cons_state == |
| 1240 | NFS_CS_SESSION_INITING) | 1343 | NFS_CS_SESSION_INITING) |
| @@ -1242,57 +1345,54 @@ static void nfs4_state_manager(struct nfs_client *clp) | |||
| 1242 | goto out_error; | 1345 | goto out_error; |
| 1243 | } | 1346 | } |
| 1244 | clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state); | 1347 | clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state); |
| 1348 | set_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state); | ||
| 1245 | } | 1349 | } |
| 1246 | 1350 | ||
| 1247 | if (test_and_clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state)) { | 1351 | if (test_and_clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state)) { |
| 1248 | status = nfs4_check_lease(clp); | 1352 | status = nfs4_check_lease(clp); |
| 1249 | if (status != 0) | 1353 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) |
| 1250 | continue; | 1354 | continue; |
| 1355 | if (status < 0 && status != -NFS4ERR_CB_PATH_DOWN) | ||
| 1356 | goto out_error; | ||
| 1251 | } | 1357 | } |
| 1358 | |||
| 1252 | /* Initialize or reset the session */ | 1359 | /* Initialize or reset the session */ |
| 1253 | if (test_and_clear_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state) | 1360 | if (test_and_clear_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state) |
| 1254 | && nfs4_has_session(clp)) { | 1361 | && nfs4_has_session(clp)) { |
| 1255 | if (clp->cl_cons_state == NFS_CS_SESSION_INITING) | 1362 | status = nfs4_reset_session(clp); |
| 1256 | status = nfs4_initialize_session(clp); | 1363 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) |
| 1257 | else | 1364 | continue; |
| 1258 | status = nfs4_reset_session(clp); | 1365 | if (status < 0) |
| 1259 | if (status) { | ||
| 1260 | if (status == -NFS4ERR_STALE_CLIENTID) | ||
| 1261 | continue; | ||
| 1262 | goto out_error; | 1366 | goto out_error; |
| 1263 | } | ||
| 1264 | } | 1367 | } |
| 1368 | |||
| 1265 | /* First recover reboot state... */ | 1369 | /* First recover reboot state... */ |
| 1266 | if (test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) { | 1370 | if (test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) { |
| 1267 | status = nfs4_do_reclaim(clp, | 1371 | status = nfs4_do_reclaim(clp, |
| 1268 | nfs4_reboot_recovery_ops[clp->cl_minorversion]); | 1372 | nfs4_reboot_recovery_ops[clp->cl_minorversion]); |
| 1269 | if (status == -NFS4ERR_STALE_CLIENTID) | 1373 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) || |
| 1270 | continue; | 1374 | test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state)) |
| 1271 | if (test_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state)) | ||
| 1272 | continue; | 1375 | continue; |
| 1273 | nfs4_state_end_reclaim_reboot(clp); | 1376 | nfs4_state_end_reclaim_reboot(clp); |
| 1274 | continue; | 1377 | if (test_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) |
| 1378 | continue; | ||
| 1379 | if (status < 0) | ||
| 1380 | goto out_error; | ||
| 1275 | } | 1381 | } |
| 1276 | 1382 | ||
| 1277 | /* Now recover expired state... */ | 1383 | /* Now recover expired state... */ |
| 1278 | if (test_and_clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) { | 1384 | if (test_and_clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) { |
| 1279 | status = nfs4_do_reclaim(clp, | 1385 | status = nfs4_do_reclaim(clp, |
| 1280 | nfs4_nograce_recovery_ops[clp->cl_minorversion]); | 1386 | nfs4_nograce_recovery_ops[clp->cl_minorversion]); |
| 1281 | if (status < 0) { | 1387 | if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) || |
| 1282 | set_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state); | 1388 | test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state) || |
| 1283 | if (status == -NFS4ERR_STALE_CLIENTID) | 1389 | test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) |
| 1284 | continue; | 1390 | continue; |
| 1285 | if (status == -NFS4ERR_EXPIRED) | 1391 | if (status < 0) |
| 1286 | continue; | ||
| 1287 | if (test_bit(NFS4CLNT_SESSION_SETUP, | ||
| 1288 | &clp->cl_state)) | ||
| 1289 | continue; | ||
| 1290 | goto out_error; | 1392 | goto out_error; |
| 1291 | } else | ||
| 1292 | nfs4_state_end_reclaim_nograce(clp); | ||
| 1293 | continue; | ||
| 1294 | } | 1393 | } |
| 1295 | 1394 | ||
| 1395 | nfs4_end_drain_session(clp); | ||
| 1296 | if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) { | 1396 | if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) { |
| 1297 | nfs_client_return_marked_delegations(clp); | 1397 | nfs_client_return_marked_delegations(clp); |
| 1298 | continue; | 1398 | continue; |
| @@ -1309,8 +1409,7 @@ static void nfs4_state_manager(struct nfs_client *clp) | |||
| 1309 | out_error: | 1409 | out_error: |
| 1310 | printk(KERN_WARNING "Error: state manager failed on NFSv4 server %s" | 1410 | printk(KERN_WARNING "Error: state manager failed on NFSv4 server %s" |
| 1311 | " with error %d\n", clp->cl_hostname, -status); | 1411 | " with error %d\n", clp->cl_hostname, -status); |
| 1312 | if (test_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) | 1412 | nfs4_end_drain_session(clp); |
| 1313 | nfs4_state_end_reclaim_reboot(clp); | ||
| 1314 | nfs4_clear_state_manager_bit(clp); | 1413 | nfs4_clear_state_manager_bit(clp); |
| 1315 | } | 1414 | } |
| 1316 | 1415 | ||
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 20b4e30e6c82..e437fd6a819f 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
| @@ -46,11 +46,13 @@ | |||
| 46 | #include <linux/proc_fs.h> | 46 | #include <linux/proc_fs.h> |
| 47 | #include <linux/kdev_t.h> | 47 | #include <linux/kdev_t.h> |
| 48 | #include <linux/sunrpc/clnt.h> | 48 | #include <linux/sunrpc/clnt.h> |
| 49 | #include <linux/sunrpc/msg_prot.h> | ||
| 49 | #include <linux/nfs.h> | 50 | #include <linux/nfs.h> |
| 50 | #include <linux/nfs4.h> | 51 | #include <linux/nfs4.h> |
| 51 | #include <linux/nfs_fs.h> | 52 | #include <linux/nfs_fs.h> |
| 52 | #include <linux/nfs_idmap.h> | 53 | #include <linux/nfs_idmap.h> |
| 53 | #include "nfs4_fs.h" | 54 | #include "nfs4_fs.h" |
| 55 | #include "internal.h" | ||
| 54 | 56 | ||
| 55 | #define NFSDBG_FACILITY NFSDBG_XDR | 57 | #define NFSDBG_FACILITY NFSDBG_XDR |
| 56 | 58 | ||
| @@ -134,7 +136,7 @@ static int nfs4_stat_to_errno(int); | |||
| 134 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) | 136 | #define decode_lookup_maxsz (op_decode_hdr_maxsz) |
| 135 | #define encode_share_access_maxsz \ | 137 | #define encode_share_access_maxsz \ |
| 136 | (2) | 138 | (2) |
| 137 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz) | 139 | #define encode_createmode_maxsz (1 + encode_attrs_maxsz + encode_verifier_maxsz) |
| 138 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) | 140 | #define encode_opentype_maxsz (1 + encode_createmode_maxsz) |
| 139 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) | 141 | #define encode_claim_null_maxsz (1 + nfs4_name_maxsz) |
| 140 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ | 142 | #define encode_open_maxsz (op_encode_hdr_maxsz + \ |
| @@ -299,6 +301,8 @@ static int nfs4_stat_to_errno(int); | |||
| 299 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) | 301 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 4) |
| 300 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ | 302 | #define decode_sequence_maxsz (op_decode_hdr_maxsz + \ |
| 301 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) | 303 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + 5) |
| 304 | #define encode_reclaim_complete_maxsz (op_encode_hdr_maxsz + 4) | ||
| 305 | #define decode_reclaim_complete_maxsz (op_decode_hdr_maxsz + 4) | ||
| 302 | #else /* CONFIG_NFS_V4_1 */ | 306 | #else /* CONFIG_NFS_V4_1 */ |
| 303 | #define encode_sequence_maxsz 0 | 307 | #define encode_sequence_maxsz 0 |
| 304 | #define decode_sequence_maxsz 0 | 308 | #define decode_sequence_maxsz 0 |
| @@ -676,6 +680,25 @@ static int nfs4_stat_to_errno(int); | |||
| 676 | decode_sequence_maxsz + \ | 680 | decode_sequence_maxsz + \ |
| 677 | decode_putrootfh_maxsz + \ | 681 | decode_putrootfh_maxsz + \ |
| 678 | decode_fsinfo_maxsz) | 682 | decode_fsinfo_maxsz) |
| 683 | #define NFS4_enc_reclaim_complete_sz (compound_encode_hdr_maxsz + \ | ||
| 684 | encode_sequence_maxsz + \ | ||
| 685 | encode_reclaim_complete_maxsz) | ||
| 686 | #define NFS4_dec_reclaim_complete_sz (compound_decode_hdr_maxsz + \ | ||
| 687 | decode_sequence_maxsz + \ | ||
| 688 | decode_reclaim_complete_maxsz) | ||
| 689 | |||
| 690 | const u32 nfs41_maxwrite_overhead = ((RPC_MAX_HEADER_WITH_AUTH + | ||
| 691 | compound_encode_hdr_maxsz + | ||
| 692 | encode_sequence_maxsz + | ||
| 693 | encode_putfh_maxsz + | ||
| 694 | encode_getattr_maxsz) * | ||
| 695 | XDR_UNIT); | ||
| 696 | |||
| 697 | const u32 nfs41_maxread_overhead = ((RPC_MAX_HEADER_WITH_AUTH + | ||
| 698 | compound_decode_hdr_maxsz + | ||
| 699 | decode_sequence_maxsz + | ||
| 700 | decode_putfh_maxsz) * | ||
| 701 | XDR_UNIT); | ||
| 679 | #endif /* CONFIG_NFS_V4_1 */ | 702 | #endif /* CONFIG_NFS_V4_1 */ |
| 680 | 703 | ||
| 681 | static const umode_t nfs_type2fmt[] = { | 704 | static const umode_t nfs_type2fmt[] = { |
| @@ -1140,6 +1163,7 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena | |||
| 1140 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) | 1163 | static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) |
| 1141 | { | 1164 | { |
| 1142 | __be32 *p; | 1165 | __be32 *p; |
| 1166 | struct nfs_client *clp; | ||
| 1143 | 1167 | ||
| 1144 | p = reserve_space(xdr, 4); | 1168 | p = reserve_space(xdr, 4); |
| 1145 | switch(arg->open_flags & O_EXCL) { | 1169 | switch(arg->open_flags & O_EXCL) { |
| @@ -1148,8 +1172,23 @@ static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_op | |||
| 1148 | encode_attrs(xdr, arg->u.attrs, arg->server); | 1172 | encode_attrs(xdr, arg->u.attrs, arg->server); |
| 1149 | break; | 1173 | break; |
| 1150 | default: | 1174 | default: |
| 1151 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); | 1175 | clp = arg->server->nfs_client; |
| 1152 | encode_nfs4_verifier(xdr, &arg->u.verifier); | 1176 | if (clp->cl_minorversion > 0) { |
| 1177 | if (nfs4_has_persistent_session(clp)) { | ||
| 1178 | *p = cpu_to_be32(NFS4_CREATE_GUARDED); | ||
| 1179 | encode_attrs(xdr, arg->u.attrs, arg->server); | ||
| 1180 | } else { | ||
| 1181 | struct iattr dummy; | ||
| 1182 | |||
| 1183 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE4_1); | ||
| 1184 | encode_nfs4_verifier(xdr, &arg->u.verifier); | ||
| 1185 | dummy.ia_valid = 0; | ||
| 1186 | encode_attrs(xdr, &dummy, arg->server); | ||
| 1187 | } | ||
| 1188 | } else { | ||
| 1189 | *p = cpu_to_be32(NFS4_CREATE_EXCLUSIVE); | ||
| 1190 | encode_nfs4_verifier(xdr, &arg->u.verifier); | ||
| 1191 | } | ||
| 1153 | } | 1192 | } |
| 1154 | } | 1193 | } |
| 1155 | 1194 | ||
| @@ -1592,6 +1631,19 @@ static void encode_destroy_session(struct xdr_stream *xdr, | |||
| 1592 | hdr->nops++; | 1631 | hdr->nops++; |
| 1593 | hdr->replen += decode_destroy_session_maxsz; | 1632 | hdr->replen += decode_destroy_session_maxsz; |
| 1594 | } | 1633 | } |
| 1634 | |||
| 1635 | static void encode_reclaim_complete(struct xdr_stream *xdr, | ||
| 1636 | struct nfs41_reclaim_complete_args *args, | ||
| 1637 | struct compound_hdr *hdr) | ||
| 1638 | { | ||
| 1639 | __be32 *p; | ||
| 1640 | |||
| 1641 | p = reserve_space(xdr, 8); | ||
| 1642 | *p++ = cpu_to_be32(OP_RECLAIM_COMPLETE); | ||
| 1643 | *p++ = cpu_to_be32(args->one_fs); | ||
| 1644 | hdr->nops++; | ||
| 1645 | hdr->replen += decode_reclaim_complete_maxsz; | ||
| 1646 | } | ||
| 1595 | #endif /* CONFIG_NFS_V4_1 */ | 1647 | #endif /* CONFIG_NFS_V4_1 */ |
| 1596 | 1648 | ||
| 1597 | static void encode_sequence(struct xdr_stream *xdr, | 1649 | static void encode_sequence(struct xdr_stream *xdr, |
| @@ -2096,7 +2148,7 @@ nfs4_xdr_enc_getacl(struct rpc_rqst *req, __be32 *p, | |||
| 2096 | encode_compound_hdr(&xdr, req, &hdr); | 2148 | encode_compound_hdr(&xdr, req, &hdr); |
| 2097 | encode_sequence(&xdr, &args->seq_args, &hdr); | 2149 | encode_sequence(&xdr, &args->seq_args, &hdr); |
| 2098 | encode_putfh(&xdr, args->fh, &hdr); | 2150 | encode_putfh(&xdr, args->fh, &hdr); |
| 2099 | replen = hdr.replen + nfs4_fattr_bitmap_maxsz + 1; | 2151 | replen = hdr.replen + op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz + 1; |
| 2100 | encode_getattr_two(&xdr, FATTR4_WORD0_ACL, 0, &hdr); | 2152 | encode_getattr_two(&xdr, FATTR4_WORD0_ACL, 0, &hdr); |
| 2101 | 2153 | ||
| 2102 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, | 2154 | xdr_inline_pages(&req->rq_rcv_buf, replen << 2, |
| @@ -2420,6 +2472,26 @@ static int nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, uint32_t *p, | |||
| 2420 | encode_nops(&hdr); | 2472 | encode_nops(&hdr); |
| 2421 | return 0; | 2473 | return 0; |
| 2422 | } | 2474 | } |
| 2475 | |||
| 2476 | /* | ||
| 2477 | * a RECLAIM_COMPLETE request | ||
| 2478 | */ | ||
| 2479 | static int nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, uint32_t *p, | ||
| 2480 | struct nfs41_reclaim_complete_args *args) | ||
| 2481 | { | ||
| 2482 | struct xdr_stream xdr; | ||
| 2483 | struct compound_hdr hdr = { | ||
| 2484 | .minorversion = nfs4_xdr_minorversion(&args->seq_args) | ||
| 2485 | }; | ||
| 2486 | |||
| 2487 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | ||
| 2488 | encode_compound_hdr(&xdr, req, &hdr); | ||
| 2489 | encode_sequence(&xdr, &args->seq_args, &hdr); | ||
| 2490 | encode_reclaim_complete(&xdr, args, &hdr); | ||
| 2491 | encode_nops(&hdr); | ||
| 2492 | return 0; | ||
| 2493 | } | ||
| 2494 | |||
| 2423 | #endif /* CONFIG_NFS_V4_1 */ | 2495 | #endif /* CONFIG_NFS_V4_1 */ |
| 2424 | 2496 | ||
| 2425 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) | 2497 | static void print_overflow_msg(const char *func, const struct xdr_stream *xdr) |
| @@ -4528,6 +4600,11 @@ static int decode_destroy_session(struct xdr_stream *xdr, void *dummy) | |||
| 4528 | { | 4600 | { |
| 4529 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); | 4601 | return decode_op_hdr(xdr, OP_DESTROY_SESSION); |
| 4530 | } | 4602 | } |
| 4603 | |||
| 4604 | static int decode_reclaim_complete(struct xdr_stream *xdr, void *dummy) | ||
| 4605 | { | ||
| 4606 | return decode_op_hdr(xdr, OP_RECLAIM_COMPLETE); | ||
| 4607 | } | ||
| 4531 | #endif /* CONFIG_NFS_V4_1 */ | 4608 | #endif /* CONFIG_NFS_V4_1 */ |
| 4532 | 4609 | ||
| 4533 | static int decode_sequence(struct xdr_stream *xdr, | 4610 | static int decode_sequence(struct xdr_stream *xdr, |
| @@ -4583,8 +4660,8 @@ static int decode_sequence(struct xdr_stream *xdr, | |||
| 4583 | dummy = be32_to_cpup(p++); | 4660 | dummy = be32_to_cpup(p++); |
| 4584 | /* target highest slot id - currently not processed */ | 4661 | /* target highest slot id - currently not processed */ |
| 4585 | dummy = be32_to_cpup(p++); | 4662 | dummy = be32_to_cpup(p++); |
| 4586 | /* result flags - currently not processed */ | 4663 | /* result flags */ |
| 4587 | dummy = be32_to_cpup(p); | 4664 | res->sr_status_flags = be32_to_cpup(p); |
| 4588 | status = 0; | 4665 | status = 0; |
| 4589 | out_err: | 4666 | out_err: |
| 4590 | res->sr_status = status; | 4667 | res->sr_status = status; |
| @@ -5309,7 +5386,7 @@ out: | |||
| 5309 | } | 5386 | } |
| 5310 | 5387 | ||
| 5311 | /* | 5388 | /* |
| 5312 | * FSINFO request | 5389 | * Decode FSINFO response |
| 5313 | */ | 5390 | */ |
| 5314 | static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p, | 5391 | static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p, |
| 5315 | struct nfs4_fsinfo_res *res) | 5392 | struct nfs4_fsinfo_res *res) |
| @@ -5330,7 +5407,7 @@ static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p, | |||
| 5330 | } | 5407 | } |
| 5331 | 5408 | ||
| 5332 | /* | 5409 | /* |
| 5333 | * PATHCONF request | 5410 | * Decode PATHCONF response |
| 5334 | */ | 5411 | */ |
| 5335 | static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, __be32 *p, | 5412 | static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, __be32 *p, |
| 5336 | struct nfs4_pathconf_res *res) | 5413 | struct nfs4_pathconf_res *res) |
| @@ -5351,7 +5428,7 @@ static int nfs4_xdr_dec_pathconf(struct rpc_rqst *req, __be32 *p, | |||
| 5351 | } | 5428 | } |
| 5352 | 5429 | ||
| 5353 | /* | 5430 | /* |
| 5354 | * STATFS request | 5431 | * Decode STATFS response |
| 5355 | */ | 5432 | */ |
| 5356 | static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, __be32 *p, | 5433 | static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, __be32 *p, |
| 5357 | struct nfs4_statfs_res *res) | 5434 | struct nfs4_statfs_res *res) |
| @@ -5372,7 +5449,7 @@ static int nfs4_xdr_dec_statfs(struct rpc_rqst *req, __be32 *p, | |||
| 5372 | } | 5449 | } |
| 5373 | 5450 | ||
| 5374 | /* | 5451 | /* |
| 5375 | * GETATTR_BITMAP request | 5452 | * Decode GETATTR_BITMAP response |
| 5376 | */ | 5453 | */ |
| 5377 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, __be32 *p, struct nfs4_server_caps_res *res) | 5454 | static int nfs4_xdr_dec_server_caps(struct rpc_rqst *req, __be32 *p, struct nfs4_server_caps_res *res) |
| 5378 | { | 5455 | { |
| @@ -5411,7 +5488,7 @@ static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, __be32 *p, void *dummy) | |||
| 5411 | } | 5488 | } |
| 5412 | 5489 | ||
| 5413 | /* | 5490 | /* |
| 5414 | * a SETCLIENTID request | 5491 | * Decode SETCLIENTID response |
| 5415 | */ | 5492 | */ |
| 5416 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, | 5493 | static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, |
| 5417 | struct nfs_client *clp) | 5494 | struct nfs_client *clp) |
| @@ -5428,7 +5505,7 @@ static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p, | |||
| 5428 | } | 5505 | } |
| 5429 | 5506 | ||
| 5430 | /* | 5507 | /* |
| 5431 | * a SETCLIENTID_CONFIRM request | 5508 | * Decode SETCLIENTID_CONFIRM response |
| 5432 | */ | 5509 | */ |
| 5433 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo) | 5510 | static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *fsinfo) |
| 5434 | { | 5511 | { |
| @@ -5448,7 +5525,7 @@ static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, str | |||
| 5448 | } | 5525 | } |
| 5449 | 5526 | ||
| 5450 | /* | 5527 | /* |
| 5451 | * DELEGRETURN request | 5528 | * Decode DELEGRETURN response |
| 5452 | */ | 5529 | */ |
| 5453 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_delegreturnres *res) | 5530 | static int nfs4_xdr_dec_delegreturn(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_delegreturnres *res) |
| 5454 | { | 5531 | { |
| @@ -5474,7 +5551,7 @@ out: | |||
| 5474 | } | 5551 | } |
| 5475 | 5552 | ||
| 5476 | /* | 5553 | /* |
| 5477 | * FS_LOCATIONS request | 5554 | * Decode FS_LOCATIONS response |
| 5478 | */ | 5555 | */ |
| 5479 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, __be32 *p, | 5556 | static int nfs4_xdr_dec_fs_locations(struct rpc_rqst *req, __be32 *p, |
| 5480 | struct nfs4_fs_locations_res *res) | 5557 | struct nfs4_fs_locations_res *res) |
| @@ -5504,7 +5581,7 @@ out: | |||
| 5504 | 5581 | ||
| 5505 | #if defined(CONFIG_NFS_V4_1) | 5582 | #if defined(CONFIG_NFS_V4_1) |
| 5506 | /* | 5583 | /* |
| 5507 | * EXCHANGE_ID request | 5584 | * Decode EXCHANGE_ID response |
| 5508 | */ | 5585 | */ |
| 5509 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, uint32_t *p, | 5586 | static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, uint32_t *p, |
| 5510 | void *res) | 5587 | void *res) |
| @@ -5521,7 +5598,7 @@ static int nfs4_xdr_dec_exchange_id(struct rpc_rqst *rqstp, uint32_t *p, | |||
| 5521 | } | 5598 | } |
| 5522 | 5599 | ||
| 5523 | /* | 5600 | /* |
| 5524 | * a CREATE_SESSION request | 5601 | * Decode CREATE_SESSION response |
| 5525 | */ | 5602 | */ |
| 5526 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, uint32_t *p, | 5603 | static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, uint32_t *p, |
| 5527 | struct nfs41_create_session_res *res) | 5604 | struct nfs41_create_session_res *res) |
| @@ -5538,7 +5615,7 @@ static int nfs4_xdr_dec_create_session(struct rpc_rqst *rqstp, uint32_t *p, | |||
| 5538 | } | 5615 | } |
| 5539 | 5616 | ||
| 5540 | /* | 5617 | /* |
| 5541 | * a DESTROY_SESSION request | 5618 | * Decode DESTROY_SESSION response |
| 5542 | */ | 5619 | */ |
| 5543 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, uint32_t *p, | 5620 | static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, uint32_t *p, |
| 5544 | void *dummy) | 5621 | void *dummy) |
| @@ -5555,7 +5632,7 @@ static int nfs4_xdr_dec_destroy_session(struct rpc_rqst *rqstp, uint32_t *p, | |||
| 5555 | } | 5632 | } |
| 5556 | 5633 | ||
| 5557 | /* | 5634 | /* |
| 5558 | * a SEQUENCE request | 5635 | * Decode SEQUENCE response |
| 5559 | */ | 5636 | */ |
| 5560 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, uint32_t *p, | 5637 | static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, uint32_t *p, |
| 5561 | struct nfs4_sequence_res *res) | 5638 | struct nfs4_sequence_res *res) |
| @@ -5572,7 +5649,7 @@ static int nfs4_xdr_dec_sequence(struct rpc_rqst *rqstp, uint32_t *p, | |||
| 5572 | } | 5649 | } |
| 5573 | 5650 | ||
| 5574 | /* | 5651 | /* |
| 5575 | * a GET_LEASE_TIME request | 5652 | * Decode GET_LEASE_TIME response |
| 5576 | */ | 5653 | */ |
| 5577 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, uint32_t *p, | 5654 | static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, uint32_t *p, |
| 5578 | struct nfs4_get_lease_time_res *res) | 5655 | struct nfs4_get_lease_time_res *res) |
| @@ -5591,6 +5668,25 @@ static int nfs4_xdr_dec_get_lease_time(struct rpc_rqst *rqstp, uint32_t *p, | |||
| 5591 | status = decode_fsinfo(&xdr, res->lr_fsinfo); | 5668 | status = decode_fsinfo(&xdr, res->lr_fsinfo); |
| 5592 | return status; | 5669 | return status; |
| 5593 | } | 5670 | } |
| 5671 | |||
| 5672 | /* | ||
| 5673 | * Decode RECLAIM_COMPLETE response | ||
| 5674 | */ | ||
| 5675 | static int nfs4_xdr_dec_reclaim_complete(struct rpc_rqst *rqstp, uint32_t *p, | ||
| 5676 | struct nfs41_reclaim_complete_res *res) | ||
| 5677 | { | ||
| 5678 | struct xdr_stream xdr; | ||
| 5679 | struct compound_hdr hdr; | ||
| 5680 | int status; | ||
| 5681 | |||
| 5682 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | ||
| 5683 | status = decode_compound_hdr(&xdr, &hdr); | ||
| 5684 | if (!status) | ||
| 5685 | status = decode_sequence(&xdr, &res->seq_res, rqstp); | ||
| 5686 | if (!status) | ||
| 5687 | status = decode_reclaim_complete(&xdr, (void *)NULL); | ||
| 5688 | return status; | ||
| 5689 | } | ||
| 5594 | #endif /* CONFIG_NFS_V4_1 */ | 5690 | #endif /* CONFIG_NFS_V4_1 */ |
| 5595 | 5691 | ||
| 5596 | __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus) | 5692 | __be32 *nfs4_decode_dirent(__be32 *p, struct nfs_entry *entry, int plus) |
| @@ -5767,6 +5863,7 @@ struct rpc_procinfo nfs4_procedures[] = { | |||
| 5767 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), | 5863 | PROC(DESTROY_SESSION, enc_destroy_session, dec_destroy_session), |
| 5768 | PROC(SEQUENCE, enc_sequence, dec_sequence), | 5864 | PROC(SEQUENCE, enc_sequence, dec_sequence), |
| 5769 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), | 5865 | PROC(GET_LEASE_TIME, enc_get_lease_time, dec_get_lease_time), |
| 5866 | PROC(RECLAIM_COMPLETE, enc_reclaim_complete, dec_reclaim_complete), | ||
| 5770 | #endif /* CONFIG_NFS_V4_1 */ | 5867 | #endif /* CONFIG_NFS_V4_1 */ |
| 5771 | }; | 5868 | }; |
| 5772 | 5869 | ||
diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 12c9e66d3f1d..db9b360ae19d 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c | |||
| @@ -356,25 +356,19 @@ static void nfs_readpage_retry(struct rpc_task *task, struct nfs_read_data *data | |||
| 356 | struct nfs_readres *resp = &data->res; | 356 | struct nfs_readres *resp = &data->res; |
| 357 | 357 | ||
| 358 | if (resp->eof || resp->count == argp->count) | 358 | if (resp->eof || resp->count == argp->count) |
| 359 | goto out; | 359 | return; |
| 360 | 360 | ||
| 361 | /* This is a short read! */ | 361 | /* This is a short read! */ |
| 362 | nfs_inc_stats(data->inode, NFSIOS_SHORTREAD); | 362 | nfs_inc_stats(data->inode, NFSIOS_SHORTREAD); |
| 363 | /* Has the server at least made some progress? */ | 363 | /* Has the server at least made some progress? */ |
| 364 | if (resp->count == 0) | 364 | if (resp->count == 0) |
| 365 | goto out; | 365 | return; |
| 366 | 366 | ||
| 367 | /* Yes, so retry the read at the end of the data */ | 367 | /* Yes, so retry the read at the end of the data */ |
| 368 | argp->offset += resp->count; | 368 | argp->offset += resp->count; |
| 369 | argp->pgbase += resp->count; | 369 | argp->pgbase += resp->count; |
| 370 | argp->count -= resp->count; | 370 | argp->count -= resp->count; |
| 371 | nfs4_restart_rpc(task, NFS_SERVER(data->inode)->nfs_client); | 371 | nfs_restart_rpc(task, NFS_SERVER(data->inode)->nfs_client); |
| 372 | return; | ||
| 373 | out: | ||
| 374 | nfs4_sequence_free_slot(NFS_SERVER(data->inode)->nfs_client, | ||
| 375 | &data->res.seq_res); | ||
| 376 | return; | ||
| 377 | |||
| 378 | } | 372 | } |
| 379 | 373 | ||
| 380 | /* | 374 | /* |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 90be551b80c1..ce907efc5508 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
| @@ -175,14 +175,16 @@ static const match_table_t nfs_mount_option_tokens = { | |||
| 175 | }; | 175 | }; |
| 176 | 176 | ||
| 177 | enum { | 177 | enum { |
| 178 | Opt_xprt_udp, Opt_xprt_tcp, Opt_xprt_rdma, | 178 | Opt_xprt_udp, Opt_xprt_udp6, Opt_xprt_tcp, Opt_xprt_tcp6, Opt_xprt_rdma, |
| 179 | 179 | ||
| 180 | Opt_xprt_err | 180 | Opt_xprt_err |
| 181 | }; | 181 | }; |
| 182 | 182 | ||
| 183 | static const match_table_t nfs_xprt_protocol_tokens = { | 183 | static const match_table_t nfs_xprt_protocol_tokens = { |
| 184 | { Opt_xprt_udp, "udp" }, | 184 | { Opt_xprt_udp, "udp" }, |
| 185 | { Opt_xprt_udp6, "udp6" }, | ||
| 185 | { Opt_xprt_tcp, "tcp" }, | 186 | { Opt_xprt_tcp, "tcp" }, |
| 187 | { Opt_xprt_tcp6, "tcp6" }, | ||
| 186 | { Opt_xprt_rdma, "rdma" }, | 188 | { Opt_xprt_rdma, "rdma" }, |
| 187 | 189 | ||
| 188 | { Opt_xprt_err, NULL } | 190 | { Opt_xprt_err, NULL } |
| @@ -492,6 +494,45 @@ static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour) | |||
| 492 | return sec_flavours[i].str; | 494 | return sec_flavours[i].str; |
| 493 | } | 495 | } |
| 494 | 496 | ||
| 497 | static void nfs_show_mountd_netid(struct seq_file *m, struct nfs_server *nfss, | ||
| 498 | int showdefaults) | ||
| 499 | { | ||
| 500 | struct sockaddr *sap = (struct sockaddr *) &nfss->mountd_address; | ||
| 501 | |||
| 502 | seq_printf(m, ",mountproto="); | ||
| 503 | switch (sap->sa_family) { | ||
| 504 | case AF_INET: | ||
| 505 | switch (nfss->mountd_protocol) { | ||
| 506 | case IPPROTO_UDP: | ||
| 507 | seq_printf(m, RPCBIND_NETID_UDP); | ||
| 508 | break; | ||
| 509 | case IPPROTO_TCP: | ||
| 510 | seq_printf(m, RPCBIND_NETID_TCP); | ||
| 511 | break; | ||
| 512 | default: | ||
| 513 | if (showdefaults) | ||
| 514 | seq_printf(m, "auto"); | ||
| 515 | } | ||
| 516 | break; | ||
| 517 | case AF_INET6: | ||
| 518 | switch (nfss->mountd_protocol) { | ||
| 519 | case IPPROTO_UDP: | ||
| 520 | seq_printf(m, RPCBIND_NETID_UDP6); | ||
| 521 | break; | ||
| 522 | case IPPROTO_TCP: | ||
| 523 | seq_printf(m, RPCBIND_NETID_TCP6); | ||
| 524 | break; | ||
| 525 | default: | ||
| 526 | if (showdefaults) | ||
| 527 | seq_printf(m, "auto"); | ||
| 528 | } | ||
| 529 | break; | ||
| 530 | default: | ||
| 531 | if (showdefaults) | ||
| 532 | seq_printf(m, "auto"); | ||
| 533 | } | ||
| 534 | } | ||
| 535 | |||
| 495 | static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss, | 536 | static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss, |
| 496 | int showdefaults) | 537 | int showdefaults) |
| 497 | { | 538 | { |
| @@ -505,7 +546,7 @@ static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss, | |||
| 505 | } | 546 | } |
| 506 | case AF_INET6: { | 547 | case AF_INET6: { |
| 507 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; | 548 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; |
| 508 | seq_printf(m, ",mountaddr=%pI6", &sin6->sin6_addr); | 549 | seq_printf(m, ",mountaddr=%pI6c", &sin6->sin6_addr); |
| 509 | break; | 550 | break; |
| 510 | } | 551 | } |
| 511 | default: | 552 | default: |
| @@ -518,17 +559,7 @@ static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss, | |||
| 518 | if (nfss->mountd_port || showdefaults) | 559 | if (nfss->mountd_port || showdefaults) |
| 519 | seq_printf(m, ",mountport=%u", nfss->mountd_port); | 560 | seq_printf(m, ",mountport=%u", nfss->mountd_port); |
| 520 | 561 | ||
| 521 | switch (nfss->mountd_protocol) { | 562 | nfs_show_mountd_netid(m, nfss, showdefaults); |
| 522 | case IPPROTO_UDP: | ||
| 523 | seq_printf(m, ",mountproto=udp"); | ||
| 524 | break; | ||
| 525 | case IPPROTO_TCP: | ||
| 526 | seq_printf(m, ",mountproto=tcp"); | ||
| 527 | break; | ||
| 528 | default: | ||
| 529 | if (showdefaults) | ||
| 530 | seq_printf(m, ",mountproto=auto"); | ||
| 531 | } | ||
| 532 | } | 563 | } |
| 533 | 564 | ||
| 534 | /* | 565 | /* |
| @@ -578,7 +609,7 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, | |||
| 578 | seq_puts(m, nfs_infop->nostr); | 609 | seq_puts(m, nfs_infop->nostr); |
| 579 | } | 610 | } |
| 580 | seq_printf(m, ",proto=%s", | 611 | seq_printf(m, ",proto=%s", |
| 581 | rpc_peeraddr2str(nfss->client, RPC_DISPLAY_PROTO)); | 612 | rpc_peeraddr2str(nfss->client, RPC_DISPLAY_NETID)); |
| 582 | if (version == 4) { | 613 | if (version == 4) { |
| 583 | if (nfss->port != NFS_PORT) | 614 | if (nfss->port != NFS_PORT) |
| 584 | seq_printf(m, ",port=%u", nfss->port); | 615 | seq_printf(m, ",port=%u", nfss->port); |
| @@ -714,8 +745,6 @@ static void nfs_umount_begin(struct super_block *sb) | |||
| 714 | struct nfs_server *server; | 745 | struct nfs_server *server; |
| 715 | struct rpc_clnt *rpc; | 746 | struct rpc_clnt *rpc; |
| 716 | 747 | ||
| 717 | lock_kernel(); | ||
| 718 | |||
| 719 | server = NFS_SB(sb); | 748 | server = NFS_SB(sb); |
| 720 | /* -EIO all pending I/O */ | 749 | /* -EIO all pending I/O */ |
| 721 | rpc = server->client_acl; | 750 | rpc = server->client_acl; |
| @@ -724,8 +753,6 @@ static void nfs_umount_begin(struct super_block *sb) | |||
| 724 | rpc = server->client; | 753 | rpc = server->client; |
| 725 | if (!IS_ERR(rpc)) | 754 | if (!IS_ERR(rpc)) |
| 726 | rpc_killall_tasks(rpc); | 755 | rpc_killall_tasks(rpc); |
| 727 | |||
| 728 | unlock_kernel(); | ||
| 729 | } | 756 | } |
| 730 | 757 | ||
| 731 | static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(unsigned int version) | 758 | static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(unsigned int version) |
| @@ -734,8 +761,6 @@ static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(unsigned int ve | |||
| 734 | 761 | ||
| 735 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 762 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
| 736 | if (data) { | 763 | if (data) { |
| 737 | data->rsize = NFS_MAX_FILE_IO_SIZE; | ||
| 738 | data->wsize = NFS_MAX_FILE_IO_SIZE; | ||
| 739 | data->acregmin = NFS_DEF_ACREGMIN; | 764 | data->acregmin = NFS_DEF_ACREGMIN; |
| 740 | data->acregmax = NFS_DEF_ACREGMAX; | 765 | data->acregmax = NFS_DEF_ACREGMAX; |
| 741 | data->acdirmin = NFS_DEF_ACDIRMIN; | 766 | data->acdirmin = NFS_DEF_ACDIRMIN; |
| @@ -887,6 +912,8 @@ static int nfs_parse_mount_options(char *raw, | |||
| 887 | { | 912 | { |
| 888 | char *p, *string, *secdata; | 913 | char *p, *string, *secdata; |
| 889 | int rc, sloppy = 0, invalid_option = 0; | 914 | int rc, sloppy = 0, invalid_option = 0; |
| 915 | unsigned short protofamily = AF_UNSPEC; | ||
| 916 | unsigned short mountfamily = AF_UNSPEC; | ||
| 890 | 917 | ||
| 891 | if (!raw) { | 918 | if (!raw) { |
| 892 | dfprintk(MOUNT, "NFS: mount options string was NULL.\n"); | 919 | dfprintk(MOUNT, "NFS: mount options string was NULL.\n"); |
| @@ -1232,12 +1259,17 @@ static int nfs_parse_mount_options(char *raw, | |||
| 1232 | token = match_token(string, | 1259 | token = match_token(string, |
| 1233 | nfs_xprt_protocol_tokens, args); | 1260 | nfs_xprt_protocol_tokens, args); |
| 1234 | 1261 | ||
| 1262 | protofamily = AF_INET; | ||
| 1235 | switch (token) { | 1263 | switch (token) { |
| 1264 | case Opt_xprt_udp6: | ||
| 1265 | protofamily = AF_INET6; | ||
| 1236 | case Opt_xprt_udp: | 1266 | case Opt_xprt_udp: |
| 1237 | mnt->flags &= ~NFS_MOUNT_TCP; | 1267 | mnt->flags &= ~NFS_MOUNT_TCP; |
| 1238 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; | 1268 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; |
| 1239 | kfree(string); | 1269 | kfree(string); |
| 1240 | break; | 1270 | break; |
| 1271 | case Opt_xprt_tcp6: | ||
| 1272 | protofamily = AF_INET6; | ||
| 1241 | case Opt_xprt_tcp: | 1273 | case Opt_xprt_tcp: |
| 1242 | mnt->flags |= NFS_MOUNT_TCP; | 1274 | mnt->flags |= NFS_MOUNT_TCP; |
| 1243 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; | 1275 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
| @@ -1265,10 +1297,15 @@ static int nfs_parse_mount_options(char *raw, | |||
| 1265 | nfs_xprt_protocol_tokens, args); | 1297 | nfs_xprt_protocol_tokens, args); |
| 1266 | kfree(string); | 1298 | kfree(string); |
| 1267 | 1299 | ||
| 1300 | mountfamily = AF_INET; | ||
| 1268 | switch (token) { | 1301 | switch (token) { |
| 1302 | case Opt_xprt_udp6: | ||
| 1303 | mountfamily = AF_INET6; | ||
| 1269 | case Opt_xprt_udp: | 1304 | case Opt_xprt_udp: |
| 1270 | mnt->mount_server.protocol = XPRT_TRANSPORT_UDP; | 1305 | mnt->mount_server.protocol = XPRT_TRANSPORT_UDP; |
| 1271 | break; | 1306 | break; |
| 1307 | case Opt_xprt_tcp6: | ||
| 1308 | mountfamily = AF_INET6; | ||
| 1272 | case Opt_xprt_tcp: | 1309 | case Opt_xprt_tcp: |
| 1273 | mnt->mount_server.protocol = XPRT_TRANSPORT_TCP; | 1310 | mnt->mount_server.protocol = XPRT_TRANSPORT_TCP; |
| 1274 | break; | 1311 | break; |
| @@ -1367,8 +1404,33 @@ static int nfs_parse_mount_options(char *raw, | |||
| 1367 | if (!sloppy && invalid_option) | 1404 | if (!sloppy && invalid_option) |
| 1368 | return 0; | 1405 | return 0; |
| 1369 | 1406 | ||
| 1407 | /* | ||
| 1408 | * verify that any proto=/mountproto= options match the address | ||
| 1409 | * familiies in the addr=/mountaddr= options. | ||
| 1410 | */ | ||
| 1411 | if (protofamily != AF_UNSPEC && | ||
| 1412 | protofamily != mnt->nfs_server.address.ss_family) | ||
| 1413 | goto out_proto_mismatch; | ||
| 1414 | |||
| 1415 | if (mountfamily != AF_UNSPEC) { | ||
| 1416 | if (mnt->mount_server.addrlen) { | ||
| 1417 | if (mountfamily != mnt->mount_server.address.ss_family) | ||
| 1418 | goto out_mountproto_mismatch; | ||
| 1419 | } else { | ||
| 1420 | if (mountfamily != mnt->nfs_server.address.ss_family) | ||
| 1421 | goto out_mountproto_mismatch; | ||
| 1422 | } | ||
| 1423 | } | ||
| 1424 | |||
| 1370 | return 1; | 1425 | return 1; |
| 1371 | 1426 | ||
| 1427 | out_mountproto_mismatch: | ||
| 1428 | printk(KERN_INFO "NFS: mount server address does not match mountproto= " | ||
| 1429 | "option\n"); | ||
| 1430 | return 0; | ||
| 1431 | out_proto_mismatch: | ||
| 1432 | printk(KERN_INFO "NFS: server address does not match proto= option\n"); | ||
| 1433 | return 0; | ||
| 1372 | out_invalid_address: | 1434 | out_invalid_address: |
| 1373 | printk(KERN_INFO "NFS: bad IP address specified: %s\n", p); | 1435 | printk(KERN_INFO "NFS: bad IP address specified: %s\n", p); |
| 1374 | return 0; | 1436 | return 0; |
| @@ -1881,7 +1943,6 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data) | |||
| 1881 | if (data == NULL) | 1943 | if (data == NULL) |
| 1882 | return -ENOMEM; | 1944 | return -ENOMEM; |
| 1883 | 1945 | ||
| 1884 | lock_kernel(); | ||
| 1885 | /* fill out struct with values from existing mount */ | 1946 | /* fill out struct with values from existing mount */ |
| 1886 | data->flags = nfss->flags; | 1947 | data->flags = nfss->flags; |
| 1887 | data->rsize = nfss->rsize; | 1948 | data->rsize = nfss->rsize; |
| @@ -1907,7 +1968,6 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data) | |||
| 1907 | error = nfs_compare_remount_data(nfss, data); | 1968 | error = nfs_compare_remount_data(nfss, data); |
| 1908 | out: | 1969 | out: |
| 1909 | kfree(data); | 1970 | kfree(data); |
| 1910 | unlock_kernel(); | ||
| 1911 | return error; | 1971 | return error; |
| 1912 | } | 1972 | } |
| 1913 | 1973 | ||
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index 1064c91ae810..6da3d3ff6edd 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c | |||
| @@ -83,7 +83,7 @@ static void nfs_async_unlink_done(struct rpc_task *task, void *calldata) | |||
| 83 | struct inode *dir = data->dir; | 83 | struct inode *dir = data->dir; |
| 84 | 84 | ||
| 85 | if (!NFS_PROTO(dir)->unlink_done(task, dir)) | 85 | if (!NFS_PROTO(dir)->unlink_done(task, dir)) |
| 86 | nfs4_restart_rpc(task, NFS_SERVER(dir)->nfs_client); | 86 | nfs_restart_rpc(task, NFS_SERVER(dir)->nfs_client); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | /** | 89 | /** |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index b1ce2ea9b93b..d171696017f4 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
| @@ -1216,7 +1216,7 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data) | |||
| 1216 | */ | 1216 | */ |
| 1217 | argp->stable = NFS_FILE_SYNC; | 1217 | argp->stable = NFS_FILE_SYNC; |
| 1218 | } | 1218 | } |
| 1219 | nfs4_restart_rpc(task, server->nfs_client); | 1219 | nfs_restart_rpc(task, server->nfs_client); |
| 1220 | return -EAGAIN; | 1220 | return -EAGAIN; |
| 1221 | } | 1221 | } |
| 1222 | if (time_before(complain, jiffies)) { | 1222 | if (time_before(complain, jiffies)) { |
| @@ -1228,7 +1228,6 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data) | |||
| 1228 | /* Can't do anything about it except throw an error. */ | 1228 | /* Can't do anything about it except throw an error. */ |
| 1229 | task->tk_status = -EIO; | 1229 | task->tk_status = -EIO; |
| 1230 | } | 1230 | } |
| 1231 | nfs4_sequence_free_slot(server->nfs_client, &data->res.seq_res); | ||
| 1232 | return 0; | 1231 | return 0; |
| 1233 | } | 1232 | } |
| 1234 | 1233 | ||
| @@ -1612,15 +1611,16 @@ int nfs_migrate_page(struct address_space *mapping, struct page *newpage, | |||
| 1612 | if (ret) | 1611 | if (ret) |
| 1613 | goto out_unlock; | 1612 | goto out_unlock; |
| 1614 | page_cache_get(newpage); | 1613 | page_cache_get(newpage); |
| 1614 | spin_lock(&mapping->host->i_lock); | ||
| 1615 | req->wb_page = newpage; | 1615 | req->wb_page = newpage; |
| 1616 | SetPagePrivate(newpage); | 1616 | SetPagePrivate(newpage); |
| 1617 | set_page_private(newpage, page_private(page)); | 1617 | set_page_private(newpage, (unsigned long)req); |
| 1618 | ClearPagePrivate(page); | 1618 | ClearPagePrivate(page); |
| 1619 | set_page_private(page, 0); | 1619 | set_page_private(page, 0); |
| 1620 | spin_unlock(&mapping->host->i_lock); | ||
| 1620 | page_cache_release(page); | 1621 | page_cache_release(page); |
| 1621 | out_unlock: | 1622 | out_unlock: |
| 1622 | nfs_clear_page_tag_locked(req); | 1623 | nfs_clear_page_tag_locked(req); |
| 1623 | nfs_release_request(req); | ||
| 1624 | out: | 1624 | out: |
| 1625 | return ret; | 1625 | return ret; |
| 1626 | } | 1626 | } |
diff --git a/fs/nfsctl.c b/fs/nfsctl.c index 8f9a20556f79..d3854d94b7cf 100644 --- a/fs/nfsctl.c +++ b/fs/nfsctl.c | |||
| @@ -7,8 +7,6 @@ | |||
| 7 | #include <linux/types.h> | 7 | #include <linux/types.h> |
| 8 | #include <linux/file.h> | 8 | #include <linux/file.h> |
| 9 | #include <linux/fs.h> | 9 | #include <linux/fs.h> |
| 10 | #include <linux/sunrpc/svc.h> | ||
| 11 | #include <linux/nfsd/nfsd.h> | ||
| 12 | #include <linux/nfsd/syscall.h> | 10 | #include <linux/nfsd/syscall.h> |
| 13 | #include <linux/cred.h> | 11 | #include <linux/cred.h> |
| 14 | #include <linux/sched.h> | 12 | #include <linux/sched.h> |
diff --git a/fs/nfsd/auth.c b/fs/nfsd/auth.c index 36fcabbf5186..79717a40daba 100644 --- a/fs/nfsd/auth.c +++ b/fs/nfsd/auth.c | |||
| @@ -1,15 +1,7 @@ | |||
| 1 | /* | 1 | /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */ |
| 2 | * linux/fs/nfsd/auth.c | ||
| 3 | * | ||
| 4 | * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> | ||
| 5 | */ | ||
| 6 | 2 | ||
| 7 | #include <linux/types.h> | ||
| 8 | #include <linux/sched.h> | 3 | #include <linux/sched.h> |
| 9 | #include <linux/sunrpc/svc.h> | 4 | #include "nfsd.h" |
| 10 | #include <linux/sunrpc/svcauth.h> | ||
| 11 | #include <linux/nfsd/nfsd.h> | ||
| 12 | #include <linux/nfsd/export.h> | ||
| 13 | #include "auth.h" | 5 | #include "auth.h" |
| 14 | 6 | ||
| 15 | int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp) | 7 | int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp) |
diff --git a/fs/nfsd/cache.h b/fs/nfsd/cache.h new file mode 100644 index 000000000000..d892be61016c --- /dev/null +++ b/fs/nfsd/cache.h | |||
| @@ -0,0 +1,83 @@ | |||
| 1 | /* | ||
| 2 | * Request reply cache. This was heavily inspired by the | ||
| 3 | * implementation in 4.3BSD/4.4BSD. | ||
| 4 | * | ||
| 5 | * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef NFSCACHE_H | ||
| 9 | #define NFSCACHE_H | ||
| 10 | |||
| 11 | #include <linux/sunrpc/svc.h> | ||
| 12 | |||
| 13 | /* | ||
| 14 | * Representation of a reply cache entry. | ||
| 15 | */ | ||
| 16 | struct svc_cacherep { | ||
| 17 | struct hlist_node c_hash; | ||
| 18 | struct list_head c_lru; | ||
| 19 | |||
| 20 | unsigned char c_state, /* unused, inprog, done */ | ||
| 21 | c_type, /* status, buffer */ | ||
| 22 | c_secure : 1; /* req came from port < 1024 */ | ||
| 23 | struct sockaddr_in c_addr; | ||
| 24 | __be32 c_xid; | ||
| 25 | u32 c_prot; | ||
| 26 | u32 c_proc; | ||
| 27 | u32 c_vers; | ||
| 28 | unsigned long c_timestamp; | ||
| 29 | union { | ||
| 30 | struct kvec u_vec; | ||
| 31 | __be32 u_status; | ||
| 32 | } c_u; | ||
| 33 | }; | ||
| 34 | |||
| 35 | #define c_replvec c_u.u_vec | ||
| 36 | #define c_replstat c_u.u_status | ||
| 37 | |||
| 38 | /* cache entry states */ | ||
| 39 | enum { | ||
| 40 | RC_UNUSED, | ||
| 41 | RC_INPROG, | ||
| 42 | RC_DONE | ||
| 43 | }; | ||
| 44 | |||
| 45 | /* return values */ | ||
| 46 | enum { | ||
| 47 | RC_DROPIT, | ||
| 48 | RC_REPLY, | ||
| 49 | RC_DOIT, | ||
| 50 | RC_INTR | ||
| 51 | }; | ||
| 52 | |||
| 53 | /* | ||
| 54 | * Cache types. | ||
| 55 | * We may want to add more types one day, e.g. for diropres and | ||
| 56 | * attrstat replies. Using cache entries with fixed length instead | ||
| 57 | * of buffer pointers may be more efficient. | ||
| 58 | */ | ||
| 59 | enum { | ||
| 60 | RC_NOCACHE, | ||
| 61 | RC_REPLSTAT, | ||
| 62 | RC_REPLBUFF, | ||
| 63 | }; | ||
| 64 | |||
| 65 | /* | ||
| 66 | * If requests are retransmitted within this interval, they're dropped. | ||
| 67 | */ | ||
| 68 | #define RC_DELAY (HZ/5) | ||
| 69 | |||
| 70 | int nfsd_reply_cache_init(void); | ||
| 71 | void nfsd_reply_cache_shutdown(void); | ||
| 72 | int nfsd_cache_lookup(struct svc_rqst *, int); | ||
| 73 | void nfsd_cache_update(struct svc_rqst *, int, __be32 *); | ||
| 74 | |||
| 75 | #ifdef CONFIG_NFSD_V4 | ||
| 76 | void nfsd4_set_statp(struct svc_rqst *rqstp, __be32 *statp); | ||
| 77 | #else /* CONFIG_NFSD_V4 */ | ||
| 78 | static inline void nfsd4_set_statp(struct svc_rqst *rqstp, __be32 *statp) | ||
| 79 | { | ||
| 80 | } | ||
| 81 | #endif /* CONFIG_NFSD_V4 */ | ||
| 82 | |||
| 83 | #endif /* NFSCACHE_H */ | ||
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index c1c9e035d4a4..c487810a2366 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | #define MSNFS /* HACK HACK */ | 1 | #define MSNFS /* HACK HACK */ |
| 2 | /* | 2 | /* |
| 3 | * linux/fs/nfsd/export.c | ||
| 4 | * | ||
| 5 | * NFS exporting and validation. | 3 | * NFS exporting and validation. |
| 6 | * | 4 | * |
| 7 | * We maintain a list of clients, each of which has a list of | 5 | * We maintain a list of clients, each of which has a list of |
| @@ -14,29 +12,16 @@ | |||
| 14 | * Copyright (C) 1995, 1996 Olaf Kirch, <okir@monad.swb.de> | 12 | * Copyright (C) 1995, 1996 Olaf Kirch, <okir@monad.swb.de> |
| 15 | */ | 13 | */ |
| 16 | 14 | ||
| 17 | #include <linux/unistd.h> | ||
| 18 | #include <linux/slab.h> | ||
| 19 | #include <linux/stat.h> | ||
| 20 | #include <linux/in.h> | ||
| 21 | #include <linux/seq_file.h> | ||
| 22 | #include <linux/syscalls.h> | ||
| 23 | #include <linux/rwsem.h> | ||
| 24 | #include <linux/dcache.h> | ||
| 25 | #include <linux/namei.h> | 15 | #include <linux/namei.h> |
| 26 | #include <linux/mount.h> | ||
| 27 | #include <linux/hash.h> | ||
| 28 | #include <linux/module.h> | 16 | #include <linux/module.h> |
| 29 | #include <linux/exportfs.h> | 17 | #include <linux/exportfs.h> |
| 30 | 18 | ||
| 31 | #include <linux/sunrpc/svc.h> | ||
| 32 | #include <linux/nfsd/nfsd.h> | ||
| 33 | #include <linux/nfsd/nfsfh.h> | ||
| 34 | #include <linux/nfsd/syscall.h> | 19 | #include <linux/nfsd/syscall.h> |
| 35 | #include <linux/lockd/bind.h> | ||
| 36 | #include <linux/sunrpc/msg_prot.h> | ||
| 37 | #include <linux/sunrpc/gss_api.h> | ||
| 38 | #include <net/ipv6.h> | 20 | #include <net/ipv6.h> |
| 39 | 21 | ||
| 22 | #include "nfsd.h" | ||
| 23 | #include "nfsfh.h" | ||
| 24 | |||
| 40 | #define NFSDDBG_FACILITY NFSDDBG_EXPORT | 25 | #define NFSDDBG_FACILITY NFSDDBG_EXPORT |
| 41 | 26 | ||
| 42 | typedef struct auth_domain svc_client; | 27 | typedef struct auth_domain svc_client; |
| @@ -369,16 +354,25 @@ static struct svc_export *svc_export_update(struct svc_export *new, | |||
| 369 | struct svc_export *old); | 354 | struct svc_export *old); |
| 370 | static struct svc_export *svc_export_lookup(struct svc_export *); | 355 | static struct svc_export *svc_export_lookup(struct svc_export *); |
| 371 | 356 | ||
| 372 | static int check_export(struct inode *inode, int flags, unsigned char *uuid) | 357 | static int check_export(struct inode *inode, int *flags, unsigned char *uuid) |
| 373 | { | 358 | { |
| 374 | 359 | ||
| 375 | /* We currently export only dirs and regular files. | 360 | /* |
| 376 | * This is what umountd does. | 361 | * We currently export only dirs, regular files, and (for v4 |
| 362 | * pseudoroot) symlinks. | ||
| 377 | */ | 363 | */ |
| 378 | if (!S_ISDIR(inode->i_mode) && | 364 | if (!S_ISDIR(inode->i_mode) && |
| 365 | !S_ISLNK(inode->i_mode) && | ||
| 379 | !S_ISREG(inode->i_mode)) | 366 | !S_ISREG(inode->i_mode)) |
| 380 | return -ENOTDIR; | 367 | return -ENOTDIR; |
| 381 | 368 | ||
| 369 | /* | ||
| 370 | * Mountd should never pass down a writeable V4ROOT export, but, | ||
| 371 | * just to make sure: | ||
| 372 | */ | ||
| 373 | if (*flags & NFSEXP_V4ROOT) | ||
| 374 | *flags |= NFSEXP_READONLY; | ||
| 375 | |||
| 382 | /* There are two requirements on a filesystem to be exportable. | 376 | /* There are two requirements on a filesystem to be exportable. |
| 383 | * 1: We must be able to identify the filesystem from a number. | 377 | * 1: We must be able to identify the filesystem from a number. |
| 384 | * either a device number (so FS_REQUIRES_DEV needed) | 378 | * either a device number (so FS_REQUIRES_DEV needed) |
| @@ -387,7 +381,7 @@ static int check_export(struct inode *inode, int flags, unsigned char *uuid) | |||
| 387 | * This means that s_export_op must be set. | 381 | * This means that s_export_op must be set. |
| 388 | */ | 382 | */ |
| 389 | if (!(inode->i_sb->s_type->fs_flags & FS_REQUIRES_DEV) && | 383 | if (!(inode->i_sb->s_type->fs_flags & FS_REQUIRES_DEV) && |
| 390 | !(flags & NFSEXP_FSID) && | 384 | !(*flags & NFSEXP_FSID) && |
| 391 | uuid == NULL) { | 385 | uuid == NULL) { |
| 392 | dprintk("exp_export: export of non-dev fs without fsid\n"); | 386 | dprintk("exp_export: export of non-dev fs without fsid\n"); |
| 393 | return -EINVAL; | 387 | return -EINVAL; |
| @@ -602,7 +596,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen) | |||
| 602 | goto out4; | 596 | goto out4; |
| 603 | } | 597 | } |
| 604 | 598 | ||
| 605 | err = check_export(exp.ex_path.dentry->d_inode, exp.ex_flags, | 599 | err = check_export(exp.ex_path.dentry->d_inode, &exp.ex_flags, |
| 606 | exp.ex_uuid); | 600 | exp.ex_uuid); |
| 607 | if (err) | 601 | if (err) |
| 608 | goto out4; | 602 | goto out4; |
| @@ -1041,7 +1035,7 @@ exp_export(struct nfsctl_export *nxp) | |||
| 1041 | goto finish; | 1035 | goto finish; |
| 1042 | } | 1036 | } |
| 1043 | 1037 | ||
| 1044 | err = check_export(path.dentry->d_inode, nxp->ex_flags, NULL); | 1038 | err = check_export(path.dentry->d_inode, &nxp->ex_flags, NULL); |
| 1045 | if (err) goto finish; | 1039 | if (err) goto finish; |
| 1046 | 1040 | ||
| 1047 | err = -ENOMEM; | 1041 | err = -ENOMEM; |
| @@ -1320,6 +1314,23 @@ rqst_exp_parent(struct svc_rqst *rqstp, struct path *path) | |||
| 1320 | return exp; | 1314 | return exp; |
| 1321 | } | 1315 | } |
| 1322 | 1316 | ||
| 1317 | static struct svc_export *find_fsidzero_export(struct svc_rqst *rqstp) | ||
| 1318 | { | ||
| 1319 | struct svc_export *exp; | ||
| 1320 | u32 fsidv[2]; | ||
| 1321 | |||
| 1322 | mk_fsid(FSID_NUM, fsidv, 0, 0, 0, NULL); | ||
| 1323 | |||
| 1324 | exp = rqst_exp_find(rqstp, FSID_NUM, fsidv); | ||
| 1325 | /* | ||
| 1326 | * We shouldn't have accepting an nfsv4 request at all if we | ||
| 1327 | * don't have a pseudoexport!: | ||
| 1328 | */ | ||
| 1329 | if (IS_ERR(exp) && PTR_ERR(exp) == -ENOENT) | ||
| 1330 | exp = ERR_PTR(-ESERVERFAULT); | ||
| 1331 | return exp; | ||
| 1332 | } | ||
| 1333 | |||
| 1323 | /* | 1334 | /* |
| 1324 | * Called when we need the filehandle for the root of the pseudofs, | 1335 | * Called when we need the filehandle for the root of the pseudofs, |
| 1325 | * for a given NFSv4 client. The root is defined to be the | 1336 | * for a given NFSv4 client. The root is defined to be the |
| @@ -1330,11 +1341,8 @@ exp_pseudoroot(struct svc_rqst *rqstp, struct svc_fh *fhp) | |||
| 1330 | { | 1341 | { |
| 1331 | struct svc_export *exp; | 1342 | struct svc_export *exp; |
| 1332 | __be32 rv; | 1343 | __be32 rv; |
| 1333 | u32 fsidv[2]; | ||
| 1334 | 1344 | ||
| 1335 | mk_fsid(FSID_NUM, fsidv, 0, 0, 0, NULL); | 1345 | exp = find_fsidzero_export(rqstp); |
| 1336 | |||
| 1337 | exp = rqst_exp_find(rqstp, FSID_NUM, fsidv); | ||
| 1338 | if (IS_ERR(exp)) | 1346 | if (IS_ERR(exp)) |
| 1339 | return nfserrno(PTR_ERR(exp)); | 1347 | return nfserrno(PTR_ERR(exp)); |
| 1340 | rv = fh_compose(fhp, exp, exp->ex_path.dentry, NULL); | 1348 | rv = fh_compose(fhp, exp, exp->ex_path.dentry, NULL); |
| @@ -1425,6 +1433,7 @@ static struct flags { | |||
| 1425 | { NFSEXP_CROSSMOUNT, {"crossmnt", ""}}, | 1433 | { NFSEXP_CROSSMOUNT, {"crossmnt", ""}}, |
| 1426 | { NFSEXP_NOSUBTREECHECK, {"no_subtree_check", ""}}, | 1434 | { NFSEXP_NOSUBTREECHECK, {"no_subtree_check", ""}}, |
| 1427 | { NFSEXP_NOAUTHNLM, {"insecure_locks", ""}}, | 1435 | { NFSEXP_NOAUTHNLM, {"insecure_locks", ""}}, |
| 1436 | { NFSEXP_V4ROOT, {"v4root", ""}}, | ||
| 1428 | #ifdef MSNFS | 1437 | #ifdef MSNFS |
| 1429 | { NFSEXP_MSNFS, {"msnfs", ""}}, | 1438 | { NFSEXP_MSNFS, {"msnfs", ""}}, |
| 1430 | #endif | 1439 | #endif |
diff --git a/fs/nfsd/lockd.c b/fs/nfsd/lockd.c index b2786a5f9afe..0c6d81670137 100644 --- a/fs/nfsd/lockd.c +++ b/fs/nfsd/lockd.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/nfsd/lockd.c | ||
| 3 | * | ||
| 4 | * This file contains all the stubs needed when communicating with lockd. | 2 | * This file contains all the stubs needed when communicating with lockd. |
| 5 | * This level of indirection is necessary so we can run nfsd+lockd without | 3 | * This level of indirection is necessary so we can run nfsd+lockd without |
| 6 | * requiring the nfs client to be compiled in/loaded, and vice versa. | 4 | * requiring the nfs client to be compiled in/loaded, and vice versa. |
| @@ -8,14 +6,10 @@ | |||
| 8 | * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de> | 6 | * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de> |
| 9 | */ | 7 | */ |
| 10 | 8 | ||
| 11 | #include <linux/types.h> | ||
| 12 | #include <linux/fs.h> | ||
| 13 | #include <linux/file.h> | 9 | #include <linux/file.h> |
| 14 | #include <linux/mount.h> | ||
| 15 | #include <linux/sunrpc/clnt.h> | ||
| 16 | #include <linux/sunrpc/svc.h> | ||
| 17 | #include <linux/nfsd/nfsd.h> | ||
| 18 | #include <linux/lockd/bind.h> | 10 | #include <linux/lockd/bind.h> |
| 11 | #include "nfsd.h" | ||
| 12 | #include "vfs.h" | ||
| 19 | 13 | ||
| 20 | #define NFSDDBG_FACILITY NFSDDBG_LOCKD | 14 | #define NFSDDBG_FACILITY NFSDDBG_LOCKD |
| 21 | 15 | ||
diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c index 4e3219e84116..f20589d2ae27 100644 --- a/fs/nfsd/nfs2acl.c +++ b/fs/nfsd/nfs2acl.c | |||
| @@ -1,19 +1,15 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/nfsd/nfs2acl.c | ||
| 3 | * | ||
| 4 | * Process version 2 NFSACL requests. | 2 | * Process version 2 NFSACL requests. |
| 5 | * | 3 | * |
| 6 | * Copyright (C) 2002-2003 Andreas Gruenbacher <agruen@suse.de> | 4 | * Copyright (C) 2002-2003 Andreas Gruenbacher <agruen@suse.de> |
| 7 | */ | 5 | */ |
| 8 | 6 | ||
| 9 | #include <linux/sunrpc/svc.h> | 7 | #include "nfsd.h" |
| 10 | #include <linux/nfs.h> | 8 | /* FIXME: nfsacl.h is a broken header */ |
| 11 | #include <linux/nfsd/nfsd.h> | ||
| 12 | #include <linux/nfsd/cache.h> | ||
| 13 | #include <linux/nfsd/xdr.h> | ||
| 14 | #include <linux/nfsd/xdr3.h> | ||
| 15 | #include <linux/posix_acl.h> | ||
| 16 | #include <linux/nfsacl.h> | 9 | #include <linux/nfsacl.h> |
| 10 | #include "cache.h" | ||
| 11 | #include "xdr3.h" | ||
| 12 | #include "vfs.h" | ||
| 17 | 13 | ||
| 18 | #define NFSDDBG_FACILITY NFSDDBG_PROC | 14 | #define NFSDDBG_FACILITY NFSDDBG_PROC |
| 19 | #define RETURN_STATUS(st) { resp->status = (st); return (st); } | 15 | #define RETURN_STATUS(st) { resp->status = (st); return (st); } |
| @@ -217,6 +213,16 @@ static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p, | |||
| 217 | * XDR encode functions | 213 | * XDR encode functions |
| 218 | */ | 214 | */ |
| 219 | 215 | ||
| 216 | /* | ||
| 217 | * There must be an encoding function for void results so svc_process | ||
| 218 | * will work properly. | ||
| 219 | */ | ||
| 220 | int | ||
| 221 | nfsaclsvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p, void *dummy) | ||
| 222 | { | ||
| 223 | return xdr_ressize_check(rqstp, p); | ||
| 224 | } | ||
| 225 | |||
| 220 | /* GETACL */ | 226 | /* GETACL */ |
| 221 | static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p, | 227 | static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p, |
| 222 | struct nfsd3_getaclres *resp) | 228 | struct nfsd3_getaclres *resp) |
| @@ -308,7 +314,6 @@ static int nfsaclsvc_release_access(struct svc_rqst *rqstp, __be32 *p, | |||
| 308 | } | 314 | } |
| 309 | 315 | ||
| 310 | #define nfsaclsvc_decode_voidargs NULL | 316 | #define nfsaclsvc_decode_voidargs NULL |
| 311 | #define nfsaclsvc_encode_voidres NULL | ||
| 312 | #define nfsaclsvc_release_void NULL | 317 | #define nfsaclsvc_release_void NULL |
| 313 | #define nfsd3_fhandleargs nfsd_fhandle | 318 | #define nfsd3_fhandleargs nfsd_fhandle |
| 314 | #define nfsd3_attrstatres nfsd_attrstat | 319 | #define nfsd3_attrstatres nfsd_attrstat |
| @@ -346,5 +351,5 @@ struct svc_version nfsd_acl_version2 = { | |||
| 346 | .vs_proc = nfsd_acl_procedures2, | 351 | .vs_proc = nfsd_acl_procedures2, |
| 347 | .vs_dispatch = nfsd_dispatch, | 352 | .vs_dispatch = nfsd_dispatch, |
| 348 | .vs_xdrsize = NFS3_SVC_XDRSIZE, | 353 | .vs_xdrsize = NFS3_SVC_XDRSIZE, |
| 349 | .vs_hidden = 1, | 354 | .vs_hidden = 0, |
| 350 | }; | 355 | }; |
diff --git a/fs/nfsd/nfs3acl.c b/fs/nfsd/nfs3acl.c index 9981dbb377a3..e0c4846bad92 100644 --- a/fs/nfsd/nfs3acl.c +++ b/fs/nfsd/nfs3acl.c | |||
| @@ -1,18 +1,15 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/nfsd/nfs3acl.c | ||
| 3 | * | ||
| 4 | * Process version 3 NFSACL requests. | 2 | * Process version 3 NFSACL requests. |
| 5 | * | 3 | * |
| 6 | * Copyright (C) 2002-2003 Andreas Gruenbacher <agruen@suse.de> | 4 | * Copyright (C) 2002-2003 Andreas Gruenbacher <agruen@suse.de> |
| 7 | */ | 5 | */ |
| 8 | 6 | ||
| 9 | #include <linux/sunrpc/svc.h> | 7 | #include "nfsd.h" |
| 10 | #include <linux/nfs3.h> | 8 | /* FIXME: nfsacl.h is a broken header */ |
| 11 | #include <linux/nfsd/nfsd.h> | ||
| 12 | #include <linux/nfsd/cache.h> | ||
| 13 | #include <linux/nfsd/xdr3.h> | ||
| 14 | #include <linux/posix_acl.h> | ||
| 15 | #include <linux/nfsacl.h> | 9 | #include <linux/nfsacl.h> |
| 10 | #include "cache.h" | ||
| 11 | #include "xdr3.h" | ||
| 12 | #include "vfs.h" | ||
| 16 | 13 | ||
| 17 | #define RETURN_STATUS(st) { resp->status = (st); return (st); } | 14 | #define RETURN_STATUS(st) { resp->status = (st); return (st); } |
| 18 | 15 | ||
| @@ -264,6 +261,6 @@ struct svc_version nfsd_acl_version3 = { | |||
| 264 | .vs_proc = nfsd_acl_procedures3, | 261 | .vs_proc = nfsd_acl_procedures3, |
| 265 | .vs_dispatch = nfsd_dispatch, | 262 | .vs_dispatch = nfsd_dispatch, |
| 266 | .vs_xdrsize = NFS3_SVC_XDRSIZE, | 263 | .vs_xdrsize = NFS3_SVC_XDRSIZE, |
| 267 | .vs_hidden = 1, | 264 | .vs_hidden = 0, |
| 268 | }; | 265 | }; |
| 269 | 266 | ||
diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index a713c418a922..3d68f45a37b9 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c | |||
| @@ -1,30 +1,16 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/nfsd/nfs3proc.c | ||
| 3 | * | ||
| 4 | * Process version 3 NFS requests. | 2 | * Process version 3 NFS requests. |
| 5 | * | 3 | * |
| 6 | * Copyright (C) 1996, 1997, 1998 Olaf Kirch <okir@monad.swb.de> | 4 | * Copyright (C) 1996, 1997, 1998 Olaf Kirch <okir@monad.swb.de> |
| 7 | */ | 5 | */ |
| 8 | 6 | ||
| 9 | #include <linux/linkage.h> | ||
| 10 | #include <linux/time.h> | ||
| 11 | #include <linux/errno.h> | ||
| 12 | #include <linux/fs.h> | 7 | #include <linux/fs.h> |
| 13 | #include <linux/ext2_fs.h> | 8 | #include <linux/ext2_fs.h> |
| 14 | #include <linux/stat.h> | ||
| 15 | #include <linux/fcntl.h> | ||
| 16 | #include <linux/net.h> | ||
| 17 | #include <linux/in.h> | ||
| 18 | #include <linux/unistd.h> | ||
| 19 | #include <linux/slab.h> | ||
| 20 | #include <linux/major.h> | ||
| 21 | #include <linux/magic.h> | 9 | #include <linux/magic.h> |
| 22 | 10 | ||
| 23 | #include <linux/sunrpc/svc.h> | 11 | #include "cache.h" |
| 24 | #include <linux/nfsd/nfsd.h> | 12 | #include "xdr3.h" |
| 25 | #include <linux/nfsd/cache.h> | 13 | #include "vfs.h" |
| 26 | #include <linux/nfsd/xdr3.h> | ||
| 27 | #include <linux/nfs3.h> | ||
| 28 | 14 | ||
| 29 | #define NFSDDBG_FACILITY NFSDDBG_PROC | 15 | #define NFSDDBG_FACILITY NFSDDBG_PROC |
| 30 | 16 | ||
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index d0a2ce1b4324..2a533a0af2a9 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/nfsd/nfs3xdr.c | ||
| 3 | * | ||
| 4 | * XDR support for nfsd/protocol version 3. | 2 | * XDR support for nfsd/protocol version 3. |
| 5 | * | 3 | * |
| 6 | * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> | 4 | * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> |
| @@ -8,19 +6,8 @@ | |||
| 8 | * 2003-08-09 Jamie Lokier: Use htonl() for nanoseconds, not htons()! | 6 | * 2003-08-09 Jamie Lokier: Use htonl() for nanoseconds, not htons()! |
| 9 | */ | 7 | */ |
| 10 | 8 | ||
| 11 | #include <linux/types.h> | ||
| 12 | #include <linux/time.h> | ||
| 13 | #include <linux/nfs3.h> | ||
| 14 | #include <linux/list.h> | ||
| 15 | #include <linux/spinlock.h> | ||
| 16 | #include <linux/dcache.h> | ||
| 17 | #include <linux/namei.h> | 9 | #include <linux/namei.h> |
| 18 | #include <linux/mm.h> | 10 | #include "xdr3.h" |
| 19 | #include <linux/vfs.h> | ||
| 20 | #include <linux/sunrpc/xdr.h> | ||
| 21 | #include <linux/sunrpc/svc.h> | ||
| 22 | #include <linux/nfsd/nfsd.h> | ||
| 23 | #include <linux/nfsd/xdr3.h> | ||
| 24 | #include "auth.h" | 11 | #include "auth.h" |
| 25 | 12 | ||
| 26 | #define NFSDDBG_FACILITY NFSDDBG_XDR | 13 | #define NFSDDBG_FACILITY NFSDDBG_XDR |
diff --git a/fs/nfsd/nfs4acl.c b/fs/nfsd/nfs4acl.c index 725d02f210e2..88150685df34 100644 --- a/fs/nfsd/nfs4acl.c +++ b/fs/nfsd/nfs4acl.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * fs/nfs4acl/acl.c | ||
| 3 | * | ||
| 4 | * Common NFSv4 ACL handling code. | 2 | * Common NFSv4 ACL handling code. |
| 5 | * | 3 | * |
| 6 | * Copyright (c) 2002, 2003 The Regents of the University of Michigan. | 4 | * Copyright (c) 2002, 2003 The Regents of the University of Michigan. |
| @@ -36,15 +34,7 @@ | |||
| 36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 37 | */ | 35 | */ |
| 38 | 36 | ||
| 39 | #include <linux/string.h> | ||
| 40 | #include <linux/slab.h> | ||
| 41 | #include <linux/list.h> | ||
| 42 | #include <linux/types.h> | ||
| 43 | #include <linux/fs.h> | ||
| 44 | #include <linux/module.h> | ||
| 45 | #include <linux/nfs_fs.h> | 37 | #include <linux/nfs_fs.h> |
| 46 | #include <linux/posix_acl.h> | ||
| 47 | #include <linux/nfs4.h> | ||
| 48 | #include <linux/nfs4_acl.h> | 38 | #include <linux/nfs4_acl.h> |
| 49 | 39 | ||
| 50 | 40 | ||
| @@ -389,7 +379,7 @@ sort_pacl(struct posix_acl *pacl) | |||
| 389 | sort_pacl_range(pacl, 1, i-1); | 379 | sort_pacl_range(pacl, 1, i-1); |
| 390 | 380 | ||
| 391 | BUG_ON(pacl->a_entries[i].e_tag != ACL_GROUP_OBJ); | 381 | BUG_ON(pacl->a_entries[i].e_tag != ACL_GROUP_OBJ); |
| 392 | j = i++; | 382 | j = ++i; |
| 393 | while (pacl->a_entries[j].e_tag == ACL_GROUP) | 383 | while (pacl->a_entries[j].e_tag == ACL_GROUP) |
| 394 | j++; | 384 | j++; |
| 395 | sort_pacl_range(pacl, i, j-1); | 385 | sort_pacl_range(pacl, i, j-1); |
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 24e8d78f8dde..c6eed2a3b093 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/nfsd/nfs4callback.c | ||
| 3 | * | ||
| 4 | * Copyright (c) 2001 The Regents of the University of Michigan. | 2 | * Copyright (c) 2001 The Regents of the University of Michigan. |
| 5 | * All rights reserved. | 3 | * All rights reserved. |
| 6 | * | 4 | * |
| @@ -33,22 +31,9 @@ | |||
| 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 34 | */ | 32 | */ |
| 35 | 33 | ||
| 36 | #include <linux/module.h> | ||
| 37 | #include <linux/list.h> | ||
| 38 | #include <linux/inet.h> | ||
| 39 | #include <linux/errno.h> | ||
| 40 | #include <linux/delay.h> | ||
| 41 | #include <linux/sched.h> | ||
| 42 | #include <linux/kthread.h> | ||
| 43 | #include <linux/sunrpc/xdr.h> | ||
| 44 | #include <linux/sunrpc/svc.h> | ||
| 45 | #include <linux/sunrpc/clnt.h> | 34 | #include <linux/sunrpc/clnt.h> |
| 46 | #include <linux/sunrpc/svcsock.h> | 35 | #include "nfsd.h" |
| 47 | #include <linux/nfsd/nfsd.h> | 36 | #include "state.h" |
| 48 | #include <linux/nfsd/state.h> | ||
| 49 | #include <linux/sunrpc/sched.h> | ||
| 50 | #include <linux/nfs4.h> | ||
| 51 | #include <linux/sunrpc/xprtsock.h> | ||
| 52 | 37 | ||
| 53 | #define NFSDDBG_FACILITY NFSDDBG_PROC | 38 | #define NFSDDBG_FACILITY NFSDDBG_PROC |
| 54 | 39 | ||
diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c index ba2c199592fd..6e2983b27f3c 100644 --- a/fs/nfsd/nfs4idmap.c +++ b/fs/nfsd/nfs4idmap.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * fs/nfsd/nfs4idmap.c | ||
| 3 | * | ||
| 4 | * Mapping of UID/GIDs to name and vice versa. | 2 | * Mapping of UID/GIDs to name and vice versa. |
| 5 | * | 3 | * |
| 6 | * Copyright (c) 2002, 2003 The Regents of the University of | 4 | * Copyright (c) 2002, 2003 The Regents of the University of |
| @@ -35,22 +33,9 @@ | |||
| 35 | */ | 33 | */ |
| 36 | 34 | ||
| 37 | #include <linux/module.h> | 35 | #include <linux/module.h> |
| 38 | #include <linux/init.h> | ||
| 39 | |||
| 40 | #include <linux/mm.h> | ||
| 41 | #include <linux/errno.h> | ||
| 42 | #include <linux/string.h> | ||
| 43 | #include <linux/sunrpc/clnt.h> | ||
| 44 | #include <linux/nfs.h> | ||
| 45 | #include <linux/nfs4.h> | ||
| 46 | #include <linux/nfs_fs.h> | ||
| 47 | #include <linux/nfs_page.h> | ||
| 48 | #include <linux/sunrpc/cache.h> | ||
| 49 | #include <linux/nfsd_idmap.h> | 36 | #include <linux/nfsd_idmap.h> |
| 50 | #include <linux/list.h> | ||
| 51 | #include <linux/time.h> | ||
| 52 | #include <linux/seq_file.h> | 37 | #include <linux/seq_file.h> |
| 53 | #include <linux/sunrpc/svcauth.h> | 38 | #include <linux/sched.h> |
| 54 | 39 | ||
| 55 | /* | 40 | /* |
| 56 | * Cache entry | 41 | * Cache entry |
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index bebc0c2e1b0a..37514c469846 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * fs/nfsd/nfs4proc.c | ||
| 3 | * | ||
| 4 | * Server-side procedures for NFSv4. | 2 | * Server-side procedures for NFSv4. |
| 5 | * | 3 | * |
| 6 | * Copyright (c) 2002 The Regents of the University of Michigan. | 4 | * Copyright (c) 2002 The Regents of the University of Michigan. |
| @@ -34,20 +32,11 @@ | |||
| 34 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 36 | */ | 34 | */ |
| 37 | |||
| 38 | #include <linux/param.h> | ||
| 39 | #include <linux/major.h> | ||
| 40 | #include <linux/slab.h> | ||
| 41 | #include <linux/file.h> | 35 | #include <linux/file.h> |
| 42 | 36 | ||
| 43 | #include <linux/sunrpc/svc.h> | 37 | #include "cache.h" |
| 44 | #include <linux/nfsd/nfsd.h> | 38 | #include "xdr4.h" |
| 45 | #include <linux/nfsd/cache.h> | 39 | #include "vfs.h" |
| 46 | #include <linux/nfs4.h> | ||
| 47 | #include <linux/nfsd/state.h> | ||
| 48 | #include <linux/nfsd/xdr4.h> | ||
| 49 | #include <linux/nfs4_acl.h> | ||
| 50 | #include <linux/sunrpc/gss_api.h> | ||
| 51 | 40 | ||
| 52 | #define NFSDDBG_FACILITY NFSDDBG_PROC | 41 | #define NFSDDBG_FACILITY NFSDDBG_PROC |
| 53 | 42 | ||
| @@ -170,7 +159,7 @@ do_open_permission(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs | |||
| 170 | accmode |= NFSD_MAY_READ; | 159 | accmode |= NFSD_MAY_READ; |
| 171 | if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) | 160 | if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) |
| 172 | accmode |= (NFSD_MAY_WRITE | NFSD_MAY_TRUNC); | 161 | accmode |= (NFSD_MAY_WRITE | NFSD_MAY_TRUNC); |
| 173 | if (open->op_share_deny & NFS4_SHARE_DENY_WRITE) | 162 | if (open->op_share_deny & NFS4_SHARE_DENY_READ) |
| 174 | accmode |= NFSD_MAY_WRITE; | 163 | accmode |= NFSD_MAY_WRITE; |
| 175 | 164 | ||
| 176 | status = fh_verify(rqstp, current_fh, S_IFREG, accmode); | 165 | status = fh_verify(rqstp, current_fh, S_IFREG, accmode); |
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index b5348405046b..5a754f7b71ed 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/nfsd/nfs4recover.c | ||
| 3 | * | ||
| 4 | * Copyright (c) 2004 The Regents of the University of Michigan. | 2 | * Copyright (c) 2004 The Regents of the University of Michigan. |
| 5 | * All rights reserved. | 3 | * All rights reserved. |
| 6 | * | 4 | * |
| @@ -33,20 +31,14 @@ | |||
| 33 | * | 31 | * |
| 34 | */ | 32 | */ |
| 35 | 33 | ||
| 36 | #include <linux/err.h> | ||
| 37 | #include <linux/sunrpc/svc.h> | ||
| 38 | #include <linux/nfsd/nfsd.h> | ||
| 39 | #include <linux/nfs4.h> | ||
| 40 | #include <linux/nfsd/state.h> | ||
| 41 | #include <linux/nfsd/xdr4.h> | ||
| 42 | #include <linux/param.h> | ||
| 43 | #include <linux/file.h> | 34 | #include <linux/file.h> |
| 44 | #include <linux/namei.h> | 35 | #include <linux/namei.h> |
| 45 | #include <asm/uaccess.h> | ||
| 46 | #include <linux/scatterlist.h> | ||
| 47 | #include <linux/crypto.h> | 36 | #include <linux/crypto.h> |
| 48 | #include <linux/sched.h> | 37 | #include <linux/sched.h> |
| 49 | #include <linux/mount.h> | 38 | |
| 39 | #include "nfsd.h" | ||
| 40 | #include "state.h" | ||
| 41 | #include "vfs.h" | ||
| 50 | 42 | ||
| 51 | #define NFSDDBG_FACILITY NFSDDBG_PROC | 43 | #define NFSDDBG_FACILITY NFSDDBG_PROC |
| 52 | 44 | ||
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 2153f9bdbebd..f19ed866c95f 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/nfsd/nfs4state.c | ||
| 3 | * | ||
| 4 | * Copyright (c) 2001 The Regents of the University of Michigan. | 2 | * Copyright (c) 2001 The Regents of the University of Michigan. |
| 5 | * All rights reserved. | 3 | * All rights reserved. |
| 6 | * | 4 | * |
| @@ -34,28 +32,14 @@ | |||
| 34 | * | 32 | * |
| 35 | */ | 33 | */ |
| 36 | 34 | ||
| 37 | #include <linux/param.h> | ||
| 38 | #include <linux/major.h> | ||
| 39 | #include <linux/slab.h> | ||
| 40 | |||
| 41 | #include <linux/sunrpc/svc.h> | ||
| 42 | #include <linux/nfsd/nfsd.h> | ||
| 43 | #include <linux/nfsd/cache.h> | ||
| 44 | #include <linux/file.h> | 35 | #include <linux/file.h> |
| 45 | #include <linux/mount.h> | ||
| 46 | #include <linux/workqueue.h> | ||
| 47 | #include <linux/smp_lock.h> | 36 | #include <linux/smp_lock.h> |
| 48 | #include <linux/kthread.h> | ||
| 49 | #include <linux/nfs4.h> | ||
| 50 | #include <linux/nfsd/state.h> | ||
| 51 | #include <linux/nfsd/xdr4.h> | ||
| 52 | #include <linux/namei.h> | 37 | #include <linux/namei.h> |
| 53 | #include <linux/swap.h> | 38 | #include <linux/swap.h> |
| 54 | #include <linux/mutex.h> | ||
| 55 | #include <linux/lockd/bind.h> | ||
| 56 | #include <linux/module.h> | ||
| 57 | #include <linux/sunrpc/svcauth_gss.h> | 39 | #include <linux/sunrpc/svcauth_gss.h> |
| 58 | #include <linux/sunrpc/clnt.h> | 40 | #include <linux/sunrpc/clnt.h> |
| 41 | #include "xdr4.h" | ||
| 42 | #include "vfs.h" | ||
| 59 | 43 | ||
| 60 | #define NFSDDBG_FACILITY NFSDDBG_PROC | 44 | #define NFSDDBG_FACILITY NFSDDBG_PROC |
| 61 | 45 | ||
| @@ -477,13 +461,14 @@ static int set_forechannel_drc_size(struct nfsd4_channel_attrs *fchan) | |||
| 477 | 461 | ||
| 478 | /* | 462 | /* |
| 479 | * fchan holds the client values on input, and the server values on output | 463 | * fchan holds the client values on input, and the server values on output |
| 464 | * sv_max_mesg is the maximum payload plus one page for overhead. | ||
| 480 | */ | 465 | */ |
| 481 | static int init_forechannel_attrs(struct svc_rqst *rqstp, | 466 | static int init_forechannel_attrs(struct svc_rqst *rqstp, |
| 482 | struct nfsd4_channel_attrs *session_fchan, | 467 | struct nfsd4_channel_attrs *session_fchan, |
| 483 | struct nfsd4_channel_attrs *fchan) | 468 | struct nfsd4_channel_attrs *fchan) |
| 484 | { | 469 | { |
| 485 | int status = 0; | 470 | int status = 0; |
| 486 | __u32 maxcount = svc_max_payload(rqstp); | 471 | __u32 maxcount = nfsd_serv->sv_max_mesg; |
| 487 | 472 | ||
| 488 | /* headerpadsz set to zero in encode routine */ | 473 | /* headerpadsz set to zero in encode routine */ |
| 489 | 474 | ||
| @@ -523,6 +508,15 @@ free_session_slots(struct nfsd4_session *ses) | |||
| 523 | kfree(ses->se_slots[i]); | 508 | kfree(ses->se_slots[i]); |
| 524 | } | 509 | } |
| 525 | 510 | ||
| 511 | /* | ||
| 512 | * We don't actually need to cache the rpc and session headers, so we | ||
| 513 | * can allocate a little less for each slot: | ||
| 514 | */ | ||
| 515 | static inline int slot_bytes(struct nfsd4_channel_attrs *ca) | ||
| 516 | { | ||
| 517 | return ca->maxresp_cached - NFSD_MIN_HDR_SEQ_SZ; | ||
| 518 | } | ||
| 519 | |||
| 526 | static int | 520 | static int |
| 527 | alloc_init_session(struct svc_rqst *rqstp, struct nfs4_client *clp, | 521 | alloc_init_session(struct svc_rqst *rqstp, struct nfs4_client *clp, |
| 528 | struct nfsd4_create_session *cses) | 522 | struct nfsd4_create_session *cses) |
| @@ -554,7 +548,7 @@ alloc_init_session(struct svc_rqst *rqstp, struct nfs4_client *clp, | |||
| 554 | memcpy(new, &tmp, sizeof(*new)); | 548 | memcpy(new, &tmp, sizeof(*new)); |
| 555 | 549 | ||
| 556 | /* allocate each struct nfsd4_slot and data cache in one piece */ | 550 | /* allocate each struct nfsd4_slot and data cache in one piece */ |
| 557 | cachesize = new->se_fchannel.maxresp_cached - NFSD_MIN_HDR_SEQ_SZ; | 551 | cachesize = slot_bytes(&new->se_fchannel); |
| 558 | for (i = 0; i < new->se_fchannel.maxreqs; i++) { | 552 | for (i = 0; i < new->se_fchannel.maxreqs; i++) { |
| 559 | sp = kzalloc(sizeof(*sp) + cachesize, GFP_KERNEL); | 553 | sp = kzalloc(sizeof(*sp) + cachesize, GFP_KERNEL); |
| 560 | if (!sp) | 554 | if (!sp) |
| @@ -628,10 +622,12 @@ void | |||
| 628 | free_session(struct kref *kref) | 622 | free_session(struct kref *kref) |
| 629 | { | 623 | { |
| 630 | struct nfsd4_session *ses; | 624 | struct nfsd4_session *ses; |
| 625 | int mem; | ||
| 631 | 626 | ||
| 632 | ses = container_of(kref, struct nfsd4_session, se_ref); | 627 | ses = container_of(kref, struct nfsd4_session, se_ref); |
| 633 | spin_lock(&nfsd_drc_lock); | 628 | spin_lock(&nfsd_drc_lock); |
| 634 | nfsd_drc_mem_used -= ses->se_fchannel.maxreqs * NFSD_SLOT_CACHE_SIZE; | 629 | mem = ses->se_fchannel.maxreqs * slot_bytes(&ses->se_fchannel); |
| 630 | nfsd_drc_mem_used -= mem; | ||
| 635 | spin_unlock(&nfsd_drc_lock); | 631 | spin_unlock(&nfsd_drc_lock); |
| 636 | free_session_slots(ses); | 632 | free_session_slots(ses); |
| 637 | kfree(ses); | 633 | kfree(ses); |
| @@ -2404,11 +2400,8 @@ nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open, struct nfs4_sta | |||
| 2404 | 2400 | ||
| 2405 | memcpy(&open->op_delegate_stateid, &dp->dl_stateid, sizeof(dp->dl_stateid)); | 2401 | memcpy(&open->op_delegate_stateid, &dp->dl_stateid, sizeof(dp->dl_stateid)); |
| 2406 | 2402 | ||
| 2407 | dprintk("NFSD: delegation stateid=(%08x/%08x/%08x/%08x)\n\n", | 2403 | dprintk("NFSD: delegation stateid=" STATEID_FMT "\n", |
| 2408 | dp->dl_stateid.si_boot, | 2404 | STATEID_VAL(&dp->dl_stateid)); |
| 2409 | dp->dl_stateid.si_stateownerid, | ||
| 2410 | dp->dl_stateid.si_fileid, | ||
| 2411 | dp->dl_stateid.si_generation); | ||
| 2412 | out: | 2405 | out: |
| 2413 | if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS | 2406 | if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS |
| 2414 | && flag == NFS4_OPEN_DELEGATE_NONE | 2407 | && flag == NFS4_OPEN_DELEGATE_NONE |
| @@ -2498,9 +2491,8 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf | |||
| 2498 | 2491 | ||
| 2499 | status = nfs_ok; | 2492 | status = nfs_ok; |
| 2500 | 2493 | ||
| 2501 | dprintk("nfs4_process_open2: stateid=(%08x/%08x/%08x/%08x)\n", | 2494 | dprintk("%s: stateid=" STATEID_FMT "\n", __func__, |
| 2502 | stp->st_stateid.si_boot, stp->st_stateid.si_stateownerid, | 2495 | STATEID_VAL(&stp->st_stateid)); |
| 2503 | stp->st_stateid.si_fileid, stp->st_stateid.si_generation); | ||
| 2504 | out: | 2496 | out: |
| 2505 | if (fp) | 2497 | if (fp) |
| 2506 | put_nfs4_file(fp); | 2498 | put_nfs4_file(fp); |
| @@ -2666,9 +2658,8 @@ STALE_STATEID(stateid_t *stateid) | |||
| 2666 | { | 2658 | { |
| 2667 | if (time_after((unsigned long)boot_time, | 2659 | if (time_after((unsigned long)boot_time, |
| 2668 | (unsigned long)stateid->si_boot)) { | 2660 | (unsigned long)stateid->si_boot)) { |
| 2669 | dprintk("NFSD: stale stateid (%08x/%08x/%08x/%08x)!\n", | 2661 | dprintk("NFSD: stale stateid " STATEID_FMT "!\n", |
| 2670 | stateid->si_boot, stateid->si_stateownerid, | 2662 | STATEID_VAL(stateid)); |
| 2671 | stateid->si_fileid, stateid->si_generation); | ||
| 2672 | return 1; | 2663 | return 1; |
| 2673 | } | 2664 | } |
| 2674 | return 0; | 2665 | return 0; |
| @@ -2680,9 +2671,8 @@ EXPIRED_STATEID(stateid_t *stateid) | |||
| 2680 | if (time_before((unsigned long)boot_time, | 2671 | if (time_before((unsigned long)boot_time, |
| 2681 | ((unsigned long)stateid->si_boot)) && | 2672 | ((unsigned long)stateid->si_boot)) && |
| 2682 | time_before((unsigned long)(stateid->si_boot + lease_time), get_seconds())) { | 2673 | time_before((unsigned long)(stateid->si_boot + lease_time), get_seconds())) { |
| 2683 | dprintk("NFSD: expired stateid (%08x/%08x/%08x/%08x)!\n", | 2674 | dprintk("NFSD: expired stateid " STATEID_FMT "!\n", |
| 2684 | stateid->si_boot, stateid->si_stateownerid, | 2675 | STATEID_VAL(stateid)); |
| 2685 | stateid->si_fileid, stateid->si_generation); | ||
| 2686 | return 1; | 2676 | return 1; |
| 2687 | } | 2677 | } |
| 2688 | return 0; | 2678 | return 0; |
| @@ -2696,9 +2686,8 @@ stateid_error_map(stateid_t *stateid) | |||
| 2696 | if (EXPIRED_STATEID(stateid)) | 2686 | if (EXPIRED_STATEID(stateid)) |
| 2697 | return nfserr_expired; | 2687 | return nfserr_expired; |
| 2698 | 2688 | ||
| 2699 | dprintk("NFSD: bad stateid (%08x/%08x/%08x/%08x)!\n", | 2689 | dprintk("NFSD: bad stateid " STATEID_FMT "!\n", |
| 2700 | stateid->si_boot, stateid->si_stateownerid, | 2690 | STATEID_VAL(stateid)); |
| 2701 | stateid->si_fileid, stateid->si_generation); | ||
| 2702 | return nfserr_bad_stateid; | 2691 | return nfserr_bad_stateid; |
| 2703 | } | 2692 | } |
| 2704 | 2693 | ||
| @@ -2884,10 +2873,8 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid, | |||
| 2884 | struct svc_fh *current_fh = &cstate->current_fh; | 2873 | struct svc_fh *current_fh = &cstate->current_fh; |
| 2885 | __be32 status; | 2874 | __be32 status; |
| 2886 | 2875 | ||
| 2887 | dprintk("NFSD: preprocess_seqid_op: seqid=%d " | 2876 | dprintk("NFSD: %s: seqid=%d stateid = " STATEID_FMT "\n", __func__, |
| 2888 | "stateid = (%08x/%08x/%08x/%08x)\n", seqid, | 2877 | seqid, STATEID_VAL(stateid)); |
| 2889 | stateid->si_boot, stateid->si_stateownerid, stateid->si_fileid, | ||
| 2890 | stateid->si_generation); | ||
| 2891 | 2878 | ||
| 2892 | *stpp = NULL; | 2879 | *stpp = NULL; |
| 2893 | *sopp = NULL; | 2880 | *sopp = NULL; |
| @@ -3019,12 +3006,8 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
| 3019 | sop->so_confirmed = 1; | 3006 | sop->so_confirmed = 1; |
| 3020 | update_stateid(&stp->st_stateid); | 3007 | update_stateid(&stp->st_stateid); |
| 3021 | memcpy(&oc->oc_resp_stateid, &stp->st_stateid, sizeof(stateid_t)); | 3008 | memcpy(&oc->oc_resp_stateid, &stp->st_stateid, sizeof(stateid_t)); |
| 3022 | dprintk("NFSD: nfsd4_open_confirm: success, seqid=%d " | 3009 | dprintk("NFSD: %s: success, seqid=%d stateid=" STATEID_FMT "\n", |
| 3023 | "stateid=(%08x/%08x/%08x/%08x)\n", oc->oc_seqid, | 3010 | __func__, oc->oc_seqid, STATEID_VAL(&stp->st_stateid)); |
| 3024 | stp->st_stateid.si_boot, | ||
| 3025 | stp->st_stateid.si_stateownerid, | ||
| 3026 | stp->st_stateid.si_fileid, | ||
| 3027 | stp->st_stateid.si_generation); | ||
| 3028 | 3011 | ||
| 3029 | nfsd4_create_clid_dir(sop->so_client); | 3012 | nfsd4_create_clid_dir(sop->so_client); |
| 3030 | out: | 3013 | out: |
| @@ -3283,9 +3266,8 @@ find_delegation_stateid(struct inode *ino, stateid_t *stid) | |||
| 3283 | struct nfs4_file *fp; | 3266 | struct nfs4_file *fp; |
| 3284 | struct nfs4_delegation *dl; | 3267 | struct nfs4_delegation *dl; |
| 3285 | 3268 | ||
| 3286 | dprintk("NFSD:find_delegation_stateid stateid=(%08x/%08x/%08x/%08x)\n", | 3269 | dprintk("NFSD: %s: stateid=" STATEID_FMT "\n", __func__, |
| 3287 | stid->si_boot, stid->si_stateownerid, | 3270 | STATEID_VAL(stid)); |
| 3288 | stid->si_fileid, stid->si_generation); | ||
| 3289 | 3271 | ||
| 3290 | fp = find_file(ino); | 3272 | fp = find_file(ino); |
| 3291 | if (!fp) | 3273 | if (!fp) |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 0fbd50cee1f6..a8587e90fd5a 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
| @@ -40,24 +40,16 @@ | |||
| 40 | * at the end of nfs4svc_decode_compoundargs. | 40 | * at the end of nfs4svc_decode_compoundargs. |
| 41 | */ | 41 | */ |
| 42 | 42 | ||
| 43 | #include <linux/param.h> | ||
| 44 | #include <linux/smp.h> | ||
| 45 | #include <linux/fs.h> | ||
| 46 | #include <linux/namei.h> | 43 | #include <linux/namei.h> |
| 47 | #include <linux/vfs.h> | 44 | #include <linux/statfs.h> |
| 48 | #include <linux/utsname.h> | 45 | #include <linux/utsname.h> |
| 49 | #include <linux/sunrpc/xdr.h> | ||
| 50 | #include <linux/sunrpc/svc.h> | ||
| 51 | #include <linux/sunrpc/clnt.h> | ||
| 52 | #include <linux/nfsd/nfsd.h> | ||
| 53 | #include <linux/nfsd/state.h> | ||
| 54 | #include <linux/nfsd/xdr4.h> | ||
| 55 | #include <linux/nfsd_idmap.h> | 46 | #include <linux/nfsd_idmap.h> |
| 56 | #include <linux/nfs4.h> | ||
| 57 | #include <linux/nfs4_acl.h> | 47 | #include <linux/nfs4_acl.h> |
| 58 | #include <linux/sunrpc/gss_api.h> | ||
| 59 | #include <linux/sunrpc/svcauth_gss.h> | 48 | #include <linux/sunrpc/svcauth_gss.h> |
| 60 | 49 | ||
| 50 | #include "xdr4.h" | ||
| 51 | #include "vfs.h" | ||
| 52 | |||
| 61 | #define NFSDDBG_FACILITY NFSDDBG_XDR | 53 | #define NFSDDBG_FACILITY NFSDDBG_XDR |
| 62 | 54 | ||
| 63 | /* | 55 | /* |
| @@ -2204,11 +2196,14 @@ nfsd4_encode_dirent_fattr(struct nfsd4_readdir *cd, | |||
| 2204 | * we will not follow the cross mount and will fill the attribtutes | 2196 | * we will not follow the cross mount and will fill the attribtutes |
| 2205 | * directly from the mountpoint dentry. | 2197 | * directly from the mountpoint dentry. |
| 2206 | */ | 2198 | */ |
| 2207 | if (d_mountpoint(dentry) && !attributes_need_mount(cd->rd_bmval)) | 2199 | if (nfsd_mountpoint(dentry, exp)) { |
| 2208 | ignore_crossmnt = 1; | ||
| 2209 | else if (d_mountpoint(dentry)) { | ||
| 2210 | int err; | 2200 | int err; |
| 2211 | 2201 | ||
| 2202 | if (!(exp->ex_flags & NFSEXP_V4ROOT) | ||
| 2203 | && !attributes_need_mount(cd->rd_bmval)) { | ||
| 2204 | ignore_crossmnt = 1; | ||
| 2205 | goto out_encode; | ||
| 2206 | } | ||
| 2212 | /* | 2207 | /* |
| 2213 | * Why the heck aren't we just using nfsd_lookup?? | 2208 | * Why the heck aren't we just using nfsd_lookup?? |
| 2214 | * Different "."/".." handling? Something else? | 2209 | * Different "."/".." handling? Something else? |
| @@ -2224,6 +2219,7 @@ nfsd4_encode_dirent_fattr(struct nfsd4_readdir *cd, | |||
| 2224 | goto out_put; | 2219 | goto out_put; |
| 2225 | 2220 | ||
| 2226 | } | 2221 | } |
| 2222 | out_encode: | ||
| 2227 | nfserr = nfsd4_encode_fattr(NULL, exp, dentry, p, buflen, cd->rd_bmval, | 2223 | nfserr = nfsd4_encode_fattr(NULL, exp, dentry, p, buflen, cd->rd_bmval, |
| 2228 | cd->rd_rqstp, ignore_crossmnt); | 2224 | cd->rd_rqstp, ignore_crossmnt); |
| 2229 | out_put: | 2225 | out_put: |
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c index 4638635c5d87..da08560c4818 100644 --- a/fs/nfsd/nfscache.c +++ b/fs/nfsd/nfscache.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/nfsd/nfscache.c | ||
| 3 | * | ||
| 4 | * Request reply cache. This is currently a global cache, but this may | 2 | * Request reply cache. This is currently a global cache, but this may |
| 5 | * change in the future and be a per-client cache. | 3 | * change in the future and be a per-client cache. |
| 6 | * | 4 | * |
| @@ -10,16 +8,8 @@ | |||
| 10 | * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> | 8 | * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> |
| 11 | */ | 9 | */ |
| 12 | 10 | ||
| 13 | #include <linux/kernel.h> | 11 | #include "nfsd.h" |
| 14 | #include <linux/time.h> | 12 | #include "cache.h" |
| 15 | #include <linux/slab.h> | ||
| 16 | #include <linux/string.h> | ||
| 17 | #include <linux/spinlock.h> | ||
| 18 | #include <linux/list.h> | ||
| 19 | |||
| 20 | #include <linux/sunrpc/svc.h> | ||
| 21 | #include <linux/nfsd/nfsd.h> | ||
| 22 | #include <linux/nfsd/cache.h> | ||
| 23 | 13 | ||
| 24 | /* Size of reply cache. Common values are: | 14 | /* Size of reply cache. Common values are: |
| 25 | * 4.3BSD: 128 | 15 | * 4.3BSD: 128 |
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 5c01fc148ce8..2604c3e70ea5 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
| @@ -1,46 +1,20 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/nfsd/nfsctl.c | ||
| 3 | * | ||
| 4 | * Syscall interface to knfsd. | 2 | * Syscall interface to knfsd. |
| 5 | * | 3 | * |
| 6 | * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> | 4 | * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> |
| 7 | */ | 5 | */ |
| 8 | 6 | ||
| 9 | #include <linux/module.h> | ||
| 10 | |||
| 11 | #include <linux/linkage.h> | ||
| 12 | #include <linux/time.h> | ||
| 13 | #include <linux/errno.h> | ||
| 14 | #include <linux/fs.h> | ||
| 15 | #include <linux/namei.h> | 7 | #include <linux/namei.h> |
| 16 | #include <linux/fcntl.h> | ||
| 17 | #include <linux/net.h> | ||
| 18 | #include <linux/in.h> | ||
| 19 | #include <linux/syscalls.h> | ||
| 20 | #include <linux/unistd.h> | ||
| 21 | #include <linux/slab.h> | ||
| 22 | #include <linux/proc_fs.h> | ||
| 23 | #include <linux/seq_file.h> | ||
| 24 | #include <linux/pagemap.h> | ||
| 25 | #include <linux/init.h> | ||
| 26 | #include <linux/inet.h> | ||
| 27 | #include <linux/string.h> | ||
| 28 | #include <linux/ctype.h> | 8 | #include <linux/ctype.h> |
| 29 | 9 | ||
| 30 | #include <linux/nfs.h> | ||
| 31 | #include <linux/nfsd_idmap.h> | 10 | #include <linux/nfsd_idmap.h> |
| 32 | #include <linux/lockd/bind.h> | ||
| 33 | #include <linux/sunrpc/svc.h> | ||
| 34 | #include <linux/sunrpc/svcsock.h> | 11 | #include <linux/sunrpc/svcsock.h> |
| 35 | #include <linux/nfsd/nfsd.h> | ||
| 36 | #include <linux/nfsd/cache.h> | ||
| 37 | #include <linux/nfsd/xdr.h> | ||
| 38 | #include <linux/nfsd/syscall.h> | 12 | #include <linux/nfsd/syscall.h> |
| 39 | #include <linux/lockd/lockd.h> | 13 | #include <linux/lockd/lockd.h> |
| 40 | #include <linux/sunrpc/clnt.h> | 14 | #include <linux/sunrpc/clnt.h> |
| 41 | 15 | ||
| 42 | #include <asm/uaccess.h> | 16 | #include "nfsd.h" |
| 43 | #include <net/ipv6.h> | 17 | #include "cache.h" |
| 44 | 18 | ||
| 45 | /* | 19 | /* |
| 46 | * We have a single directory with 9 nodes in it. | 20 | * We have a single directory with 9 nodes in it. |
| @@ -55,6 +29,7 @@ enum { | |||
| 55 | NFSD_Getfd, | 29 | NFSD_Getfd, |
| 56 | NFSD_Getfs, | 30 | NFSD_Getfs, |
| 57 | NFSD_List, | 31 | NFSD_List, |
| 32 | NFSD_Export_features, | ||
| 58 | NFSD_Fh, | 33 | NFSD_Fh, |
| 59 | NFSD_FO_UnlockIP, | 34 | NFSD_FO_UnlockIP, |
| 60 | NFSD_FO_UnlockFS, | 35 | NFSD_FO_UnlockFS, |
| @@ -173,6 +148,24 @@ static const struct file_operations exports_operations = { | |||
| 173 | .owner = THIS_MODULE, | 148 | .owner = THIS_MODULE, |
| 174 | }; | 149 | }; |
| 175 | 150 | ||
| 151 | static int export_features_show(struct seq_file *m, void *v) | ||
| 152 | { | ||
| 153 | seq_printf(m, "0x%x 0x%x\n", NFSEXP_ALLFLAGS, NFSEXP_SECINFO_FLAGS); | ||
| 154 | return 0; | ||
| 155 | } | ||
| 156 | |||
| 157 | static int export_features_open(struct inode *inode, struct file *file) | ||
| 158 | { | ||
| 159 | return single_open(file, export_features_show, NULL); | ||
| 160 | } | ||
| 161 | |||
| 162 | static struct file_operations export_features_operations = { | ||
| 163 | .open = export_features_open, | ||
| 164 | .read = seq_read, | ||
| 165 | .llseek = seq_lseek, | ||
| 166 | .release = single_release, | ||
| 167 | }; | ||
| 168 | |||
| 176 | extern int nfsd_pool_stats_open(struct inode *inode, struct file *file); | 169 | extern int nfsd_pool_stats_open(struct inode *inode, struct file *file); |
| 177 | extern int nfsd_pool_stats_release(struct inode *inode, struct file *file); | 170 | extern int nfsd_pool_stats_release(struct inode *inode, struct file *file); |
| 178 | 171 | ||
| @@ -1330,6 +1323,8 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent) | |||
| 1330 | [NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR}, | 1323 | [NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR}, |
| 1331 | [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR}, | 1324 | [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR}, |
| 1332 | [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, | 1325 | [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, |
| 1326 | [NFSD_Export_features] = {"export_features", | ||
| 1327 | &export_features_operations, S_IRUGO}, | ||
| 1333 | [NFSD_FO_UnlockIP] = {"unlock_ip", | 1328 | [NFSD_FO_UnlockIP] = {"unlock_ip", |
| 1334 | &transaction_ops, S_IWUSR|S_IRUSR}, | 1329 | &transaction_ops, S_IWUSR|S_IRUSR}, |
| 1335 | [NFSD_FO_UnlockFS] = {"unlock_filesystem", | 1330 | [NFSD_FO_UnlockFS] = {"unlock_filesystem", |
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h new file mode 100644 index 000000000000..e942a1aaac92 --- /dev/null +++ b/fs/nfsd/nfsd.h | |||
| @@ -0,0 +1,338 @@ | |||
| 1 | /* | ||
| 2 | * Hodge-podge collection of knfsd-related stuff. | ||
| 3 | * I will sort this out later. | ||
| 4 | * | ||
| 5 | * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de> | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef LINUX_NFSD_NFSD_H | ||
| 9 | #define LINUX_NFSD_NFSD_H | ||
| 10 | |||
| 11 | #include <linux/types.h> | ||
| 12 | #include <linux/mount.h> | ||
| 13 | |||
| 14 | #include <linux/nfsd/debug.h> | ||
| 15 | #include <linux/nfsd/export.h> | ||
| 16 | #include <linux/nfsd/stats.h> | ||
| 17 | /* | ||
| 18 | * nfsd version | ||
| 19 | */ | ||
| 20 | #define NFSD_SUPPORTED_MINOR_VERSION 1 | ||
| 21 | |||
| 22 | struct readdir_cd { | ||
| 23 | __be32 err; /* 0, nfserr, or nfserr_eof */ | ||
| 24 | }; | ||
| 25 | |||
| 26 | |||
| 27 | extern struct svc_program nfsd_program; | ||
| 28 | extern struct svc_version nfsd_version2, nfsd_version3, | ||
| 29 | nfsd_version4; | ||
| 30 | extern u32 nfsd_supported_minorversion; | ||
| 31 | extern struct mutex nfsd_mutex; | ||
| 32 | extern struct svc_serv *nfsd_serv; | ||
| 33 | extern spinlock_t nfsd_drc_lock; | ||
| 34 | extern unsigned int nfsd_drc_max_mem; | ||
| 35 | extern unsigned int nfsd_drc_mem_used; | ||
| 36 | |||
| 37 | extern const struct seq_operations nfs_exports_op; | ||
| 38 | |||
| 39 | /* | ||
| 40 | * Function prototypes. | ||
| 41 | */ | ||
| 42 | int nfsd_svc(unsigned short port, int nrservs); | ||
| 43 | int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp); | ||
| 44 | |||
| 45 | int nfsd_nrthreads(void); | ||
| 46 | int nfsd_nrpools(void); | ||
| 47 | int nfsd_get_nrthreads(int n, int *); | ||
| 48 | int nfsd_set_nrthreads(int n, int *); | ||
| 49 | |||
| 50 | #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) | ||
| 51 | #ifdef CONFIG_NFSD_V2_ACL | ||
| 52 | extern struct svc_version nfsd_acl_version2; | ||
| 53 | #else | ||
| 54 | #define nfsd_acl_version2 NULL | ||
| 55 | #endif | ||
| 56 | #ifdef CONFIG_NFSD_V3_ACL | ||
| 57 | extern struct svc_version nfsd_acl_version3; | ||
| 58 | #else | ||
| 59 | #define nfsd_acl_version3 NULL | ||
| 60 | #endif | ||
| 61 | #endif | ||
| 62 | |||
| 63 | enum vers_op {NFSD_SET, NFSD_CLEAR, NFSD_TEST, NFSD_AVAIL }; | ||
| 64 | int nfsd_vers(int vers, enum vers_op change); | ||
| 65 | int nfsd_minorversion(u32 minorversion, enum vers_op change); | ||
| 66 | void nfsd_reset_versions(void); | ||
| 67 | int nfsd_create_serv(void); | ||
| 68 | |||
| 69 | extern int nfsd_max_blksize; | ||
| 70 | |||
| 71 | static inline int nfsd_v4client(struct svc_rqst *rq) | ||
| 72 | { | ||
| 73 | return rq->rq_prog == NFS_PROGRAM && rq->rq_vers == 4; | ||
| 74 | } | ||
| 75 | |||
| 76 | /* | ||
| 77 | * NFSv4 State | ||
| 78 | */ | ||
| 79 | #ifdef CONFIG_NFSD_V4 | ||
| 80 | extern unsigned int max_delegations; | ||
| 81 | int nfs4_state_init(void); | ||
| 82 | void nfsd4_free_slabs(void); | ||
| 83 | int nfs4_state_start(void); | ||
| 84 | void nfs4_state_shutdown(void); | ||
| 85 | time_t nfs4_lease_time(void); | ||
| 86 | void nfs4_reset_lease(time_t leasetime); | ||
| 87 | int nfs4_reset_recoverydir(char *recdir); | ||
| 88 | #else | ||
| 89 | static inline int nfs4_state_init(void) { return 0; } | ||
| 90 | static inline void nfsd4_free_slabs(void) { } | ||
| 91 | static inline int nfs4_state_start(void) { return 0; } | ||
| 92 | static inline void nfs4_state_shutdown(void) { } | ||
| 93 | static inline time_t nfs4_lease_time(void) { return 0; } | ||
| 94 | static inline void nfs4_reset_lease(time_t leasetime) { } | ||
| 95 | static inline int nfs4_reset_recoverydir(char *recdir) { return 0; } | ||
| 96 | #endif | ||
| 97 | |||
| 98 | /* | ||
| 99 | * lockd binding | ||
| 100 | */ | ||
| 101 | void nfsd_lockd_init(void); | ||
| 102 | void nfsd_lockd_shutdown(void); | ||
| 103 | |||
| 104 | |||
| 105 | /* | ||
| 106 | * These macros provide pre-xdr'ed values for faster operation. | ||
| 107 | */ | ||
| 108 | #define nfs_ok cpu_to_be32(NFS_OK) | ||
| 109 | #define nfserr_perm cpu_to_be32(NFSERR_PERM) | ||
| 110 | #define nfserr_noent cpu_to_be32(NFSERR_NOENT) | ||
| 111 | #define nfserr_io cpu_to_be32(NFSERR_IO) | ||
| 112 | #define nfserr_nxio cpu_to_be32(NFSERR_NXIO) | ||
| 113 | #define nfserr_eagain cpu_to_be32(NFSERR_EAGAIN) | ||
| 114 | #define nfserr_acces cpu_to_be32(NFSERR_ACCES) | ||
| 115 | #define nfserr_exist cpu_to_be32(NFSERR_EXIST) | ||
| 116 | #define nfserr_xdev cpu_to_be32(NFSERR_XDEV) | ||
| 117 | #define nfserr_nodev cpu_to_be32(NFSERR_NODEV) | ||
| 118 | #define nfserr_notdir cpu_to_be32(NFSERR_NOTDIR) | ||
| 119 | #define nfserr_isdir cpu_to_be32(NFSERR_ISDIR) | ||
| 120 | #define nfserr_inval cpu_to_be32(NFSERR_INVAL) | ||
| 121 | #define nfserr_fbig cpu_to_be32(NFSERR_FBIG) | ||
| 122 | #define nfserr_nospc cpu_to_be32(NFSERR_NOSPC) | ||
| 123 | #define nfserr_rofs cpu_to_be32(NFSERR_ROFS) | ||
| 124 | #define nfserr_mlink cpu_to_be32(NFSERR_MLINK) | ||
| 125 | #define nfserr_opnotsupp cpu_to_be32(NFSERR_OPNOTSUPP) | ||
| 126 | #define nfserr_nametoolong cpu_to_be32(NFSERR_NAMETOOLONG) | ||
| 127 | #define nfserr_notempty cpu_to_be32(NFSERR_NOTEMPTY) | ||
| 128 | #define nfserr_dquot cpu_to_be32(NFSERR_DQUOT) | ||
| 129 | #define nfserr_stale cpu_to_be32(NFSERR_STALE) | ||
| 130 | #define nfserr_remote cpu_to_be32(NFSERR_REMOTE) | ||
| 131 | #define nfserr_wflush cpu_to_be32(NFSERR_WFLUSH) | ||
| 132 | #define nfserr_badhandle cpu_to_be32(NFSERR_BADHANDLE) | ||
| 133 | #define nfserr_notsync cpu_to_be32(NFSERR_NOT_SYNC) | ||
| 134 | #define nfserr_badcookie cpu_to_be32(NFSERR_BAD_COOKIE) | ||
| 135 | #define nfserr_notsupp cpu_to_be32(NFSERR_NOTSUPP) | ||
| 136 | #define nfserr_toosmall cpu_to_be32(NFSERR_TOOSMALL) | ||
| 137 | #define nfserr_serverfault cpu_to_be32(NFSERR_SERVERFAULT) | ||
| 138 | #define nfserr_badtype cpu_to_be32(NFSERR_BADTYPE) | ||
| 139 | #define nfserr_jukebox cpu_to_be32(NFSERR_JUKEBOX) | ||
| 140 | #define nfserr_denied cpu_to_be32(NFSERR_DENIED) | ||
| 141 | #define nfserr_deadlock cpu_to_be32(NFSERR_DEADLOCK) | ||
| 142 | #define nfserr_expired cpu_to_be32(NFSERR_EXPIRED) | ||
| 143 | #define nfserr_bad_cookie cpu_to_be32(NFSERR_BAD_COOKIE) | ||
| 144 | #define nfserr_same cpu_to_be32(NFSERR_SAME) | ||
| 145 | #define nfserr_clid_inuse cpu_to_be32(NFSERR_CLID_INUSE) | ||
| 146 | #define nfserr_stale_clientid cpu_to_be32(NFSERR_STALE_CLIENTID) | ||
| 147 | #define nfserr_resource cpu_to_be32(NFSERR_RESOURCE) | ||
| 148 | #define nfserr_moved cpu_to_be32(NFSERR_MOVED) | ||
| 149 | #define nfserr_nofilehandle cpu_to_be32(NFSERR_NOFILEHANDLE) | ||
| 150 | #define nfserr_minor_vers_mismatch cpu_to_be32(NFSERR_MINOR_VERS_MISMATCH) | ||
| 151 | #define nfserr_share_denied cpu_to_be32(NFSERR_SHARE_DENIED) | ||
| 152 | #define nfserr_stale_stateid cpu_to_be32(NFSERR_STALE_STATEID) | ||
| 153 | #define nfserr_old_stateid cpu_to_be32(NFSERR_OLD_STATEID) | ||
| 154 | #define nfserr_bad_stateid cpu_to_be32(NFSERR_BAD_STATEID) | ||
| 155 | #define nfserr_bad_seqid cpu_to_be32(NFSERR_BAD_SEQID) | ||
| 156 | #define nfserr_symlink cpu_to_be32(NFSERR_SYMLINK) | ||
| 157 | #define nfserr_not_same cpu_to_be32(NFSERR_NOT_SAME) | ||
| 158 | #define nfserr_restorefh cpu_to_be32(NFSERR_RESTOREFH) | ||
| 159 | #define nfserr_attrnotsupp cpu_to_be32(NFSERR_ATTRNOTSUPP) | ||
| 160 | #define nfserr_bad_xdr cpu_to_be32(NFSERR_BAD_XDR) | ||
| 161 | #define nfserr_openmode cpu_to_be32(NFSERR_OPENMODE) | ||
| 162 | #define nfserr_locks_held cpu_to_be32(NFSERR_LOCKS_HELD) | ||
| 163 | #define nfserr_op_illegal cpu_to_be32(NFSERR_OP_ILLEGAL) | ||
| 164 | #define nfserr_grace cpu_to_be32(NFSERR_GRACE) | ||
| 165 | #define nfserr_no_grace cpu_to_be32(NFSERR_NO_GRACE) | ||
| 166 | #define nfserr_reclaim_bad cpu_to_be32(NFSERR_RECLAIM_BAD) | ||
| 167 | #define nfserr_badname cpu_to_be32(NFSERR_BADNAME) | ||
| 168 | #define nfserr_cb_path_down cpu_to_be32(NFSERR_CB_PATH_DOWN) | ||
| 169 | #define nfserr_locked cpu_to_be32(NFSERR_LOCKED) | ||
| 170 | #define nfserr_wrongsec cpu_to_be32(NFSERR_WRONGSEC) | ||
| 171 | #define nfserr_badiomode cpu_to_be32(NFS4ERR_BADIOMODE) | ||
| 172 | #define nfserr_badlayout cpu_to_be32(NFS4ERR_BADLAYOUT) | ||
| 173 | #define nfserr_bad_session_digest cpu_to_be32(NFS4ERR_BAD_SESSION_DIGEST) | ||
| 174 | #define nfserr_badsession cpu_to_be32(NFS4ERR_BADSESSION) | ||
| 175 | #define nfserr_badslot cpu_to_be32(NFS4ERR_BADSLOT) | ||
| 176 | #define nfserr_complete_already cpu_to_be32(NFS4ERR_COMPLETE_ALREADY) | ||
| 177 | #define nfserr_conn_not_bound_to_session cpu_to_be32(NFS4ERR_CONN_NOT_BOUND_TO_SESSION) | ||
| 178 | #define nfserr_deleg_already_wanted cpu_to_be32(NFS4ERR_DELEG_ALREADY_WANTED) | ||
| 179 | #define nfserr_back_chan_busy cpu_to_be32(NFS4ERR_BACK_CHAN_BUSY) | ||
| 180 | #define nfserr_layouttrylater cpu_to_be32(NFS4ERR_LAYOUTTRYLATER) | ||
| 181 | #define nfserr_layoutunavailable cpu_to_be32(NFS4ERR_LAYOUTUNAVAILABLE) | ||
| 182 | #define nfserr_nomatching_layout cpu_to_be32(NFS4ERR_NOMATCHING_LAYOUT) | ||
| 183 | #define nfserr_recallconflict cpu_to_be32(NFS4ERR_RECALLCONFLICT) | ||
| 184 | #define nfserr_unknown_layouttype cpu_to_be32(NFS4ERR_UNKNOWN_LAYOUTTYPE) | ||
| 185 | #define nfserr_seq_misordered cpu_to_be32(NFS4ERR_SEQ_MISORDERED) | ||
| 186 | #define nfserr_sequence_pos cpu_to_be32(NFS4ERR_SEQUENCE_POS) | ||
| 187 | #define nfserr_req_too_big cpu_to_be32(NFS4ERR_REQ_TOO_BIG) | ||
| 188 | #define nfserr_rep_too_big cpu_to_be32(NFS4ERR_REP_TOO_BIG) | ||
| 189 | #define nfserr_rep_too_big_to_cache cpu_to_be32(NFS4ERR_REP_TOO_BIG_TO_CACHE) | ||
| 190 | #define nfserr_retry_uncached_rep cpu_to_be32(NFS4ERR_RETRY_UNCACHED_REP) | ||
| 191 | #define nfserr_unsafe_compound cpu_to_be32(NFS4ERR_UNSAFE_COMPOUND) | ||
| 192 | #define nfserr_too_many_ops cpu_to_be32(NFS4ERR_TOO_MANY_OPS) | ||
| 193 | #define nfserr_op_not_in_session cpu_to_be32(NFS4ERR_OP_NOT_IN_SESSION) | ||
| 194 | #define nfserr_hash_alg_unsupp cpu_to_be32(NFS4ERR_HASH_ALG_UNSUPP) | ||
| 195 | #define nfserr_clientid_busy cpu_to_be32(NFS4ERR_CLIENTID_BUSY) | ||
| 196 | #define nfserr_pnfs_io_hole cpu_to_be32(NFS4ERR_PNFS_IO_HOLE) | ||
| 197 | #define nfserr_seq_false_retry cpu_to_be32(NFS4ERR_SEQ_FALSE_RETRY) | ||
| 198 | #define nfserr_bad_high_slot cpu_to_be32(NFS4ERR_BAD_HIGH_SLOT) | ||
| 199 | #define nfserr_deadsession cpu_to_be32(NFS4ERR_DEADSESSION) | ||
| 200 | #define nfserr_encr_alg_unsupp cpu_to_be32(NFS4ERR_ENCR_ALG_UNSUPP) | ||
| 201 | #define nfserr_pnfs_no_layout cpu_to_be32(NFS4ERR_PNFS_NO_LAYOUT) | ||
| 202 | #define nfserr_not_only_op cpu_to_be32(NFS4ERR_NOT_ONLY_OP) | ||
| 203 | #define nfserr_wrong_cred cpu_to_be32(NFS4ERR_WRONG_CRED) | ||
| 204 | #define nfserr_wrong_type cpu_to_be32(NFS4ERR_WRONG_TYPE) | ||
| 205 | #define nfserr_dirdeleg_unavail cpu_to_be32(NFS4ERR_DIRDELEG_UNAVAIL) | ||
| 206 | #define nfserr_reject_deleg cpu_to_be32(NFS4ERR_REJECT_DELEG) | ||
| 207 | #define nfserr_returnconflict cpu_to_be32(NFS4ERR_RETURNCONFLICT) | ||
| 208 | #define nfserr_deleg_revoked cpu_to_be32(NFS4ERR_DELEG_REVOKED) | ||
| 209 | |||
| 210 | /* error codes for internal use */ | ||
| 211 | /* if a request fails due to kmalloc failure, it gets dropped. | ||
| 212 | * Client should resend eventually | ||
| 213 | */ | ||
| 214 | #define nfserr_dropit cpu_to_be32(30000) | ||
| 215 | /* end-of-file indicator in readdir */ | ||
| 216 | #define nfserr_eof cpu_to_be32(30001) | ||
| 217 | /* replay detected */ | ||
| 218 | #define nfserr_replay_me cpu_to_be32(11001) | ||
| 219 | /* nfs41 replay detected */ | ||
| 220 | #define nfserr_replay_cache cpu_to_be32(11002) | ||
| 221 | |||
| 222 | /* Check for dir entries '.' and '..' */ | ||
| 223 | #define isdotent(n, l) (l < 3 && n[0] == '.' && (l == 1 || n[1] == '.')) | ||
| 224 | |||
| 225 | /* | ||
| 226 | * Time of server startup | ||
| 227 | */ | ||
| 228 | extern struct timeval nfssvc_boot; | ||
| 229 | |||
| 230 | #ifdef CONFIG_NFSD_V4 | ||
| 231 | |||
| 232 | /* before processing a COMPOUND operation, we have to check that there | ||
| 233 | * is enough space in the buffer for XDR encode to succeed. otherwise, | ||
| 234 | * we might process an operation with side effects, and be unable to | ||
| 235 | * tell the client that the operation succeeded. | ||
| 236 | * | ||
| 237 | * COMPOUND_SLACK_SPACE - this is the minimum bytes of buffer space | ||
| 238 | * needed to encode an "ordinary" _successful_ operation. (GETATTR, | ||
| 239 | * READ, READDIR, and READLINK have their own buffer checks.) if we | ||
| 240 | * fall below this level, we fail the next operation with NFS4ERR_RESOURCE. | ||
| 241 | * | ||
| 242 | * COMPOUND_ERR_SLACK_SPACE - this is the minimum bytes of buffer space | ||
| 243 | * needed to encode an operation which has failed with NFS4ERR_RESOURCE. | ||
| 244 | * care is taken to ensure that we never fall below this level for any | ||
| 245 | * reason. | ||
| 246 | */ | ||
| 247 | #define COMPOUND_SLACK_SPACE 140 /* OP_GETFH */ | ||
| 248 | #define COMPOUND_ERR_SLACK_SPACE 12 /* OP_SETATTR */ | ||
| 249 | |||
| 250 | #define NFSD_LEASE_TIME (nfs4_lease_time()) | ||
| 251 | #define NFSD_LAUNDROMAT_MINTIMEOUT 10 /* seconds */ | ||
| 252 | |||
| 253 | /* | ||
| 254 | * The following attributes are currently not supported by the NFSv4 server: | ||
| 255 | * ARCHIVE (deprecated anyway) | ||
| 256 | * HIDDEN (unlikely to be supported any time soon) | ||
| 257 | * MIMETYPE (unlikely to be supported any time soon) | ||
| 258 | * QUOTA_* (will be supported in a forthcoming patch) | ||
| 259 | * SYSTEM (unlikely to be supported any time soon) | ||
| 260 | * TIME_BACKUP (unlikely to be supported any time soon) | ||
| 261 | * TIME_CREATE (unlikely to be supported any time soon) | ||
| 262 | */ | ||
| 263 | #define NFSD4_SUPPORTED_ATTRS_WORD0 \ | ||
| 264 | (FATTR4_WORD0_SUPPORTED_ATTRS | FATTR4_WORD0_TYPE | FATTR4_WORD0_FH_EXPIRE_TYPE \ | ||
| 265 | | FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE | FATTR4_WORD0_LINK_SUPPORT \ | ||
| 266 | | FATTR4_WORD0_SYMLINK_SUPPORT | FATTR4_WORD0_NAMED_ATTR | FATTR4_WORD0_FSID \ | ||
| 267 | | FATTR4_WORD0_UNIQUE_HANDLES | FATTR4_WORD0_LEASE_TIME | FATTR4_WORD0_RDATTR_ERROR \ | ||
| 268 | | FATTR4_WORD0_ACLSUPPORT | FATTR4_WORD0_CANSETTIME | FATTR4_WORD0_CASE_INSENSITIVE \ | ||
| 269 | | FATTR4_WORD0_CASE_PRESERVING | FATTR4_WORD0_CHOWN_RESTRICTED \ | ||
| 270 | | FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FILEID | FATTR4_WORD0_FILES_AVAIL \ | ||
| 271 | | FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_FS_LOCATIONS | FATTR4_WORD0_HOMOGENEOUS \ | ||
| 272 | | FATTR4_WORD0_MAXFILESIZE | FATTR4_WORD0_MAXLINK | FATTR4_WORD0_MAXNAME \ | ||
| 273 | | FATTR4_WORD0_MAXREAD | FATTR4_WORD0_MAXWRITE | FATTR4_WORD0_ACL) | ||
| 274 | |||
| 275 | #define NFSD4_SUPPORTED_ATTRS_WORD1 \ | ||
| 276 | (FATTR4_WORD1_MODE | FATTR4_WORD1_NO_TRUNC | FATTR4_WORD1_NUMLINKS \ | ||
| 277 | | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP | FATTR4_WORD1_RAWDEV \ | ||
| 278 | | FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE | FATTR4_WORD1_SPACE_TOTAL \ | ||
| 279 | | FATTR4_WORD1_SPACE_USED | FATTR4_WORD1_TIME_ACCESS | FATTR4_WORD1_TIME_ACCESS_SET \ | ||
| 280 | | FATTR4_WORD1_TIME_DELTA | FATTR4_WORD1_TIME_METADATA \ | ||
| 281 | | FATTR4_WORD1_TIME_MODIFY | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID) | ||
| 282 | |||
| 283 | #define NFSD4_SUPPORTED_ATTRS_WORD2 0 | ||
| 284 | |||
| 285 | #define NFSD4_1_SUPPORTED_ATTRS_WORD0 \ | ||
| 286 | NFSD4_SUPPORTED_ATTRS_WORD0 | ||
| 287 | |||
| 288 | #define NFSD4_1_SUPPORTED_ATTRS_WORD1 \ | ||
| 289 | NFSD4_SUPPORTED_ATTRS_WORD1 | ||
| 290 | |||
| 291 | #define NFSD4_1_SUPPORTED_ATTRS_WORD2 \ | ||
| 292 | (NFSD4_SUPPORTED_ATTRS_WORD2 | FATTR4_WORD2_SUPPATTR_EXCLCREAT) | ||
| 293 | |||
| 294 | static inline u32 nfsd_suppattrs0(u32 minorversion) | ||
| 295 | { | ||
| 296 | return minorversion ? NFSD4_1_SUPPORTED_ATTRS_WORD0 | ||
| 297 | : NFSD4_SUPPORTED_ATTRS_WORD0; | ||
| 298 | } | ||
| 299 | |||
| 300 | static inline u32 nfsd_suppattrs1(u32 minorversion) | ||
| 301 | { | ||
| 302 | return minorversion ? NFSD4_1_SUPPORTED_ATTRS_WORD1 | ||
| 303 | : NFSD4_SUPPORTED_ATTRS_WORD1; | ||
| 304 | } | ||
| 305 | |||
| 306 | static inline u32 nfsd_suppattrs2(u32 minorversion) | ||
| 307 | { | ||
| 308 | return minorversion ? NFSD4_1_SUPPORTED_ATTRS_WORD2 | ||
| 309 | : NFSD4_SUPPORTED_ATTRS_WORD2; | ||
| 310 | } | ||
| 311 | |||
| 312 | /* These will return ERR_INVAL if specified in GETATTR or READDIR. */ | ||
| 313 | #define NFSD_WRITEONLY_ATTRS_WORD1 \ | ||
| 314 | (FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET) | ||
| 315 | |||
| 316 | /* These are the only attrs allowed in CREATE/OPEN/SETATTR. */ | ||
| 317 | #define NFSD_WRITEABLE_ATTRS_WORD0 \ | ||
| 318 | (FATTR4_WORD0_SIZE | FATTR4_WORD0_ACL ) | ||
| 319 | #define NFSD_WRITEABLE_ATTRS_WORD1 \ | ||
| 320 | (FATTR4_WORD1_MODE | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP \ | ||
| 321 | | FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET) | ||
| 322 | #define NFSD_WRITEABLE_ATTRS_WORD2 0 | ||
| 323 | |||
| 324 | #define NFSD_SUPPATTR_EXCLCREAT_WORD0 \ | ||
| 325 | NFSD_WRITEABLE_ATTRS_WORD0 | ||
| 326 | /* | ||
| 327 | * we currently store the exclusive create verifier in the v_{a,m}time | ||
| 328 | * attributes so the client can't set these at create time using EXCLUSIVE4_1 | ||
| 329 | */ | ||
| 330 | #define NFSD_SUPPATTR_EXCLCREAT_WORD1 \ | ||
| 331 | (NFSD_WRITEABLE_ATTRS_WORD1 & \ | ||
| 332 | ~(FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET)) | ||
| 333 | #define NFSD_SUPPATTR_EXCLCREAT_WORD2 \ | ||
| 334 | NFSD_WRITEABLE_ATTRS_WORD2 | ||
| 335 | |||
| 336 | #endif /* CONFIG_NFSD_V4 */ | ||
| 337 | |||
| 338 | #endif /* LINUX_NFSD_NFSD_H */ | ||
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index 01965b2f3a76..1c12177b908c 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/nfsd/nfsfh.c | ||
| 3 | * | ||
| 4 | * NFS server file handle treatment. | 2 | * NFS server file handle treatment. |
| 5 | * | 3 | * |
| 6 | * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> | 4 | * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> |
| @@ -9,19 +7,11 @@ | |||
| 9 | * ... and again Southern-Winter 2001 to support export_operations | 7 | * ... and again Southern-Winter 2001 to support export_operations |
| 10 | */ | 8 | */ |
| 11 | 9 | ||
| 12 | #include <linux/slab.h> | ||
| 13 | #include <linux/fs.h> | ||
| 14 | #include <linux/unistd.h> | ||
| 15 | #include <linux/string.h> | ||
| 16 | #include <linux/stat.h> | ||
| 17 | #include <linux/dcache.h> | ||
| 18 | #include <linux/exportfs.h> | 10 | #include <linux/exportfs.h> |
| 19 | #include <linux/mount.h> | ||
| 20 | 11 | ||
| 21 | #include <linux/sunrpc/clnt.h> | ||
| 22 | #include <linux/sunrpc/svc.h> | ||
| 23 | #include <linux/sunrpc/svcauth_gss.h> | 12 | #include <linux/sunrpc/svcauth_gss.h> |
| 24 | #include <linux/nfsd/nfsd.h> | 13 | #include "nfsd.h" |
| 14 | #include "vfs.h" | ||
| 25 | #include "auth.h" | 15 | #include "auth.h" |
| 26 | 16 | ||
| 27 | #define NFSDDBG_FACILITY NFSDDBG_FH | 17 | #define NFSDDBG_FACILITY NFSDDBG_FH |
| @@ -96,8 +86,10 @@ nfsd_mode_check(struct svc_rqst *rqstp, umode_t mode, int type) | |||
| 96 | static __be32 nfsd_setuser_and_check_port(struct svc_rqst *rqstp, | 86 | static __be32 nfsd_setuser_and_check_port(struct svc_rqst *rqstp, |
| 97 | struct svc_export *exp) | 87 | struct svc_export *exp) |
| 98 | { | 88 | { |
| 89 | int flags = nfsexp_flags(rqstp, exp); | ||
| 90 | |||
| 99 | /* Check if the request originated from a secure port. */ | 91 | /* Check if the request originated from a secure port. */ |
| 100 | if (!rqstp->rq_secure && EX_SECURE(exp)) { | 92 | if (!rqstp->rq_secure && (flags & NFSEXP_INSECURE_PORT)) { |
| 101 | RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]); | 93 | RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]); |
| 102 | dprintk(KERN_WARNING | 94 | dprintk(KERN_WARNING |
| 103 | "nfsd: request from insecure port %s!\n", | 95 | "nfsd: request from insecure port %s!\n", |
| @@ -109,6 +101,36 @@ static __be32 nfsd_setuser_and_check_port(struct svc_rqst *rqstp, | |||
| 109 | return nfserrno(nfsd_setuser(rqstp, exp)); | 101 | return nfserrno(nfsd_setuser(rqstp, exp)); |
| 110 | } | 102 | } |
| 111 | 103 | ||
| 104 | static inline __be32 check_pseudo_root(struct svc_rqst *rqstp, | ||
| 105 | struct dentry *dentry, struct svc_export *exp) | ||
| 106 | { | ||
| 107 | if (!(exp->ex_flags & NFSEXP_V4ROOT)) | ||
| 108 | return nfs_ok; | ||
| 109 | /* | ||
| 110 | * v2/v3 clients have no need for the V4ROOT export--they use | ||
| 111 | * the mount protocl instead; also, further V4ROOT checks may be | ||
| 112 | * in v4-specific code, in which case v2/v3 clients could bypass | ||
| 113 | * them. | ||
| 114 | */ | ||
| 115 | if (!nfsd_v4client(rqstp)) | ||
| 116 | return nfserr_stale; | ||
| 117 | /* | ||
| 118 | * We're exposing only the directories and symlinks that have to be | ||
| 119 | * traversed on the way to real exports: | ||
| 120 | */ | ||
| 121 | if (unlikely(!S_ISDIR(dentry->d_inode->i_mode) && | ||
| 122 | !S_ISLNK(dentry->d_inode->i_mode))) | ||
| 123 | return nfserr_stale; | ||
| 124 | /* | ||
| 125 | * A pseudoroot export gives permission to access only one | ||
| 126 | * single directory; the kernel has to make another upcall | ||
| 127 | * before granting access to anything else under it: | ||
| 128 | */ | ||
| 129 | if (unlikely(dentry != exp->ex_path.dentry)) | ||
| 130 | return nfserr_stale; | ||
| 131 | return nfs_ok; | ||
| 132 | } | ||
| 133 | |||
| 112 | /* | 134 | /* |
| 113 | * Use the given filehandle to look up the corresponding export and | 135 | * Use the given filehandle to look up the corresponding export and |
| 114 | * dentry. On success, the results are used to set fh_export and | 136 | * dentry. On success, the results are used to set fh_export and |
| @@ -232,14 +254,6 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp) | |||
| 232 | goto out; | 254 | goto out; |
| 233 | } | 255 | } |
| 234 | 256 | ||
| 235 | if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) { | ||
| 236 | error = nfsd_setuser_and_check_port(rqstp, exp); | ||
| 237 | if (error) { | ||
| 238 | dput(dentry); | ||
| 239 | goto out; | ||
| 240 | } | ||
| 241 | } | ||
| 242 | |||
| 243 | if (S_ISDIR(dentry->d_inode->i_mode) && | 257 | if (S_ISDIR(dentry->d_inode->i_mode) && |
| 244 | (dentry->d_flags & DCACHE_DISCONNECTED)) { | 258 | (dentry->d_flags & DCACHE_DISCONNECTED)) { |
| 245 | printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %s/%s\n", | 259 | printk("nfsd: find_fh_dentry returned a DISCONNECTED directory: %s/%s\n", |
| @@ -294,28 +308,32 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access) | |||
| 294 | error = nfsd_set_fh_dentry(rqstp, fhp); | 308 | error = nfsd_set_fh_dentry(rqstp, fhp); |
| 295 | if (error) | 309 | if (error) |
| 296 | goto out; | 310 | goto out; |
| 297 | dentry = fhp->fh_dentry; | ||
| 298 | exp = fhp->fh_export; | ||
| 299 | } else { | ||
| 300 | /* | ||
| 301 | * just rechecking permissions | ||
| 302 | * (e.g. nfsproc_create calls fh_verify, then nfsd_create | ||
| 303 | * does as well) | ||
| 304 | */ | ||
| 305 | dprintk("nfsd: fh_verify - just checking\n"); | ||
| 306 | dentry = fhp->fh_dentry; | ||
| 307 | exp = fhp->fh_export; | ||
| 308 | /* | ||
| 309 | * Set user creds for this exportpoint; necessary even | ||
| 310 | * in the "just checking" case because this may be a | ||
| 311 | * filehandle that was created by fh_compose, and that | ||
| 312 | * is about to be used in another nfsv4 compound | ||
| 313 | * operation. | ||
| 314 | */ | ||
| 315 | error = nfsd_setuser_and_check_port(rqstp, exp); | ||
| 316 | if (error) | ||
| 317 | goto out; | ||
| 318 | } | 311 | } |
| 312 | dentry = fhp->fh_dentry; | ||
| 313 | exp = fhp->fh_export; | ||
| 314 | /* | ||
| 315 | * We still have to do all these permission checks, even when | ||
| 316 | * fh_dentry is already set: | ||
| 317 | * - fh_verify may be called multiple times with different | ||
| 318 | * "access" arguments (e.g. nfsd_proc_create calls | ||
| 319 | * fh_verify(...,NFSD_MAY_EXEC) first, then later (in | ||
| 320 | * nfsd_create) calls fh_verify(...,NFSD_MAY_CREATE). | ||
| 321 | * - in the NFSv4 case, the filehandle may have been filled | ||
| 322 | * in by fh_compose, and given a dentry, but further | ||
| 323 | * compound operations performed with that filehandle | ||
| 324 | * still need permissions checks. In the worst case, a | ||
| 325 | * mountpoint crossing may have changed the export | ||
| 326 | * options, and we may now need to use a different uid | ||
| 327 | * (for example, if different id-squashing options are in | ||
| 328 | * effect on the new filesystem). | ||
| 329 | */ | ||
| 330 | error = check_pseudo_root(rqstp, dentry, exp); | ||
| 331 | if (error) | ||
| 332 | goto out; | ||
| 333 | |||
| 334 | error = nfsd_setuser_and_check_port(rqstp, exp); | ||
| 335 | if (error) | ||
| 336 | goto out; | ||
| 319 | 337 | ||
| 320 | error = nfsd_mode_check(rqstp, dentry->d_inode->i_mode, type); | 338 | error = nfsd_mode_check(rqstp, dentry->d_inode->i_mode, type); |
| 321 | if (error) | 339 | if (error) |
diff --git a/fs/nfsd/nfsfh.h b/fs/nfsd/nfsfh.h new file mode 100644 index 000000000000..cdfb8c6a4206 --- /dev/null +++ b/fs/nfsd/nfsfh.h | |||
| @@ -0,0 +1,208 @@ | |||
| 1 | /* Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> */ | ||
| 2 | |||
| 3 | #ifndef _LINUX_NFSD_FH_INT_H | ||
| 4 | #define _LINUX_NFSD_FH_INT_H | ||
| 5 | |||
| 6 | #include <linux/nfsd/nfsfh.h> | ||
| 7 | |||
| 8 | enum nfsd_fsid { | ||
| 9 | FSID_DEV = 0, | ||
| 10 | FSID_NUM, | ||
| 11 | FSID_MAJOR_MINOR, | ||
| 12 | FSID_ENCODE_DEV, | ||
| 13 | FSID_UUID4_INUM, | ||
| 14 | FSID_UUID8, | ||
| 15 | FSID_UUID16, | ||
| 16 | FSID_UUID16_INUM, | ||
| 17 | }; | ||
| 18 | |||
| 19 | enum fsid_source { | ||
| 20 | FSIDSOURCE_DEV, | ||
| 21 | FSIDSOURCE_FSID, | ||
| 22 | FSIDSOURCE_UUID, | ||
| 23 | }; | ||
| 24 | extern enum fsid_source fsid_source(struct svc_fh *fhp); | ||
| 25 | |||
| 26 | |||
| 27 | /* This might look a little large to "inline" but in all calls except | ||
| 28 | * one, 'vers' is constant so moste of the function disappears. | ||
| 29 | */ | ||
| 30 | static inline void mk_fsid(int vers, u32 *fsidv, dev_t dev, ino_t ino, | ||
| 31 | u32 fsid, unsigned char *uuid) | ||
| 32 | { | ||
| 33 | u32 *up; | ||
| 34 | switch(vers) { | ||
| 35 | case FSID_DEV: | ||
| 36 | fsidv[0] = htonl((MAJOR(dev)<<16) | | ||
| 37 | MINOR(dev)); | ||
| 38 | fsidv[1] = ino_t_to_u32(ino); | ||
| 39 | break; | ||
| 40 | case FSID_NUM: | ||
| 41 | fsidv[0] = fsid; | ||
| 42 | break; | ||
| 43 | case FSID_MAJOR_MINOR: | ||
| 44 | fsidv[0] = htonl(MAJOR(dev)); | ||
| 45 | fsidv[1] = htonl(MINOR(dev)); | ||
| 46 | fsidv[2] = ino_t_to_u32(ino); | ||
| 47 | break; | ||
| 48 | |||
| 49 | case FSID_ENCODE_DEV: | ||
| 50 | fsidv[0] = new_encode_dev(dev); | ||
| 51 | fsidv[1] = ino_t_to_u32(ino); | ||
| 52 | break; | ||
| 53 | |||
| 54 | case FSID_UUID4_INUM: | ||
| 55 | /* 4 byte fsid and inode number */ | ||
| 56 | up = (u32*)uuid; | ||
| 57 | fsidv[0] = ino_t_to_u32(ino); | ||
| 58 | fsidv[1] = up[0] ^ up[1] ^ up[2] ^ up[3]; | ||
| 59 | break; | ||
| 60 | |||
| 61 | case FSID_UUID8: | ||
| 62 | /* 8 byte fsid */ | ||
| 63 | up = (u32*)uuid; | ||
| 64 | fsidv[0] = up[0] ^ up[2]; | ||
| 65 | fsidv[1] = up[1] ^ up[3]; | ||
| 66 | break; | ||
| 67 | |||
| 68 | case FSID_UUID16: | ||
| 69 | /* 16 byte fsid - NFSv3+ only */ | ||
| 70 | memcpy(fsidv, uuid, 16); | ||
| 71 | break; | ||
| 72 | |||
| 73 | case FSID_UUID16_INUM: | ||
| 74 | /* 8 byte inode and 16 byte fsid */ | ||
| 75 | *(u64*)fsidv = (u64)ino; | ||
| 76 | memcpy(fsidv+2, uuid, 16); | ||
| 77 | break; | ||
| 78 | default: BUG(); | ||
| 79 | } | ||
| 80 | } | ||
| 81 | |||
| 82 | static inline int key_len(int type) | ||
| 83 | { | ||
| 84 | switch(type) { | ||
| 85 | case FSID_DEV: return 8; | ||
| 86 | case FSID_NUM: return 4; | ||
| 87 | case FSID_MAJOR_MINOR: return 12; | ||
| 88 | case FSID_ENCODE_DEV: return 8; | ||
| 89 | case FSID_UUID4_INUM: return 8; | ||
| 90 | case FSID_UUID8: return 8; | ||
| 91 | case FSID_UUID16: return 16; | ||
| 92 | case FSID_UUID16_INUM: return 24; | ||
| 93 | default: return 0; | ||
| 94 | } | ||
| 95 | } | ||
| 96 | |||
| 97 | /* | ||
| 98 | * Shorthand for dprintk()'s | ||
| 99 | */ | ||
| 100 | extern char * SVCFH_fmt(struct svc_fh *fhp); | ||
| 101 | |||
| 102 | /* | ||
| 103 | * Function prototypes | ||
| 104 | */ | ||
| 105 | __be32 fh_verify(struct svc_rqst *, struct svc_fh *, int, int); | ||
| 106 | __be32 fh_compose(struct svc_fh *, struct svc_export *, struct dentry *, struct svc_fh *); | ||
| 107 | __be32 fh_update(struct svc_fh *); | ||
| 108 | void fh_put(struct svc_fh *); | ||
| 109 | |||
| 110 | static __inline__ struct svc_fh * | ||
| 111 | fh_copy(struct svc_fh *dst, struct svc_fh *src) | ||
| 112 | { | ||
| 113 | WARN_ON(src->fh_dentry || src->fh_locked); | ||
| 114 | |||
| 115 | *dst = *src; | ||
| 116 | return dst; | ||
| 117 | } | ||
| 118 | |||
| 119 | static inline void | ||
| 120 | fh_copy_shallow(struct knfsd_fh *dst, struct knfsd_fh *src) | ||
| 121 | { | ||
| 122 | dst->fh_size = src->fh_size; | ||
| 123 | memcpy(&dst->fh_base, &src->fh_base, src->fh_size); | ||
| 124 | } | ||
| 125 | |||
| 126 | static __inline__ struct svc_fh * | ||
| 127 | fh_init(struct svc_fh *fhp, int maxsize) | ||
| 128 | { | ||
| 129 | memset(fhp, 0, sizeof(*fhp)); | ||
| 130 | fhp->fh_maxsize = maxsize; | ||
| 131 | return fhp; | ||
| 132 | } | ||
| 133 | |||
| 134 | #ifdef CONFIG_NFSD_V3 | ||
| 135 | /* | ||
| 136 | * Fill in the pre_op attr for the wcc data | ||
| 137 | */ | ||
| 138 | static inline void | ||
| 139 | fill_pre_wcc(struct svc_fh *fhp) | ||
| 140 | { | ||
| 141 | struct inode *inode; | ||
| 142 | |||
| 143 | inode = fhp->fh_dentry->d_inode; | ||
| 144 | if (!fhp->fh_pre_saved) { | ||
| 145 | fhp->fh_pre_mtime = inode->i_mtime; | ||
| 146 | fhp->fh_pre_ctime = inode->i_ctime; | ||
| 147 | fhp->fh_pre_size = inode->i_size; | ||
| 148 | fhp->fh_pre_change = inode->i_version; | ||
| 149 | fhp->fh_pre_saved = 1; | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | extern void fill_post_wcc(struct svc_fh *); | ||
| 154 | #else | ||
| 155 | #define fill_pre_wcc(ignored) | ||
| 156 | #define fill_post_wcc(notused) | ||
| 157 | #endif /* CONFIG_NFSD_V3 */ | ||
| 158 | |||
| 159 | |||
| 160 | /* | ||
| 161 | * Lock a file handle/inode | ||
| 162 | * NOTE: both fh_lock and fh_unlock are done "by hand" in | ||
| 163 | * vfs.c:nfsd_rename as it needs to grab 2 i_mutex's at once | ||
| 164 | * so, any changes here should be reflected there. | ||
| 165 | */ | ||
| 166 | |||
| 167 | static inline void | ||
| 168 | fh_lock_nested(struct svc_fh *fhp, unsigned int subclass) | ||
| 169 | { | ||
| 170 | struct dentry *dentry = fhp->fh_dentry; | ||
| 171 | struct inode *inode; | ||
| 172 | |||
| 173 | BUG_ON(!dentry); | ||
| 174 | |||
| 175 | if (fhp->fh_locked) { | ||
| 176 | printk(KERN_WARNING "fh_lock: %s/%s already locked!\n", | ||
| 177 | dentry->d_parent->d_name.name, dentry->d_name.name); | ||
| 178 | return; | ||
| 179 | } | ||
| 180 | |||
| 181 | inode = dentry->d_inode; | ||
| 182 | mutex_lock_nested(&inode->i_mutex, subclass); | ||
| 183 | fill_pre_wcc(fhp); | ||
| 184 | fhp->fh_locked = 1; | ||
| 185 | } | ||
| 186 | |||
| 187 | static inline void | ||
| 188 | fh_lock(struct svc_fh *fhp) | ||
| 189 | { | ||
| 190 | fh_lock_nested(fhp, I_MUTEX_NORMAL); | ||
| 191 | } | ||
| 192 | |||
| 193 | /* | ||
| 194 | * Unlock a file handle/inode | ||
| 195 | */ | ||
| 196 | static inline void | ||
| 197 | fh_unlock(struct svc_fh *fhp) | ||
| 198 | { | ||
| 199 | BUG_ON(!fhp->fh_dentry); | ||
| 200 | |||
| 201 | if (fhp->fh_locked) { | ||
| 202 | fill_post_wcc(fhp); | ||
| 203 | mutex_unlock(&fhp->fh_dentry->d_inode->i_mutex); | ||
| 204 | fhp->fh_locked = 0; | ||
| 205 | } | ||
| 206 | } | ||
| 207 | |||
| 208 | #endif /* _LINUX_NFSD_FH_INT_H */ | ||
diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index 0eb9c820b7a6..a047ad6111ef 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c | |||
| @@ -1,29 +1,14 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * nfsproc2.c Process version 2 NFS requests. | ||
| 3 | * linux/fs/nfsd/nfs2proc.c | ||
| 4 | * | ||
| 5 | * Process version 2 NFS requests. | 2 | * Process version 2 NFS requests. |
| 6 | * | 3 | * |
| 7 | * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de> | 4 | * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de> |
| 8 | */ | 5 | */ |
| 9 | 6 | ||
| 10 | #include <linux/linkage.h> | ||
| 11 | #include <linux/time.h> | ||
| 12 | #include <linux/errno.h> | ||
| 13 | #include <linux/fs.h> | ||
| 14 | #include <linux/stat.h> | ||
| 15 | #include <linux/fcntl.h> | ||
| 16 | #include <linux/net.h> | ||
| 17 | #include <linux/in.h> | ||
| 18 | #include <linux/namei.h> | 7 | #include <linux/namei.h> |
| 19 | #include <linux/unistd.h> | ||
| 20 | #include <linux/slab.h> | ||
| 21 | 8 | ||
| 22 | #include <linux/sunrpc/clnt.h> | 9 | #include "cache.h" |
| 23 | #include <linux/sunrpc/svc.h> | 10 | #include "xdr.h" |
| 24 | #include <linux/nfsd/nfsd.h> | 11 | #include "vfs.h" |
| 25 | #include <linux/nfsd/cache.h> | ||
| 26 | #include <linux/nfsd/xdr.h> | ||
| 27 | 12 | ||
| 28 | typedef struct svc_rqst svc_rqst; | 13 | typedef struct svc_rqst svc_rqst; |
| 29 | typedef struct svc_buf svc_buf; | 14 | typedef struct svc_buf svc_buf; |
| @@ -758,6 +743,7 @@ nfserrno (int errno) | |||
| 758 | { nfserr_io, -ETXTBSY }, | 743 | { nfserr_io, -ETXTBSY }, |
| 759 | { nfserr_notsupp, -EOPNOTSUPP }, | 744 | { nfserr_notsupp, -EOPNOTSUPP }, |
| 760 | { nfserr_toosmall, -ETOOSMALL }, | 745 | { nfserr_toosmall, -ETOOSMALL }, |
| 746 | { nfserr_serverfault, -ESERVERFAULT }, | ||
| 761 | }; | 747 | }; |
| 762 | int i; | 748 | int i; |
| 763 | 749 | ||
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 67ea83eedd43..171699eb07c8 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/nfsd/nfssvc.c | ||
| 3 | * | ||
| 4 | * Central processing for nfsd. | 2 | * Central processing for nfsd. |
| 5 | * | 3 | * |
| 6 | * Authors: Olaf Kirch (okir@monad.swb.de) | 4 | * Authors: Olaf Kirch (okir@monad.swb.de) |
| @@ -8,33 +6,19 @@ | |||
| 8 | * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> | 6 | * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> |
| 9 | */ | 7 | */ |
| 10 | 8 | ||
| 11 | #include <linux/module.h> | ||
| 12 | #include <linux/sched.h> | 9 | #include <linux/sched.h> |
| 13 | #include <linux/time.h> | ||
| 14 | #include <linux/errno.h> | ||
| 15 | #include <linux/nfs.h> | ||
| 16 | #include <linux/in.h> | ||
| 17 | #include <linux/uio.h> | ||
| 18 | #include <linux/unistd.h> | ||
| 19 | #include <linux/slab.h> | ||
| 20 | #include <linux/smp.h> | ||
| 21 | #include <linux/freezer.h> | 10 | #include <linux/freezer.h> |
| 22 | #include <linux/fs_struct.h> | 11 | #include <linux/fs_struct.h> |
| 23 | #include <linux/kthread.h> | ||
| 24 | #include <linux/swap.h> | 12 | #include <linux/swap.h> |
| 25 | 13 | ||
| 26 | #include <linux/sunrpc/types.h> | ||
| 27 | #include <linux/sunrpc/stats.h> | 14 | #include <linux/sunrpc/stats.h> |
| 28 | #include <linux/sunrpc/svc.h> | ||
| 29 | #include <linux/sunrpc/svcsock.h> | 15 | #include <linux/sunrpc/svcsock.h> |
| 30 | #include <linux/sunrpc/cache.h> | ||
| 31 | #include <linux/nfsd/nfsd.h> | ||
| 32 | #include <linux/nfsd/stats.h> | ||
| 33 | #include <linux/nfsd/cache.h> | ||
| 34 | #include <linux/nfsd/syscall.h> | ||
| 35 | #include <linux/lockd/bind.h> | 16 | #include <linux/lockd/bind.h> |
| 36 | #include <linux/nfsacl.h> | 17 | #include <linux/nfsacl.h> |
| 37 | #include <linux/seq_file.h> | 18 | #include <linux/seq_file.h> |
| 19 | #include "nfsd.h" | ||
| 20 | #include "cache.h" | ||
| 21 | #include "vfs.h" | ||
| 38 | 22 | ||
| 39 | #define NFSDDBG_FACILITY NFSDDBG_SVC | 23 | #define NFSDDBG_FACILITY NFSDDBG_SVC |
| 40 | 24 | ||
diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index afd08e2c90a5..4ce005dbf3e6 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c | |||
| @@ -1,20 +1,10 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/nfsd/nfsxdr.c | ||
| 3 | * | ||
| 4 | * XDR support for nfsd | 2 | * XDR support for nfsd |
| 5 | * | 3 | * |
| 6 | * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> | 4 | * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> |
| 7 | */ | 5 | */ |
| 8 | 6 | ||
| 9 | #include <linux/types.h> | 7 | #include "xdr.h" |
| 10 | #include <linux/time.h> | ||
| 11 | #include <linux/nfs.h> | ||
| 12 | #include <linux/vfs.h> | ||
| 13 | #include <linux/sunrpc/xdr.h> | ||
| 14 | #include <linux/sunrpc/svc.h> | ||
| 15 | #include <linux/nfsd/nfsd.h> | ||
| 16 | #include <linux/nfsd/xdr.h> | ||
| 17 | #include <linux/mm.h> | ||
| 18 | #include "auth.h" | 8 | #include "auth.h" |
| 19 | 9 | ||
| 20 | #define NFSDDBG_FACILITY NFSDDBG_XDR | 10 | #define NFSDDBG_FACILITY NFSDDBG_XDR |
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h new file mode 100644 index 000000000000..fefeae27f25e --- /dev/null +++ b/fs/nfsd/state.h | |||
| @@ -0,0 +1,408 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2001 The Regents of the University of Michigan. | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * Kendrick Smith <kmsmith@umich.edu> | ||
| 6 | * Andy Adamson <andros@umich.edu> | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 15 | * notice, this list of conditions and the following disclaimer in the | ||
| 16 | * documentation and/or other materials provided with the distribution. | ||
| 17 | * 3. Neither the name of the University nor the names of its | ||
| 18 | * contributors may be used to endorse or promote products derived | ||
| 19 | * from this software without specific prior written permission. | ||
| 20 | * | ||
| 21 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
| 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| 24 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
| 28 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
| 29 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
| 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
| 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 32 | * | ||
| 33 | */ | ||
| 34 | |||
| 35 | #ifndef _NFSD4_STATE_H | ||
| 36 | #define _NFSD4_STATE_H | ||
| 37 | |||
| 38 | #include <linux/nfsd/nfsfh.h> | ||
| 39 | #include "nfsfh.h" | ||
| 40 | |||
| 41 | typedef struct { | ||
| 42 | u32 cl_boot; | ||
| 43 | u32 cl_id; | ||
| 44 | } clientid_t; | ||
| 45 | |||
| 46 | typedef struct { | ||
| 47 | u32 so_boot; | ||
| 48 | u32 so_stateownerid; | ||
| 49 | u32 so_fileid; | ||
| 50 | } stateid_opaque_t; | ||
| 51 | |||
| 52 | typedef struct { | ||
| 53 | u32 si_generation; | ||
| 54 | stateid_opaque_t si_opaque; | ||
| 55 | } stateid_t; | ||
| 56 | #define si_boot si_opaque.so_boot | ||
| 57 | #define si_stateownerid si_opaque.so_stateownerid | ||
| 58 | #define si_fileid si_opaque.so_fileid | ||
| 59 | |||
| 60 | #define STATEID_FMT "(%08x/%08x/%08x/%08x)" | ||
| 61 | #define STATEID_VAL(s) \ | ||
| 62 | (s)->si_boot, \ | ||
| 63 | (s)->si_stateownerid, \ | ||
| 64 | (s)->si_fileid, \ | ||
| 65 | (s)->si_generation | ||
| 66 | |||
| 67 | struct nfsd4_cb_sequence { | ||
| 68 | /* args/res */ | ||
| 69 | u32 cbs_minorversion; | ||
| 70 | struct nfs4_client *cbs_clp; | ||
| 71 | }; | ||
| 72 | |||
| 73 | struct nfs4_delegation { | ||
| 74 | struct list_head dl_perfile; | ||
| 75 | struct list_head dl_perclnt; | ||
| 76 | struct list_head dl_recall_lru; /* delegation recalled */ | ||
| 77 | atomic_t dl_count; /* ref count */ | ||
| 78 | struct nfs4_client *dl_client; | ||
| 79 | struct nfs4_file *dl_file; | ||
| 80 | struct file_lock *dl_flock; | ||
| 81 | struct file *dl_vfs_file; | ||
| 82 | u32 dl_type; | ||
| 83 | time_t dl_time; | ||
| 84 | /* For recall: */ | ||
| 85 | u32 dl_ident; | ||
| 86 | stateid_t dl_stateid; | ||
| 87 | struct knfsd_fh dl_fh; | ||
| 88 | int dl_retries; | ||
| 89 | }; | ||
| 90 | |||
| 91 | /* client delegation callback info */ | ||
| 92 | struct nfs4_cb_conn { | ||
| 93 | /* SETCLIENTID info */ | ||
| 94 | struct sockaddr_storage cb_addr; | ||
| 95 | size_t cb_addrlen; | ||
| 96 | u32 cb_prog; | ||
| 97 | u32 cb_minorversion; | ||
| 98 | u32 cb_ident; /* minorversion 0 only */ | ||
| 99 | /* RPC client info */ | ||
| 100 | atomic_t cb_set; /* successful CB_NULL call */ | ||
| 101 | struct rpc_clnt * cb_client; | ||
| 102 | }; | ||
| 103 | |||
| 104 | /* Maximum number of slots per session. 160 is useful for long haul TCP */ | ||
| 105 | #define NFSD_MAX_SLOTS_PER_SESSION 160 | ||
| 106 | /* Maximum number of operations per session compound */ | ||
| 107 | #define NFSD_MAX_OPS_PER_COMPOUND 16 | ||
| 108 | /* Maximum session per slot cache size */ | ||
| 109 | #define NFSD_SLOT_CACHE_SIZE 1024 | ||
| 110 | /* Maximum number of NFSD_SLOT_CACHE_SIZE slots per session */ | ||
| 111 | #define NFSD_CACHE_SIZE_SLOTS_PER_SESSION 32 | ||
| 112 | #define NFSD_MAX_MEM_PER_SESSION \ | ||
| 113 | (NFSD_CACHE_SIZE_SLOTS_PER_SESSION * NFSD_SLOT_CACHE_SIZE) | ||
| 114 | |||
| 115 | struct nfsd4_slot { | ||
| 116 | bool sl_inuse; | ||
| 117 | bool sl_cachethis; | ||
| 118 | u16 sl_opcnt; | ||
| 119 | u32 sl_seqid; | ||
| 120 | __be32 sl_status; | ||
| 121 | u32 sl_datalen; | ||
| 122 | char sl_data[]; | ||
| 123 | }; | ||
| 124 | |||
| 125 | struct nfsd4_channel_attrs { | ||
| 126 | u32 headerpadsz; | ||
| 127 | u32 maxreq_sz; | ||
| 128 | u32 maxresp_sz; | ||
| 129 | u32 maxresp_cached; | ||
| 130 | u32 maxops; | ||
| 131 | u32 maxreqs; | ||
| 132 | u32 nr_rdma_attrs; | ||
| 133 | u32 rdma_attrs; | ||
| 134 | }; | ||
| 135 | |||
| 136 | struct nfsd4_create_session { | ||
| 137 | clientid_t clientid; | ||
| 138 | struct nfs4_sessionid sessionid; | ||
| 139 | u32 seqid; | ||
| 140 | u32 flags; | ||
| 141 | struct nfsd4_channel_attrs fore_channel; | ||
| 142 | struct nfsd4_channel_attrs back_channel; | ||
| 143 | u32 callback_prog; | ||
| 144 | u32 uid; | ||
| 145 | u32 gid; | ||
| 146 | }; | ||
| 147 | |||
| 148 | /* The single slot clientid cache structure */ | ||
| 149 | struct nfsd4_clid_slot { | ||
| 150 | u32 sl_seqid; | ||
| 151 | __be32 sl_status; | ||
| 152 | struct nfsd4_create_session sl_cr_ses; | ||
| 153 | }; | ||
| 154 | |||
| 155 | struct nfsd4_session { | ||
| 156 | struct kref se_ref; | ||
| 157 | struct list_head se_hash; /* hash by sessionid */ | ||
| 158 | struct list_head se_perclnt; | ||
| 159 | u32 se_flags; | ||
| 160 | struct nfs4_client *se_client; /* for expire_client */ | ||
| 161 | struct nfs4_sessionid se_sessionid; | ||
| 162 | struct nfsd4_channel_attrs se_fchannel; | ||
| 163 | struct nfsd4_channel_attrs se_bchannel; | ||
| 164 | struct nfsd4_slot *se_slots[]; /* forward channel slots */ | ||
| 165 | }; | ||
| 166 | |||
| 167 | static inline void | ||
| 168 | nfsd4_put_session(struct nfsd4_session *ses) | ||
| 169 | { | ||
| 170 | extern void free_session(struct kref *kref); | ||
| 171 | kref_put(&ses->se_ref, free_session); | ||
| 172 | } | ||
| 173 | |||
| 174 | static inline void | ||
| 175 | nfsd4_get_session(struct nfsd4_session *ses) | ||
| 176 | { | ||
| 177 | kref_get(&ses->se_ref); | ||
| 178 | } | ||
| 179 | |||
| 180 | /* formatted contents of nfs4_sessionid */ | ||
| 181 | struct nfsd4_sessionid { | ||
| 182 | clientid_t clientid; | ||
| 183 | u32 sequence; | ||
| 184 | u32 reserved; | ||
| 185 | }; | ||
| 186 | |||
| 187 | #define HEXDIR_LEN 33 /* hex version of 16 byte md5 of cl_name plus '\0' */ | ||
| 188 | |||
| 189 | /* | ||
| 190 | * struct nfs4_client - one per client. Clientids live here. | ||
| 191 | * o Each nfs4_client is hashed by clientid. | ||
| 192 | * | ||
| 193 | * o Each nfs4_clients is also hashed by name | ||
| 194 | * (the opaque quantity initially sent by the client to identify itself). | ||
| 195 | * | ||
| 196 | * o cl_perclient list is used to ensure no dangling stateowner references | ||
| 197 | * when we expire the nfs4_client | ||
| 198 | */ | ||
| 199 | struct nfs4_client { | ||
| 200 | struct list_head cl_idhash; /* hash by cl_clientid.id */ | ||
| 201 | struct list_head cl_strhash; /* hash by cl_name */ | ||
| 202 | struct list_head cl_openowners; | ||
| 203 | struct list_head cl_delegations; | ||
| 204 | struct list_head cl_lru; /* tail queue */ | ||
| 205 | struct xdr_netobj cl_name; /* id generated by client */ | ||
| 206 | char cl_recdir[HEXDIR_LEN]; /* recovery dir */ | ||
| 207 | nfs4_verifier cl_verifier; /* generated by client */ | ||
| 208 | time_t cl_time; /* time of last lease renewal */ | ||
| 209 | struct sockaddr_storage cl_addr; /* client ipaddress */ | ||
| 210 | u32 cl_flavor; /* setclientid pseudoflavor */ | ||
| 211 | char *cl_principal; /* setclientid principal name */ | ||
| 212 | struct svc_cred cl_cred; /* setclientid principal */ | ||
| 213 | clientid_t cl_clientid; /* generated by server */ | ||
| 214 | nfs4_verifier cl_confirm; /* generated by server */ | ||
| 215 | struct nfs4_cb_conn cl_cb_conn; /* callback info */ | ||
| 216 | atomic_t cl_count; /* ref count */ | ||
| 217 | u32 cl_firststate; /* recovery dir creation */ | ||
| 218 | |||
| 219 | /* for nfs41 */ | ||
| 220 | struct list_head cl_sessions; | ||
| 221 | struct nfsd4_clid_slot cl_cs_slot; /* create_session slot */ | ||
| 222 | u32 cl_exchange_flags; | ||
| 223 | struct nfs4_sessionid cl_sessionid; | ||
| 224 | |||
| 225 | /* for nfs41 callbacks */ | ||
| 226 | /* We currently support a single back channel with a single slot */ | ||
| 227 | unsigned long cl_cb_slot_busy; | ||
| 228 | u32 cl_cb_seq_nr; | ||
| 229 | struct svc_xprt *cl_cb_xprt; /* 4.1 callback transport */ | ||
| 230 | struct rpc_wait_queue cl_cb_waitq; /* backchannel callers may */ | ||
| 231 | /* wait here for slots */ | ||
| 232 | }; | ||
| 233 | |||
| 234 | /* struct nfs4_client_reset | ||
| 235 | * one per old client. Populates reset_str_hashtbl. Filled from conf_id_hashtbl | ||
| 236 | * upon lease reset, or from upcall to state_daemon (to read in state | ||
| 237 | * from non-volitile storage) upon reboot. | ||
| 238 | */ | ||
| 239 | struct nfs4_client_reclaim { | ||
| 240 | struct list_head cr_strhash; /* hash by cr_name */ | ||
| 241 | char cr_recdir[HEXDIR_LEN]; /* recover dir */ | ||
| 242 | }; | ||
| 243 | |||
| 244 | static inline void | ||
| 245 | update_stateid(stateid_t *stateid) | ||
| 246 | { | ||
| 247 | stateid->si_generation++; | ||
| 248 | } | ||
| 249 | |||
| 250 | /* A reasonable value for REPLAY_ISIZE was estimated as follows: | ||
| 251 | * The OPEN response, typically the largest, requires | ||
| 252 | * 4(status) + 8(stateid) + 20(changeinfo) + 4(rflags) + 8(verifier) + | ||
| 253 | * 4(deleg. type) + 8(deleg. stateid) + 4(deleg. recall flag) + | ||
| 254 | * 20(deleg. space limit) + ~32(deleg. ace) = 112 bytes | ||
| 255 | */ | ||
| 256 | |||
| 257 | #define NFSD4_REPLAY_ISIZE 112 | ||
| 258 | |||
| 259 | /* | ||
| 260 | * Replay buffer, where the result of the last seqid-mutating operation | ||
| 261 | * is cached. | ||
| 262 | */ | ||
| 263 | struct nfs4_replay { | ||
| 264 | __be32 rp_status; | ||
| 265 | unsigned int rp_buflen; | ||
| 266 | char *rp_buf; | ||
| 267 | unsigned intrp_allocated; | ||
| 268 | struct knfsd_fh rp_openfh; | ||
| 269 | char rp_ibuf[NFSD4_REPLAY_ISIZE]; | ||
| 270 | }; | ||
| 271 | |||
| 272 | /* | ||
| 273 | * nfs4_stateowner can either be an open_owner, or a lock_owner | ||
| 274 | * | ||
| 275 | * so_idhash: stateid_hashtbl[] for open owner, lockstateid_hashtbl[] | ||
| 276 | * for lock_owner | ||
| 277 | * so_strhash: ownerstr_hashtbl[] for open_owner, lock_ownerstr_hashtbl[] | ||
| 278 | * for lock_owner | ||
| 279 | * so_perclient: nfs4_client->cl_perclient entry - used when nfs4_client | ||
| 280 | * struct is reaped. | ||
| 281 | * so_perfilestate: heads the list of nfs4_stateid (either open or lock) | ||
| 282 | * and is used to ensure no dangling nfs4_stateid references when we | ||
| 283 | * release a stateowner. | ||
| 284 | * so_perlockowner: (open) nfs4_stateid->st_perlockowner entry - used when | ||
| 285 | * close is called to reap associated byte-range locks | ||
| 286 | * so_close_lru: (open) stateowner is placed on this list instead of being | ||
| 287 | * reaped (when so_perfilestate is empty) to hold the last close replay. | ||
| 288 | * reaped by laundramat thread after lease period. | ||
| 289 | */ | ||
| 290 | struct nfs4_stateowner { | ||
| 291 | struct kref so_ref; | ||
| 292 | struct list_head so_idhash; /* hash by so_id */ | ||
| 293 | struct list_head so_strhash; /* hash by op_name */ | ||
| 294 | struct list_head so_perclient; | ||
| 295 | struct list_head so_stateids; | ||
| 296 | struct list_head so_perstateid; /* for lockowners only */ | ||
| 297 | struct list_head so_close_lru; /* tail queue */ | ||
| 298 | time_t so_time; /* time of placement on so_close_lru */ | ||
| 299 | int so_is_open_owner; /* 1=openowner,0=lockowner */ | ||
| 300 | u32 so_id; | ||
| 301 | struct nfs4_client * so_client; | ||
| 302 | /* after increment in ENCODE_SEQID_OP_TAIL, represents the next | ||
| 303 | * sequence id expected from the client: */ | ||
| 304 | u32 so_seqid; | ||
| 305 | struct xdr_netobj so_owner; /* open owner name */ | ||
| 306 | int so_confirmed; /* successful OPEN_CONFIRM? */ | ||
| 307 | struct nfs4_replay so_replay; | ||
| 308 | }; | ||
| 309 | |||
| 310 | /* | ||
| 311 | * nfs4_file: a file opened by some number of (open) nfs4_stateowners. | ||
| 312 | * o fi_perfile list is used to search for conflicting | ||
| 313 | * share_acces, share_deny on the file. | ||
| 314 | */ | ||
| 315 | struct nfs4_file { | ||
| 316 | atomic_t fi_ref; | ||
| 317 | struct list_head fi_hash; /* hash by "struct inode *" */ | ||
| 318 | struct list_head fi_stateids; | ||
| 319 | struct list_head fi_delegations; | ||
| 320 | struct inode *fi_inode; | ||
| 321 | u32 fi_id; /* used with stateowner->so_id | ||
| 322 | * for stateid_hashtbl hash */ | ||
| 323 | bool fi_had_conflict; | ||
| 324 | }; | ||
| 325 | |||
| 326 | /* | ||
| 327 | * nfs4_stateid can either be an open stateid or (eventually) a lock stateid | ||
| 328 | * | ||
| 329 | * (open)nfs4_stateid: one per (open)nfs4_stateowner, nfs4_file | ||
| 330 | * | ||
| 331 | * st_hash: stateid_hashtbl[] entry or lockstateid_hashtbl entry | ||
| 332 | * st_perfile: file_hashtbl[] entry. | ||
| 333 | * st_perfile_state: nfs4_stateowner->so_perfilestate | ||
| 334 | * st_perlockowner: (open stateid) list of lock nfs4_stateowners | ||
| 335 | * st_access_bmap: used only for open stateid | ||
| 336 | * st_deny_bmap: used only for open stateid | ||
| 337 | * st_openstp: open stateid lock stateid was derived from | ||
| 338 | * | ||
| 339 | * XXX: open stateids and lock stateids have diverged sufficiently that | ||
| 340 | * we should consider defining separate structs for the two cases. | ||
| 341 | */ | ||
| 342 | |||
| 343 | struct nfs4_stateid { | ||
| 344 | struct list_head st_hash; | ||
| 345 | struct list_head st_perfile; | ||
| 346 | struct list_head st_perstateowner; | ||
| 347 | struct list_head st_lockowners; | ||
| 348 | struct nfs4_stateowner * st_stateowner; | ||
| 349 | struct nfs4_file * st_file; | ||
| 350 | stateid_t st_stateid; | ||
| 351 | struct file * st_vfs_file; | ||
| 352 | unsigned long st_access_bmap; | ||
| 353 | unsigned long st_deny_bmap; | ||
| 354 | struct nfs4_stateid * st_openstp; | ||
| 355 | }; | ||
| 356 | |||
| 357 | /* flags for preprocess_seqid_op() */ | ||
| 358 | #define HAS_SESSION 0x00000001 | ||
| 359 | #define CONFIRM 0x00000002 | ||
| 360 | #define OPEN_STATE 0x00000004 | ||
| 361 | #define LOCK_STATE 0x00000008 | ||
| 362 | #define RD_STATE 0x00000010 | ||
| 363 | #define WR_STATE 0x00000020 | ||
| 364 | #define CLOSE_STATE 0x00000040 | ||
| 365 | |||
| 366 | #define seqid_mutating_err(err) \ | ||
| 367 | (((err) != nfserr_stale_clientid) && \ | ||
| 368 | ((err) != nfserr_bad_seqid) && \ | ||
| 369 | ((err) != nfserr_stale_stateid) && \ | ||
| 370 | ((err) != nfserr_bad_stateid)) | ||
| 371 | |||
| 372 | struct nfsd4_compound_state; | ||
| 373 | |||
| 374 | extern __be32 nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate, | ||
| 375 | stateid_t *stateid, int flags, struct file **filp); | ||
| 376 | extern void nfs4_lock_state(void); | ||
| 377 | extern void nfs4_unlock_state(void); | ||
| 378 | extern int nfs4_in_grace(void); | ||
| 379 | extern __be32 nfs4_check_open_reclaim(clientid_t *clid); | ||
| 380 | extern void put_nfs4_client(struct nfs4_client *clp); | ||
| 381 | extern void nfs4_free_stateowner(struct kref *kref); | ||
| 382 | extern int set_callback_cred(void); | ||
| 383 | extern void nfsd4_probe_callback(struct nfs4_client *clp); | ||
| 384 | extern void nfsd4_cb_recall(struct nfs4_delegation *dp); | ||
| 385 | extern void nfs4_put_delegation(struct nfs4_delegation *dp); | ||
| 386 | extern __be32 nfs4_make_rec_clidname(char *clidname, struct xdr_netobj *clname); | ||
| 387 | extern void nfsd4_init_recdir(char *recdir_name); | ||
| 388 | extern int nfsd4_recdir_load(void); | ||
| 389 | extern void nfsd4_shutdown_recdir(void); | ||
| 390 | extern int nfs4_client_to_reclaim(const char *name); | ||
| 391 | extern int nfs4_has_reclaimed_state(const char *name, bool use_exchange_id); | ||
| 392 | extern void nfsd4_recdir_purge_old(void); | ||
| 393 | extern int nfsd4_create_clid_dir(struct nfs4_client *clp); | ||
| 394 | extern void nfsd4_remove_clid_dir(struct nfs4_client *clp); | ||
| 395 | |||
| 396 | static inline void | ||
| 397 | nfs4_put_stateowner(struct nfs4_stateowner *so) | ||
| 398 | { | ||
| 399 | kref_put(&so->so_ref, nfs4_free_stateowner); | ||
| 400 | } | ||
| 401 | |||
| 402 | static inline void | ||
| 403 | nfs4_get_stateowner(struct nfs4_stateowner *so) | ||
| 404 | { | ||
| 405 | kref_get(&so->so_ref); | ||
| 406 | } | ||
| 407 | |||
| 408 | #endif /* NFSD4_STATE_H */ | ||
diff --git a/fs/nfsd/stats.c b/fs/nfsd/stats.c index 71944cddf680..5232d3e8fb2f 100644 --- a/fs/nfsd/stats.c +++ b/fs/nfsd/stats.c | |||
| @@ -1,6 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/nfsd/stats.c | ||
| 3 | * | ||
| 4 | * procfs-based user access to knfsd statistics | 2 | * procfs-based user access to knfsd statistics |
| 5 | * | 3 | * |
| 6 | * /proc/net/rpc/nfsd | 4 | * /proc/net/rpc/nfsd |
| @@ -23,18 +21,13 @@ | |||
| 23 | * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> | 21 | * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> |
| 24 | */ | 22 | */ |
| 25 | 23 | ||
| 26 | #include <linux/kernel.h> | ||
| 27 | #include <linux/time.h> | ||
| 28 | #include <linux/proc_fs.h> | ||
| 29 | #include <linux/seq_file.h> | 24 | #include <linux/seq_file.h> |
| 30 | #include <linux/stat.h> | ||
| 31 | #include <linux/module.h> | 25 | #include <linux/module.h> |
| 32 | |||
| 33 | #include <linux/sunrpc/svc.h> | ||
| 34 | #include <linux/sunrpc/stats.h> | 26 | #include <linux/sunrpc/stats.h> |
| 35 | #include <linux/nfsd/nfsd.h> | ||
| 36 | #include <linux/nfsd/stats.h> | 27 | #include <linux/nfsd/stats.h> |
| 37 | 28 | ||
| 29 | #include "nfsd.h" | ||
| 30 | |||
| 38 | struct nfsd_stats nfsdstats; | 31 | struct nfsd_stats nfsdstats; |
| 39 | struct svc_stat nfsd_svcstats = { | 32 | struct svc_stat nfsd_svcstats = { |
| 40 | .program = &nfsd_program, | 33 | .program = &nfsd_program, |
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index a293f0273263..7c2e337d05af 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | #define MSNFS /* HACK HACK */ | 1 | #define MSNFS /* HACK HACK */ |
| 2 | /* | 2 | /* |
| 3 | * linux/fs/nfsd/vfs.c | ||
| 4 | * | ||
| 5 | * File operations used by nfsd. Some of these have been ripped from | 3 | * File operations used by nfsd. Some of these have been ripped from |
| 6 | * other parts of the kernel because they weren't exported, others | 4 | * other parts of the kernel because they weren't exported, others |
| 7 | * are partial duplicates with added or changed functionality. | 5 | * are partial duplicates with added or changed functionality. |
| @@ -16,48 +14,31 @@ | |||
| 16 | * Zerocpy NFS support (C) 2002 Hirokazu Takahashi <taka@valinux.co.jp> | 14 | * Zerocpy NFS support (C) 2002 Hirokazu Takahashi <taka@valinux.co.jp> |
| 17 | */ | 15 | */ |
| 18 | 16 | ||
| 19 | #include <linux/string.h> | ||
| 20 | #include <linux/time.h> | ||
| 21 | #include <linux/errno.h> | ||
| 22 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
| 23 | #include <linux/file.h> | 18 | #include <linux/file.h> |
| 24 | #include <linux/mount.h> | ||
| 25 | #include <linux/major.h> | ||
| 26 | #include <linux/splice.h> | 19 | #include <linux/splice.h> |
| 27 | #include <linux/proc_fs.h> | ||
| 28 | #include <linux/stat.h> | ||
| 29 | #include <linux/fcntl.h> | 20 | #include <linux/fcntl.h> |
| 30 | #include <linux/net.h> | ||
| 31 | #include <linux/unistd.h> | ||
| 32 | #include <linux/slab.h> | ||
| 33 | #include <linux/pagemap.h> | ||
| 34 | #include <linux/in.h> | ||
| 35 | #include <linux/module.h> | ||
| 36 | #include <linux/namei.h> | 21 | #include <linux/namei.h> |
| 37 | #include <linux/vfs.h> | ||
| 38 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
| 39 | #include <linux/sunrpc/svc.h> | ||
| 40 | #include <linux/nfsd/nfsd.h> | ||
| 41 | #ifdef CONFIG_NFSD_V3 | ||
| 42 | #include <linux/nfs3.h> | ||
| 43 | #include <linux/nfsd/xdr3.h> | ||
| 44 | #endif /* CONFIG_NFSD_V3 */ | ||
| 45 | #include <linux/nfsd/nfsfh.h> | ||
| 46 | #include <linux/quotaops.h> | 23 | #include <linux/quotaops.h> |
| 47 | #include <linux/fsnotify.h> | 24 | #include <linux/fsnotify.h> |
| 48 | #include <linux/posix_acl.h> | ||
| 49 | #include <linux/posix_acl_xattr.h> | 25 | #include <linux/posix_acl_xattr.h> |
| 50 | #include <linux/xattr.h> | 26 | #include <linux/xattr.h> |
| 27 | #include <linux/jhash.h> | ||
| 28 | #include <linux/ima.h> | ||
| 29 | #include <asm/uaccess.h> | ||
| 30 | |||
| 31 | #ifdef CONFIG_NFSD_V3 | ||
| 32 | #include "xdr3.h" | ||
| 33 | #endif /* CONFIG_NFSD_V3 */ | ||
| 34 | |||
| 51 | #ifdef CONFIG_NFSD_V4 | 35 | #ifdef CONFIG_NFSD_V4 |
| 52 | #include <linux/nfs4.h> | ||
| 53 | #include <linux/nfs4_acl.h> | 36 | #include <linux/nfs4_acl.h> |
| 54 | #include <linux/nfsd_idmap.h> | 37 | #include <linux/nfsd_idmap.h> |
| 55 | #include <linux/security.h> | ||
| 56 | #endif /* CONFIG_NFSD_V4 */ | 38 | #endif /* CONFIG_NFSD_V4 */ |
| 57 | #include <linux/jhash.h> | ||
| 58 | #include <linux/ima.h> | ||
| 59 | 39 | ||
| 60 | #include <asm/uaccess.h> | 40 | #include "nfsd.h" |
| 41 | #include "vfs.h" | ||
| 61 | 42 | ||
| 62 | #define NFSDDBG_FACILITY NFSDDBG_FILEOP | 43 | #define NFSDDBG_FACILITY NFSDDBG_FILEOP |
| 63 | 44 | ||
| @@ -89,12 +70,6 @@ struct raparm_hbucket { | |||
| 89 | #define RAPARM_HASH_MASK (RAPARM_HASH_SIZE-1) | 70 | #define RAPARM_HASH_MASK (RAPARM_HASH_SIZE-1) |
| 90 | static struct raparm_hbucket raparm_hash[RAPARM_HASH_SIZE]; | 71 | static struct raparm_hbucket raparm_hash[RAPARM_HASH_SIZE]; |
| 91 | 72 | ||
| 92 | static inline int | ||
| 93 | nfsd_v4client(struct svc_rqst *rq) | ||
| 94 | { | ||
| 95 | return rq->rq_prog == NFS_PROGRAM && rq->rq_vers == 4; | ||
| 96 | } | ||
| 97 | |||
| 98 | /* | 73 | /* |
| 99 | * Called from nfsd_lookup and encode_dirent. Check if we have crossed | 74 | * Called from nfsd_lookup and encode_dirent. Check if we have crossed |
| 100 | * a mount point. | 75 | * a mount point. |
| @@ -116,8 +91,16 @@ nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp, | |||
| 116 | 91 | ||
| 117 | exp2 = rqst_exp_get_by_name(rqstp, &path); | 92 | exp2 = rqst_exp_get_by_name(rqstp, &path); |
| 118 | if (IS_ERR(exp2)) { | 93 | if (IS_ERR(exp2)) { |
| 119 | if (PTR_ERR(exp2) != -ENOENT) | 94 | err = PTR_ERR(exp2); |
| 120 | err = PTR_ERR(exp2); | 95 | /* |
| 96 | * We normally allow NFS clients to continue | ||
| 97 | * "underneath" a mountpoint that is not exported. | ||
| 98 | * The exception is V4ROOT, where no traversal is ever | ||
| 99 | * allowed without an explicit export of the new | ||
| 100 | * directory. | ||
| 101 | */ | ||
| 102 | if (err == -ENOENT && !(exp->ex_flags & NFSEXP_V4ROOT)) | ||
| 103 | err = 0; | ||
| 121 | path_put(&path); | 104 | path_put(&path); |
| 122 | goto out; | 105 | goto out; |
| 123 | } | 106 | } |
| @@ -141,6 +124,53 @@ out: | |||
| 141 | return err; | 124 | return err; |
| 142 | } | 125 | } |
| 143 | 126 | ||
| 127 | static void follow_to_parent(struct path *path) | ||
| 128 | { | ||
| 129 | struct dentry *dp; | ||
| 130 | |||
| 131 | while (path->dentry == path->mnt->mnt_root && follow_up(path)) | ||
| 132 | ; | ||
| 133 | dp = dget_parent(path->dentry); | ||
| 134 | dput(path->dentry); | ||
| 135 | path->dentry = dp; | ||
| 136 | } | ||
| 137 | |||
| 138 | static int nfsd_lookup_parent(struct svc_rqst *rqstp, struct dentry *dparent, struct svc_export **exp, struct dentry **dentryp) | ||
| 139 | { | ||
| 140 | struct svc_export *exp2; | ||
| 141 | struct path path = {.mnt = mntget((*exp)->ex_path.mnt), | ||
| 142 | .dentry = dget(dparent)}; | ||
| 143 | |||
| 144 | follow_to_parent(&path); | ||
| 145 | |||
| 146 | exp2 = rqst_exp_parent(rqstp, &path); | ||
| 147 | if (PTR_ERR(exp2) == -ENOENT) { | ||
| 148 | *dentryp = dget(dparent); | ||
| 149 | } else if (IS_ERR(exp2)) { | ||
| 150 | path_put(&path); | ||
| 151 | return PTR_ERR(exp2); | ||
| 152 | } else { | ||
| 153 | *dentryp = dget(path.dentry); | ||
| 154 | exp_put(*exp); | ||
| 155 | *exp = exp2; | ||
| 156 | } | ||
| 157 | path_put(&path); | ||
| 158 | return 0; | ||
| 159 | } | ||
| 160 | |||
| 161 | /* | ||
| 162 | * For nfsd purposes, we treat V4ROOT exports as though there was an | ||
| 163 | * export at *every* directory. | ||
| 164 | */ | ||
| 165 | int nfsd_mountpoint(struct dentry *dentry, struct svc_export *exp) | ||
| 166 | { | ||
| 167 | if (d_mountpoint(dentry)) | ||
| 168 | return 1; | ||
| 169 | if (!(exp->ex_flags & NFSEXP_V4ROOT)) | ||
| 170 | return 0; | ||
| 171 | return dentry->d_inode != NULL; | ||
| 172 | } | ||
| 173 | |||
| 144 | __be32 | 174 | __be32 |
| 145 | nfsd_lookup_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp, | 175 | nfsd_lookup_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp, |
| 146 | const char *name, unsigned int len, | 176 | const char *name, unsigned int len, |
| @@ -169,35 +199,13 @@ nfsd_lookup_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
| 169 | dentry = dget(dparent); | 199 | dentry = dget(dparent); |
| 170 | else if (dparent != exp->ex_path.dentry) | 200 | else if (dparent != exp->ex_path.dentry) |
| 171 | dentry = dget_parent(dparent); | 201 | dentry = dget_parent(dparent); |
| 172 | else if (!EX_NOHIDE(exp)) | 202 | else if (!EX_NOHIDE(exp) && !nfsd_v4client(rqstp)) |
| 173 | dentry = dget(dparent); /* .. == . just like at / */ | 203 | dentry = dget(dparent); /* .. == . just like at / */ |
| 174 | else { | 204 | else { |
| 175 | /* checking mountpoint crossing is very different when stepping up */ | 205 | /* checking mountpoint crossing is very different when stepping up */ |
| 176 | struct svc_export *exp2 = NULL; | 206 | host_err = nfsd_lookup_parent(rqstp, dparent, &exp, &dentry); |
| 177 | struct dentry *dp; | 207 | if (host_err) |
| 178 | struct path path = {.mnt = mntget(exp->ex_path.mnt), | ||
| 179 | .dentry = dget(dparent)}; | ||
| 180 | |||
| 181 | while (path.dentry == path.mnt->mnt_root && | ||
| 182 | follow_up(&path)) | ||
| 183 | ; | ||
| 184 | dp = dget_parent(path.dentry); | ||
| 185 | dput(path.dentry); | ||
| 186 | path.dentry = dp; | ||
| 187 | |||
| 188 | exp2 = rqst_exp_parent(rqstp, &path); | ||
| 189 | if (PTR_ERR(exp2) == -ENOENT) { | ||
| 190 | dentry = dget(dparent); | ||
| 191 | } else if (IS_ERR(exp2)) { | ||
| 192 | host_err = PTR_ERR(exp2); | ||
| 193 | path_put(&path); | ||
| 194 | goto out_nfserr; | 208 | goto out_nfserr; |
| 195 | } else { | ||
| 196 | dentry = dget(path.dentry); | ||
| 197 | exp_put(exp); | ||
| 198 | exp = exp2; | ||
| 199 | } | ||
| 200 | path_put(&path); | ||
| 201 | } | 209 | } |
| 202 | } else { | 210 | } else { |
| 203 | fh_lock(fhp); | 211 | fh_lock(fhp); |
| @@ -208,7 +216,7 @@ nfsd_lookup_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
| 208 | /* | 216 | /* |
| 209 | * check if we have crossed a mount point ... | 217 | * check if we have crossed a mount point ... |
| 210 | */ | 218 | */ |
| 211 | if (d_mountpoint(dentry)) { | 219 | if (nfsd_mountpoint(dentry, exp)) { |
| 212 | if ((host_err = nfsd_cross_mnt(rqstp, &dentry, &exp))) { | 220 | if ((host_err = nfsd_cross_mnt(rqstp, &dentry, &exp))) { |
| 213 | dput(dentry); | 221 | dput(dentry); |
| 214 | goto out_nfserr; | 222 | goto out_nfserr; |
| @@ -744,8 +752,6 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, | |||
| 744 | flags, current_cred()); | 752 | flags, current_cred()); |
| 745 | if (IS_ERR(*filp)) | 753 | if (IS_ERR(*filp)) |
| 746 | host_err = PTR_ERR(*filp); | 754 | host_err = PTR_ERR(*filp); |
| 747 | else | ||
| 748 | ima_counts_get(*filp); | ||
| 749 | out_nfserr: | 755 | out_nfserr: |
| 750 | err = nfserrno(host_err); | 756 | err = nfserrno(host_err); |
| 751 | out: | 757 | out: |
| @@ -2124,8 +2130,7 @@ nfsd_permission(struct svc_rqst *rqstp, struct svc_export *exp, | |||
| 2124 | */ | 2130 | */ |
| 2125 | path.mnt = exp->ex_path.mnt; | 2131 | path.mnt = exp->ex_path.mnt; |
| 2126 | path.dentry = dentry; | 2132 | path.dentry = dentry; |
| 2127 | err = ima_path_check(&path, acc & (MAY_READ | MAY_WRITE | MAY_EXEC), | 2133 | err = ima_path_check(&path, acc & (MAY_READ | MAY_WRITE | MAY_EXEC)); |
| 2128 | IMA_COUNT_LEAVE); | ||
| 2129 | nfsd_out: | 2134 | nfsd_out: |
| 2130 | return err? nfserrno(err) : 0; | 2135 | return err? nfserrno(err) : 0; |
| 2131 | } | 2136 | } |
diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h new file mode 100644 index 000000000000..4b1de0a9ea75 --- /dev/null +++ b/fs/nfsd/vfs.h | |||
| @@ -0,0 +1,101 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de> | ||
| 3 | */ | ||
| 4 | |||
| 5 | #ifndef LINUX_NFSD_VFS_H | ||
| 6 | #define LINUX_NFSD_VFS_H | ||
| 7 | |||
| 8 | #include "nfsfh.h" | ||
| 9 | |||
| 10 | /* | ||
| 11 | * Flags for nfsd_permission | ||
| 12 | */ | ||
| 13 | #define NFSD_MAY_NOP 0 | ||
| 14 | #define NFSD_MAY_EXEC 1 /* == MAY_EXEC */ | ||
| 15 | #define NFSD_MAY_WRITE 2 /* == MAY_WRITE */ | ||
| 16 | #define NFSD_MAY_READ 4 /* == MAY_READ */ | ||
| 17 | #define NFSD_MAY_SATTR 8 | ||
| 18 | #define NFSD_MAY_TRUNC 16 | ||
| 19 | #define NFSD_MAY_LOCK 32 | ||
| 20 | #define NFSD_MAY_OWNER_OVERRIDE 64 | ||
| 21 | #define NFSD_MAY_LOCAL_ACCESS 128 /* IRIX doing local access check on device special file*/ | ||
| 22 | #define NFSD_MAY_BYPASS_GSS_ON_ROOT 256 | ||
| 23 | |||
| 24 | #define NFSD_MAY_CREATE (NFSD_MAY_EXEC|NFSD_MAY_WRITE) | ||
| 25 | #define NFSD_MAY_REMOVE (NFSD_MAY_EXEC|NFSD_MAY_WRITE|NFSD_MAY_TRUNC) | ||
| 26 | |||
| 27 | /* | ||
| 28 | * Callback function for readdir | ||
| 29 | */ | ||
| 30 | typedef int (*nfsd_dirop_t)(struct inode *, struct dentry *, int, int); | ||
| 31 | |||
| 32 | /* nfsd/vfs.c */ | ||
| 33 | int fh_lock_parent(struct svc_fh *, struct dentry *); | ||
| 34 | int nfsd_racache_init(int); | ||
| 35 | void nfsd_racache_shutdown(void); | ||
| 36 | int nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp, | ||
| 37 | struct svc_export **expp); | ||
| 38 | __be32 nfsd_lookup(struct svc_rqst *, struct svc_fh *, | ||
| 39 | const char *, unsigned int, struct svc_fh *); | ||
| 40 | __be32 nfsd_lookup_dentry(struct svc_rqst *, struct svc_fh *, | ||
| 41 | const char *, unsigned int, | ||
| 42 | struct svc_export **, struct dentry **); | ||
| 43 | __be32 nfsd_setattr(struct svc_rqst *, struct svc_fh *, | ||
| 44 | struct iattr *, int, time_t); | ||
| 45 | int nfsd_mountpoint(struct dentry *, struct svc_export *); | ||
| 46 | #ifdef CONFIG_NFSD_V4 | ||
| 47 | __be32 nfsd4_set_nfs4_acl(struct svc_rqst *, struct svc_fh *, | ||
| 48 | struct nfs4_acl *); | ||
| 49 | int nfsd4_get_nfs4_acl(struct svc_rqst *, struct dentry *, struct nfs4_acl **); | ||
| 50 | #endif /* CONFIG_NFSD_V4 */ | ||
| 51 | __be32 nfsd_create(struct svc_rqst *, struct svc_fh *, | ||
| 52 | char *name, int len, struct iattr *attrs, | ||
| 53 | int type, dev_t rdev, struct svc_fh *res); | ||
| 54 | #ifdef CONFIG_NFSD_V3 | ||
| 55 | __be32 nfsd_access(struct svc_rqst *, struct svc_fh *, u32 *, u32 *); | ||
| 56 | __be32 nfsd_create_v3(struct svc_rqst *, struct svc_fh *, | ||
| 57 | char *name, int len, struct iattr *attrs, | ||
| 58 | struct svc_fh *res, int createmode, | ||
| 59 | u32 *verifier, int *truncp, int *created); | ||
| 60 | __be32 nfsd_commit(struct svc_rqst *, struct svc_fh *, | ||
| 61 | loff_t, unsigned long); | ||
| 62 | #endif /* CONFIG_NFSD_V3 */ | ||
| 63 | __be32 nfsd_open(struct svc_rqst *, struct svc_fh *, int, | ||
| 64 | int, struct file **); | ||
| 65 | void nfsd_close(struct file *); | ||
| 66 | __be32 nfsd_read(struct svc_rqst *, struct svc_fh *, struct file *, | ||
| 67 | loff_t, struct kvec *, int, unsigned long *); | ||
| 68 | __be32 nfsd_write(struct svc_rqst *, struct svc_fh *,struct file *, | ||
| 69 | loff_t, struct kvec *,int, unsigned long *, int *); | ||
| 70 | __be32 nfsd_readlink(struct svc_rqst *, struct svc_fh *, | ||
| 71 | char *, int *); | ||
| 72 | __be32 nfsd_symlink(struct svc_rqst *, struct svc_fh *, | ||
| 73 | char *name, int len, char *path, int plen, | ||
| 74 | struct svc_fh *res, struct iattr *); | ||
| 75 | __be32 nfsd_link(struct svc_rqst *, struct svc_fh *, | ||
| 76 | char *, int, struct svc_fh *); | ||
| 77 | __be32 nfsd_rename(struct svc_rqst *, | ||
| 78 | struct svc_fh *, char *, int, | ||
| 79 | struct svc_fh *, char *, int); | ||
| 80 | __be32 nfsd_remove(struct svc_rqst *, | ||
| 81 | struct svc_fh *, char *, int); | ||
| 82 | __be32 nfsd_unlink(struct svc_rqst *, struct svc_fh *, int type, | ||
| 83 | char *name, int len); | ||
| 84 | int nfsd_truncate(struct svc_rqst *, struct svc_fh *, | ||
| 85 | unsigned long size); | ||
| 86 | __be32 nfsd_readdir(struct svc_rqst *, struct svc_fh *, | ||
| 87 | loff_t *, struct readdir_cd *, filldir_t); | ||
| 88 | __be32 nfsd_statfs(struct svc_rqst *, struct svc_fh *, | ||
| 89 | struct kstatfs *, int access); | ||
| 90 | |||
| 91 | int nfsd_notify_change(struct inode *, struct iattr *); | ||
| 92 | __be32 nfsd_permission(struct svc_rqst *, struct svc_export *, | ||
| 93 | struct dentry *, int); | ||
| 94 | int nfsd_sync_dir(struct dentry *dp); | ||
| 95 | |||
| 96 | #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) | ||
| 97 | struct posix_acl *nfsd_get_posix_acl(struct svc_fh *, int); | ||
| 98 | int nfsd_set_posix_acl(struct svc_fh *, int, struct posix_acl *); | ||
| 99 | #endif | ||
| 100 | |||
| 101 | #endif /* LINUX_NFSD_VFS_H */ | ||
diff --git a/fs/nfsd/xdr.h b/fs/nfsd/xdr.h new file mode 100644 index 000000000000..53b1863dd8f6 --- /dev/null +++ b/fs/nfsd/xdr.h | |||
| @@ -0,0 +1,173 @@ | |||
| 1 | /* XDR types for nfsd. This is mainly a typing exercise. */ | ||
| 2 | |||
| 3 | #ifndef LINUX_NFSD_H | ||
| 4 | #define LINUX_NFSD_H | ||
| 5 | |||
| 6 | #include <linux/vfs.h> | ||
| 7 | #include "nfsd.h" | ||
| 8 | #include "nfsfh.h" | ||
| 9 | |||
| 10 | struct nfsd_fhandle { | ||
| 11 | struct svc_fh fh; | ||
| 12 | }; | ||
| 13 | |||
| 14 | struct nfsd_sattrargs { | ||
| 15 | struct svc_fh fh; | ||
| 16 | struct iattr attrs; | ||
| 17 | }; | ||
| 18 | |||
| 19 | struct nfsd_diropargs { | ||
| 20 | struct svc_fh fh; | ||
| 21 | char * name; | ||
| 22 | unsigned int len; | ||
| 23 | }; | ||
| 24 | |||
| 25 | struct nfsd_readargs { | ||
| 26 | struct svc_fh fh; | ||
| 27 | __u32 offset; | ||
| 28 | __u32 count; | ||
| 29 | int vlen; | ||
| 30 | }; | ||
| 31 | |||
| 32 | struct nfsd_writeargs { | ||
| 33 | svc_fh fh; | ||
| 34 | __u32 offset; | ||
| 35 | int len; | ||
| 36 | int vlen; | ||
| 37 | }; | ||
| 38 | |||
| 39 | struct nfsd_createargs { | ||
| 40 | struct svc_fh fh; | ||
| 41 | char * name; | ||
| 42 | unsigned int len; | ||
| 43 | struct iattr attrs; | ||
| 44 | }; | ||
| 45 | |||
| 46 | struct nfsd_renameargs { | ||
| 47 | struct svc_fh ffh; | ||
| 48 | char * fname; | ||
| 49 | unsigned int flen; | ||
| 50 | struct svc_fh tfh; | ||
| 51 | char * tname; | ||
| 52 | unsigned int tlen; | ||
| 53 | }; | ||
| 54 | |||
| 55 | struct nfsd_readlinkargs { | ||
| 56 | struct svc_fh fh; | ||
| 57 | char * buffer; | ||
| 58 | }; | ||
| 59 | |||
| 60 | struct nfsd_linkargs { | ||
| 61 | struct svc_fh ffh; | ||
| 62 | struct svc_fh tfh; | ||
| 63 | char * tname; | ||
| 64 | unsigned int tlen; | ||
| 65 | }; | ||
| 66 | |||
| 67 | struct nfsd_symlinkargs { | ||
| 68 | struct svc_fh ffh; | ||
| 69 | char * fname; | ||
| 70 | unsigned int flen; | ||
| 71 | char * tname; | ||
| 72 | unsigned int tlen; | ||
| 73 | struct iattr attrs; | ||
| 74 | }; | ||
| 75 | |||
| 76 | struct nfsd_readdirargs { | ||
| 77 | struct svc_fh fh; | ||
| 78 | __u32 cookie; | ||
| 79 | __u32 count; | ||
| 80 | __be32 * buffer; | ||
| 81 | }; | ||
| 82 | |||
| 83 | struct nfsd_attrstat { | ||
| 84 | struct svc_fh fh; | ||
| 85 | struct kstat stat; | ||
| 86 | }; | ||
| 87 | |||
| 88 | struct nfsd_diropres { | ||
| 89 | struct svc_fh fh; | ||
| 90 | struct kstat stat; | ||
| 91 | }; | ||
| 92 | |||
| 93 | struct nfsd_readlinkres { | ||
| 94 | int len; | ||
| 95 | }; | ||
| 96 | |||
| 97 | struct nfsd_readres { | ||
| 98 | struct svc_fh fh; | ||
| 99 | unsigned long count; | ||
| 100 | struct kstat stat; | ||
| 101 | }; | ||
| 102 | |||
| 103 | struct nfsd_readdirres { | ||
| 104 | int count; | ||
| 105 | |||
| 106 | struct readdir_cd common; | ||
| 107 | __be32 * buffer; | ||
| 108 | int buflen; | ||
| 109 | __be32 * offset; | ||
| 110 | }; | ||
| 111 | |||
| 112 | struct nfsd_statfsres { | ||
| 113 | struct kstatfs stats; | ||
| 114 | }; | ||
| 115 | |||
| 116 | /* | ||
| 117 | * Storage requirements for XDR arguments and results. | ||
| 118 | */ | ||
| 119 | union nfsd_xdrstore { | ||
| 120 | struct nfsd_sattrargs sattr; | ||
| 121 | struct nfsd_diropargs dirop; | ||
| 122 | struct nfsd_readargs read; | ||
| 123 | struct nfsd_writeargs write; | ||
| 124 | struct nfsd_createargs create; | ||
| 125 | struct nfsd_renameargs rename; | ||
| 126 | struct nfsd_linkargs link; | ||
| 127 | struct nfsd_symlinkargs symlink; | ||
| 128 | struct nfsd_readdirargs readdir; | ||
| 129 | }; | ||
| 130 | |||
| 131 | #define NFS2_SVC_XDRSIZE sizeof(union nfsd_xdrstore) | ||
| 132 | |||
| 133 | |||
| 134 | int nfssvc_decode_void(struct svc_rqst *, __be32 *, void *); | ||
| 135 | int nfssvc_decode_fhandle(struct svc_rqst *, __be32 *, struct nfsd_fhandle *); | ||
| 136 | int nfssvc_decode_sattrargs(struct svc_rqst *, __be32 *, | ||
| 137 | struct nfsd_sattrargs *); | ||
| 138 | int nfssvc_decode_diropargs(struct svc_rqst *, __be32 *, | ||
| 139 | struct nfsd_diropargs *); | ||
| 140 | int nfssvc_decode_readargs(struct svc_rqst *, __be32 *, | ||
| 141 | struct nfsd_readargs *); | ||
| 142 | int nfssvc_decode_writeargs(struct svc_rqst *, __be32 *, | ||
| 143 | struct nfsd_writeargs *); | ||
| 144 | int nfssvc_decode_createargs(struct svc_rqst *, __be32 *, | ||
| 145 | struct nfsd_createargs *); | ||
| 146 | int nfssvc_decode_renameargs(struct svc_rqst *, __be32 *, | ||
| 147 | struct nfsd_renameargs *); | ||
| 148 | int nfssvc_decode_readlinkargs(struct svc_rqst *, __be32 *, | ||
| 149 | struct nfsd_readlinkargs *); | ||
| 150 | int nfssvc_decode_linkargs(struct svc_rqst *, __be32 *, | ||
| 151 | struct nfsd_linkargs *); | ||
| 152 | int nfssvc_decode_symlinkargs(struct svc_rqst *, __be32 *, | ||
| 153 | struct nfsd_symlinkargs *); | ||
| 154 | int nfssvc_decode_readdirargs(struct svc_rqst *, __be32 *, | ||
| 155 | struct nfsd_readdirargs *); | ||
| 156 | int nfssvc_encode_void(struct svc_rqst *, __be32 *, void *); | ||
| 157 | int nfssvc_encode_attrstat(struct svc_rqst *, __be32 *, struct nfsd_attrstat *); | ||
| 158 | int nfssvc_encode_diropres(struct svc_rqst *, __be32 *, struct nfsd_diropres *); | ||
| 159 | int nfssvc_encode_readlinkres(struct svc_rqst *, __be32 *, struct nfsd_readlinkres *); | ||
| 160 | int nfssvc_encode_readres(struct svc_rqst *, __be32 *, struct nfsd_readres *); | ||
| 161 | int nfssvc_encode_statfsres(struct svc_rqst *, __be32 *, struct nfsd_statfsres *); | ||
| 162 | int nfssvc_encode_readdirres(struct svc_rqst *, __be32 *, struct nfsd_readdirres *); | ||
| 163 | |||
| 164 | int nfssvc_encode_entry(void *, const char *name, | ||
| 165 | int namlen, loff_t offset, u64 ino, unsigned int); | ||
| 166 | |||
| 167 | int nfssvc_release_fhandle(struct svc_rqst *, __be32 *, struct nfsd_fhandle *); | ||
| 168 | |||
| 169 | /* Helper functions for NFSv2 ACL code */ | ||
| 170 | __be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp); | ||
| 171 | __be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp); | ||
| 172 | |||
| 173 | #endif /* LINUX_NFSD_H */ | ||
diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h new file mode 100644 index 000000000000..7df980eb0562 --- /dev/null +++ b/fs/nfsd/xdr3.h | |||
| @@ -0,0 +1,344 @@ | |||
| 1 | /* | ||
| 2 | * XDR types for NFSv3 in nfsd. | ||
| 3 | * | ||
| 4 | * Copyright (C) 1996-1998, Olaf Kirch <okir@monad.swb.de> | ||
| 5 | */ | ||
| 6 | |||
| 7 | #ifndef _LINUX_NFSD_XDR3_H | ||
| 8 | #define _LINUX_NFSD_XDR3_H | ||
| 9 | |||
| 10 | #include "xdr.h" | ||
| 11 | |||
| 12 | struct nfsd3_sattrargs { | ||
| 13 | struct svc_fh fh; | ||
| 14 | struct iattr attrs; | ||
| 15 | int check_guard; | ||
| 16 | time_t guardtime; | ||
| 17 | }; | ||
| 18 | |||
| 19 | struct nfsd3_diropargs { | ||
| 20 | struct svc_fh fh; | ||
| 21 | char * name; | ||
| 22 | unsigned int len; | ||
| 23 | }; | ||
| 24 | |||
| 25 | struct nfsd3_accessargs { | ||
| 26 | struct svc_fh fh; | ||
| 27 | unsigned int access; | ||
| 28 | }; | ||
| 29 | |||
| 30 | struct nfsd3_readargs { | ||
| 31 | struct svc_fh fh; | ||
| 32 | __u64 offset; | ||
| 33 | __u32 count; | ||
| 34 | int vlen; | ||
| 35 | }; | ||
| 36 | |||
| 37 | struct nfsd3_writeargs { | ||
| 38 | svc_fh fh; | ||
| 39 | __u64 offset; | ||
| 40 | __u32 count; | ||
| 41 | int stable; | ||
| 42 | __u32 len; | ||
| 43 | int vlen; | ||
| 44 | }; | ||
| 45 | |||
| 46 | struct nfsd3_createargs { | ||
| 47 | struct svc_fh fh; | ||
| 48 | char * name; | ||
| 49 | unsigned int len; | ||
| 50 | int createmode; | ||
| 51 | struct iattr attrs; | ||
| 52 | __be32 * verf; | ||
| 53 | }; | ||
| 54 | |||
| 55 | struct nfsd3_mknodargs { | ||
| 56 | struct svc_fh fh; | ||
| 57 | char * name; | ||
| 58 | unsigned int len; | ||
| 59 | __u32 ftype; | ||
| 60 | __u32 major, minor; | ||
| 61 | struct iattr attrs; | ||
| 62 | }; | ||
| 63 | |||
| 64 | struct nfsd3_renameargs { | ||
| 65 | struct svc_fh ffh; | ||
| 66 | char * fname; | ||
| 67 | unsigned int flen; | ||
| 68 | struct svc_fh tfh; | ||
| 69 | char * tname; | ||
| 70 | unsigned int tlen; | ||
| 71 | }; | ||
| 72 | |||
| 73 | struct nfsd3_readlinkargs { | ||
| 74 | struct svc_fh fh; | ||
| 75 | char * buffer; | ||
| 76 | }; | ||
| 77 | |||
| 78 | struct nfsd3_linkargs { | ||
| 79 | struct svc_fh ffh; | ||
| 80 | struct svc_fh tfh; | ||
| 81 | char * tname; | ||
| 82 | unsigned int tlen; | ||
| 83 | }; | ||
| 84 | |||
| 85 | struct nfsd3_symlinkargs { | ||
| 86 | struct svc_fh ffh; | ||
| 87 | char * fname; | ||
| 88 | unsigned int flen; | ||
| 89 | char * tname; | ||
| 90 | unsigned int tlen; | ||
| 91 | struct iattr attrs; | ||
| 92 | }; | ||
| 93 | |||
| 94 | struct nfsd3_readdirargs { | ||
| 95 | struct svc_fh fh; | ||
| 96 | __u64 cookie; | ||
| 97 | __u32 dircount; | ||
| 98 | __u32 count; | ||
| 99 | __be32 * verf; | ||
| 100 | __be32 * buffer; | ||
| 101 | }; | ||
| 102 | |||
| 103 | struct nfsd3_commitargs { | ||
| 104 | struct svc_fh fh; | ||
| 105 | __u64 offset; | ||
| 106 | __u32 count; | ||
| 107 | }; | ||
| 108 | |||
| 109 | struct nfsd3_getaclargs { | ||
| 110 | struct svc_fh fh; | ||
| 111 | int mask; | ||
| 112 | }; | ||
| 113 | |||
| 114 | struct posix_acl; | ||
| 115 | struct nfsd3_setaclargs { | ||
| 116 | struct svc_fh fh; | ||
| 117 | int mask; | ||
| 118 | struct posix_acl *acl_access; | ||
| 119 | struct posix_acl *acl_default; | ||
| 120 | }; | ||
| 121 | |||
| 122 | struct nfsd3_attrstat { | ||
| 123 | __be32 status; | ||
| 124 | struct svc_fh fh; | ||
| 125 | struct kstat stat; | ||
| 126 | }; | ||
| 127 | |||
| 128 | /* LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD */ | ||
| 129 | struct nfsd3_diropres { | ||
| 130 | __be32 status; | ||
| 131 | struct svc_fh dirfh; | ||
| 132 | struct svc_fh fh; | ||
| 133 | }; | ||
| 134 | |||
| 135 | struct nfsd3_accessres { | ||
| 136 | __be32 status; | ||
| 137 | struct svc_fh fh; | ||
| 138 | __u32 access; | ||
| 139 | }; | ||
| 140 | |||
| 141 | struct nfsd3_readlinkres { | ||
| 142 | __be32 status; | ||
| 143 | struct svc_fh fh; | ||
| 144 | __u32 len; | ||
| 145 | }; | ||
| 146 | |||
| 147 | struct nfsd3_readres { | ||
| 148 | __be32 status; | ||
| 149 | struct svc_fh fh; | ||
| 150 | unsigned long count; | ||
| 151 | int eof; | ||
| 152 | }; | ||
| 153 | |||
| 154 | struct nfsd3_writeres { | ||
| 155 | __be32 status; | ||
| 156 | struct svc_fh fh; | ||
| 157 | unsigned long count; | ||
| 158 | int committed; | ||
| 159 | }; | ||
| 160 | |||
| 161 | struct nfsd3_renameres { | ||
| 162 | __be32 status; | ||
| 163 | struct svc_fh ffh; | ||
| 164 | struct svc_fh tfh; | ||
| 165 | }; | ||
| 166 | |||
| 167 | struct nfsd3_linkres { | ||
| 168 | __be32 status; | ||
| 169 | struct svc_fh tfh; | ||
| 170 | struct svc_fh fh; | ||
| 171 | }; | ||
| 172 | |||
| 173 | struct nfsd3_readdirres { | ||
| 174 | __be32 status; | ||
| 175 | struct svc_fh fh; | ||
| 176 | int count; | ||
| 177 | __be32 verf[2]; | ||
| 178 | |||
| 179 | struct readdir_cd common; | ||
| 180 | __be32 * buffer; | ||
| 181 | int buflen; | ||
| 182 | __be32 * offset; | ||
| 183 | __be32 * offset1; | ||
| 184 | struct svc_rqst * rqstp; | ||
| 185 | |||
| 186 | }; | ||
| 187 | |||
| 188 | struct nfsd3_fsstatres { | ||
| 189 | __be32 status; | ||
| 190 | struct kstatfs stats; | ||
| 191 | __u32 invarsec; | ||
| 192 | }; | ||
| 193 | |||
| 194 | struct nfsd3_fsinfores { | ||
| 195 | __be32 status; | ||
| 196 | __u32 f_rtmax; | ||
| 197 | __u32 f_rtpref; | ||
| 198 | __u32 f_rtmult; | ||
| 199 | __u32 f_wtmax; | ||
| 200 | __u32 f_wtpref; | ||
| 201 | __u32 f_wtmult; | ||
| 202 | __u32 f_dtpref; | ||
| 203 | __u64 f_maxfilesize; | ||
| 204 | __u32 f_properties; | ||
| 205 | }; | ||
| 206 | |||
| 207 | struct nfsd3_pathconfres { | ||
| 208 | __be32 status; | ||
| 209 | __u32 p_link_max; | ||
| 210 | __u32 p_name_max; | ||
| 211 | __u32 p_no_trunc; | ||
| 212 | __u32 p_chown_restricted; | ||
| 213 | __u32 p_case_insensitive; | ||
| 214 | __u32 p_case_preserving; | ||
| 215 | }; | ||
| 216 | |||
| 217 | struct nfsd3_commitres { | ||
| 218 | __be32 status; | ||
| 219 | struct svc_fh fh; | ||
| 220 | }; | ||
| 221 | |||
| 222 | struct nfsd3_getaclres { | ||
| 223 | __be32 status; | ||
| 224 | struct svc_fh fh; | ||
| 225 | int mask; | ||
| 226 | struct posix_acl *acl_access; | ||
| 227 | struct posix_acl *acl_default; | ||
| 228 | }; | ||
| 229 | |||
| 230 | /* dummy type for release */ | ||
| 231 | struct nfsd3_fhandle_pair { | ||
| 232 | __u32 dummy; | ||
| 233 | struct svc_fh fh1; | ||
| 234 | struct svc_fh fh2; | ||
| 235 | }; | ||
| 236 | |||
| 237 | /* | ||
| 238 | * Storage requirements for XDR arguments and results. | ||
| 239 | */ | ||
| 240 | union nfsd3_xdrstore { | ||
| 241 | struct nfsd3_sattrargs sattrargs; | ||
| 242 | struct nfsd3_diropargs diropargs; | ||
| 243 | struct nfsd3_readargs readargs; | ||
| 244 | struct nfsd3_writeargs writeargs; | ||
| 245 | struct nfsd3_createargs createargs; | ||
| 246 | struct nfsd3_renameargs renameargs; | ||
| 247 | struct nfsd3_linkargs linkargs; | ||
| 248 | struct nfsd3_symlinkargs symlinkargs; | ||
| 249 | struct nfsd3_readdirargs readdirargs; | ||
| 250 | struct nfsd3_diropres diropres; | ||
| 251 | struct nfsd3_accessres accessres; | ||
| 252 | struct nfsd3_readlinkres readlinkres; | ||
| 253 | struct nfsd3_readres readres; | ||
| 254 | struct nfsd3_writeres writeres; | ||
| 255 | struct nfsd3_renameres renameres; | ||
| 256 | struct nfsd3_linkres linkres; | ||
| 257 | struct nfsd3_readdirres readdirres; | ||
| 258 | struct nfsd3_fsstatres fsstatres; | ||
| 259 | struct nfsd3_fsinfores fsinfores; | ||
| 260 | struct nfsd3_pathconfres pathconfres; | ||
| 261 | struct nfsd3_commitres commitres; | ||
| 262 | struct nfsd3_getaclres getaclres; | ||
| 263 | }; | ||
| 264 | |||
| 265 | #define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore) | ||
| 266 | |||
| 267 | int nfs3svc_decode_fhandle(struct svc_rqst *, __be32 *, struct nfsd_fhandle *); | ||
| 268 | int nfs3svc_decode_sattrargs(struct svc_rqst *, __be32 *, | ||
| 269 | struct nfsd3_sattrargs *); | ||
| 270 | int nfs3svc_decode_diropargs(struct svc_rqst *, __be32 *, | ||
| 271 | struct nfsd3_diropargs *); | ||
| 272 | int nfs3svc_decode_accessargs(struct svc_rqst *, __be32 *, | ||
| 273 | struct nfsd3_accessargs *); | ||
| 274 | int nfs3svc_decode_readargs(struct svc_rqst *, __be32 *, | ||
| 275 | struct nfsd3_readargs *); | ||
| 276 | int nfs3svc_decode_writeargs(struct svc_rqst *, __be32 *, | ||
| 277 | struct nfsd3_writeargs *); | ||
| 278 | int nfs3svc_decode_createargs(struct svc_rqst *, __be32 *, | ||
| 279 | struct nfsd3_createargs *); | ||
| 280 | int nfs3svc_decode_mkdirargs(struct svc_rqst *, __be32 *, | ||
| 281 | struct nfsd3_createargs *); | ||
| 282 | int nfs3svc_decode_mknodargs(struct svc_rqst *, __be32 *, | ||
| 283 | struct nfsd3_mknodargs *); | ||
| 284 | int nfs3svc_decode_renameargs(struct svc_rqst *, __be32 *, | ||
| 285 | struct nfsd3_renameargs *); | ||
| 286 | int nfs3svc_decode_readlinkargs(struct svc_rqst *, __be32 *, | ||
| 287 | struct nfsd3_readlinkargs *); | ||
| 288 | int nfs3svc_decode_linkargs(struct svc_rqst *, __be32 *, | ||
| 289 | struct nfsd3_linkargs *); | ||
| 290 | int nfs3svc_decode_symlinkargs(struct svc_rqst *, __be32 *, | ||
| 291 | struct nfsd3_symlinkargs *); | ||
| 292 | int nfs3svc_decode_readdirargs(struct svc_rqst *, __be32 *, | ||
| 293 | struct nfsd3_readdirargs *); | ||
| 294 | int nfs3svc_decode_readdirplusargs(struct svc_rqst *, __be32 *, | ||
| 295 | struct nfsd3_readdirargs *); | ||
| 296 | int nfs3svc_decode_commitargs(struct svc_rqst *, __be32 *, | ||
| 297 | struct nfsd3_commitargs *); | ||
| 298 | int nfs3svc_encode_voidres(struct svc_rqst *, __be32 *, void *); | ||
| 299 | int nfs3svc_encode_attrstat(struct svc_rqst *, __be32 *, | ||
| 300 | struct nfsd3_attrstat *); | ||
| 301 | int nfs3svc_encode_wccstat(struct svc_rqst *, __be32 *, | ||
| 302 | struct nfsd3_attrstat *); | ||
| 303 | int nfs3svc_encode_diropres(struct svc_rqst *, __be32 *, | ||
| 304 | struct nfsd3_diropres *); | ||
| 305 | int nfs3svc_encode_accessres(struct svc_rqst *, __be32 *, | ||
| 306 | struct nfsd3_accessres *); | ||
| 307 | int nfs3svc_encode_readlinkres(struct svc_rqst *, __be32 *, | ||
| 308 | struct nfsd3_readlinkres *); | ||
| 309 | int nfs3svc_encode_readres(struct svc_rqst *, __be32 *, struct nfsd3_readres *); | ||
| 310 | int nfs3svc_encode_writeres(struct svc_rqst *, __be32 *, struct nfsd3_writeres *); | ||
| 311 | int nfs3svc_encode_createres(struct svc_rqst *, __be32 *, | ||
| 312 | struct nfsd3_diropres *); | ||
| 313 | int nfs3svc_encode_renameres(struct svc_rqst *, __be32 *, | ||
| 314 | struct nfsd3_renameres *); | ||
| 315 | int nfs3svc_encode_linkres(struct svc_rqst *, __be32 *, | ||
| 316 | struct nfsd3_linkres *); | ||
| 317 | int nfs3svc_encode_readdirres(struct svc_rqst *, __be32 *, | ||
| 318 | struct nfsd3_readdirres *); | ||
| 319 | int nfs3svc_encode_fsstatres(struct svc_rqst *, __be32 *, | ||
| 320 | struct nfsd3_fsstatres *); | ||
| 321 | int nfs3svc_encode_fsinfores(struct svc_rqst *, __be32 *, | ||
| 322 | struct nfsd3_fsinfores *); | ||
| 323 | int nfs3svc_encode_pathconfres(struct svc_rqst *, __be32 *, | ||
| 324 | struct nfsd3_pathconfres *); | ||
| 325 | int nfs3svc_encode_commitres(struct svc_rqst *, __be32 *, | ||
| 326 | struct nfsd3_commitres *); | ||
| 327 | |||
| 328 | int nfs3svc_release_fhandle(struct svc_rqst *, __be32 *, | ||
| 329 | struct nfsd3_attrstat *); | ||
| 330 | int nfs3svc_release_fhandle2(struct svc_rqst *, __be32 *, | ||
| 331 | struct nfsd3_fhandle_pair *); | ||
| 332 | int nfs3svc_encode_entry(void *, const char *name, | ||
| 333 | int namlen, loff_t offset, u64 ino, | ||
| 334 | unsigned int); | ||
| 335 | int nfs3svc_encode_entry_plus(void *, const char *name, | ||
| 336 | int namlen, loff_t offset, u64 ino, | ||
| 337 | unsigned int); | ||
| 338 | /* Helper functions for NFSv3 ACL code */ | ||
| 339 | __be32 *nfs3svc_encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p, | ||
| 340 | struct svc_fh *fhp); | ||
| 341 | __be32 *nfs3svc_decode_fh(__be32 *p, struct svc_fh *fhp); | ||
| 342 | |||
| 343 | |||
| 344 | #endif /* _LINUX_NFSD_XDR3_H */ | ||
diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h new file mode 100644 index 000000000000..efa337739534 --- /dev/null +++ b/fs/nfsd/xdr4.h | |||
| @@ -0,0 +1,562 @@ | |||
| 1 | /* | ||
| 2 | * Server-side types for NFSv4. | ||
| 3 | * | ||
| 4 | * Copyright (c) 2002 The Regents of the University of Michigan. | ||
| 5 | * All rights reserved. | ||
| 6 | * | ||
| 7 | * Kendrick Smith <kmsmith@umich.edu> | ||
| 8 | * Andy Adamson <andros@umich.edu> | ||
| 9 | * | ||
| 10 | * Redistribution and use in source and binary forms, with or without | ||
| 11 | * modification, are permitted provided that the following conditions | ||
| 12 | * are met: | ||
| 13 | * | ||
| 14 | * 1. Redistributions of source code must retain the above copyright | ||
| 15 | * notice, this list of conditions and the following disclaimer. | ||
| 16 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 17 | * notice, this list of conditions and the following disclaimer in the | ||
| 18 | * documentation and/or other materials provided with the distribution. | ||
| 19 | * 3. Neither the name of the University nor the names of its | ||
| 20 | * contributors may be used to endorse or promote products derived | ||
| 21 | * from this software without specific prior written permission. | ||
| 22 | * | ||
| 23 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
| 24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| 25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
| 26 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
| 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| 28 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| 29 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
| 30 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
| 31 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
| 32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
| 33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 34 | * | ||
| 35 | */ | ||
| 36 | |||
| 37 | #ifndef _LINUX_NFSD_XDR4_H | ||
| 38 | #define _LINUX_NFSD_XDR4_H | ||
| 39 | |||
| 40 | #include "state.h" | ||
| 41 | #include "nfsd.h" | ||
| 42 | |||
| 43 | #define NFSD4_MAX_TAGLEN 128 | ||
| 44 | #define XDR_LEN(n) (((n) + 3) & ~3) | ||
| 45 | |||
| 46 | struct nfsd4_compound_state { | ||
| 47 | struct svc_fh current_fh; | ||
| 48 | struct svc_fh save_fh; | ||
| 49 | struct nfs4_stateowner *replay_owner; | ||
| 50 | /* For sessions DRC */ | ||
| 51 | struct nfsd4_session *session; | ||
| 52 | struct nfsd4_slot *slot; | ||
| 53 | __be32 *datap; | ||
| 54 | size_t iovlen; | ||
| 55 | u32 minorversion; | ||
| 56 | u32 status; | ||
| 57 | }; | ||
| 58 | |||
| 59 | static inline bool nfsd4_has_session(struct nfsd4_compound_state *cs) | ||
| 60 | { | ||
| 61 | return cs->slot != NULL; | ||
| 62 | } | ||
| 63 | |||
| 64 | struct nfsd4_change_info { | ||
| 65 | u32 atomic; | ||
| 66 | bool change_supported; | ||
| 67 | u32 before_ctime_sec; | ||
| 68 | u32 before_ctime_nsec; | ||
| 69 | u64 before_change; | ||
| 70 | u32 after_ctime_sec; | ||
| 71 | u32 after_ctime_nsec; | ||
| 72 | u64 after_change; | ||
| 73 | }; | ||
| 74 | |||
| 75 | struct nfsd4_access { | ||
| 76 | u32 ac_req_access; /* request */ | ||
| 77 | u32 ac_supported; /* response */ | ||
| 78 | u32 ac_resp_access; /* response */ | ||
| 79 | }; | ||
| 80 | |||
| 81 | struct nfsd4_close { | ||
| 82 | u32 cl_seqid; /* request */ | ||
| 83 | stateid_t cl_stateid; /* request+response */ | ||
| 84 | struct nfs4_stateowner * cl_stateowner; /* response */ | ||
| 85 | }; | ||
| 86 | |||
| 87 | struct nfsd4_commit { | ||
| 88 | u64 co_offset; /* request */ | ||
| 89 | u32 co_count; /* request */ | ||
| 90 | nfs4_verifier co_verf; /* response */ | ||
| 91 | }; | ||
| 92 | |||
| 93 | struct nfsd4_create { | ||
| 94 | u32 cr_namelen; /* request */ | ||
| 95 | char * cr_name; /* request */ | ||
| 96 | u32 cr_type; /* request */ | ||
| 97 | union { /* request */ | ||
| 98 | struct { | ||
| 99 | u32 namelen; | ||
| 100 | char *name; | ||
| 101 | } link; /* NF4LNK */ | ||
| 102 | struct { | ||
| 103 | u32 specdata1; | ||
| 104 | u32 specdata2; | ||
| 105 | } dev; /* NF4BLK, NF4CHR */ | ||
| 106 | } u; | ||
| 107 | u32 cr_bmval[3]; /* request */ | ||
| 108 | struct iattr cr_iattr; /* request */ | ||
| 109 | struct nfsd4_change_info cr_cinfo; /* response */ | ||
| 110 | struct nfs4_acl *cr_acl; | ||
| 111 | }; | ||
| 112 | #define cr_linklen u.link.namelen | ||
| 113 | #define cr_linkname u.link.name | ||
| 114 | #define cr_specdata1 u.dev.specdata1 | ||
| 115 | #define cr_specdata2 u.dev.specdata2 | ||
| 116 | |||
| 117 | struct nfsd4_delegreturn { | ||
| 118 | stateid_t dr_stateid; | ||
| 119 | }; | ||
| 120 | |||
| 121 | struct nfsd4_getattr { | ||
| 122 | u32 ga_bmval[3]; /* request */ | ||
| 123 | struct svc_fh *ga_fhp; /* response */ | ||
| 124 | }; | ||
| 125 | |||
| 126 | struct nfsd4_link { | ||
| 127 | u32 li_namelen; /* request */ | ||
| 128 | char * li_name; /* request */ | ||
| 129 | struct nfsd4_change_info li_cinfo; /* response */ | ||
| 130 | }; | ||
| 131 | |||
| 132 | struct nfsd4_lock_denied { | ||
| 133 | clientid_t ld_clientid; | ||
| 134 | struct nfs4_stateowner *ld_sop; | ||
| 135 | u64 ld_start; | ||
| 136 | u64 ld_length; | ||
| 137 | u32 ld_type; | ||
| 138 | }; | ||
| 139 | |||
| 140 | struct nfsd4_lock { | ||
| 141 | /* request */ | ||
| 142 | u32 lk_type; | ||
| 143 | u32 lk_reclaim; /* boolean */ | ||
| 144 | u64 lk_offset; | ||
| 145 | u64 lk_length; | ||
| 146 | u32 lk_is_new; | ||
| 147 | union { | ||
| 148 | struct { | ||
| 149 | u32 open_seqid; | ||
| 150 | stateid_t open_stateid; | ||
| 151 | u32 lock_seqid; | ||
| 152 | clientid_t clientid; | ||
| 153 | struct xdr_netobj owner; | ||
| 154 | } new; | ||
| 155 | struct { | ||
| 156 | stateid_t lock_stateid; | ||
| 157 | u32 lock_seqid; | ||
| 158 | } old; | ||
| 159 | } v; | ||
| 160 | |||
| 161 | /* response */ | ||
| 162 | union { | ||
| 163 | struct { | ||
| 164 | stateid_t stateid; | ||
| 165 | } ok; | ||
| 166 | struct nfsd4_lock_denied denied; | ||
| 167 | } u; | ||
| 168 | /* The lk_replay_owner is the open owner in the open_to_lock_owner | ||
| 169 | * case and the lock owner otherwise: */ | ||
| 170 | struct nfs4_stateowner *lk_replay_owner; | ||
| 171 | }; | ||
| 172 | #define lk_new_open_seqid v.new.open_seqid | ||
| 173 | #define lk_new_open_stateid v.new.open_stateid | ||
| 174 | #define lk_new_lock_seqid v.new.lock_seqid | ||
| 175 | #define lk_new_clientid v.new.clientid | ||
| 176 | #define lk_new_owner v.new.owner | ||
| 177 | #define lk_old_lock_stateid v.old.lock_stateid | ||
| 178 | #define lk_old_lock_seqid v.old.lock_seqid | ||
| 179 | |||
| 180 | #define lk_rflags u.ok.rflags | ||
| 181 | #define lk_resp_stateid u.ok.stateid | ||
| 182 | #define lk_denied u.denied | ||
| 183 | |||
| 184 | |||
| 185 | struct nfsd4_lockt { | ||
| 186 | u32 lt_type; | ||
| 187 | clientid_t lt_clientid; | ||
| 188 | struct xdr_netobj lt_owner; | ||
| 189 | u64 lt_offset; | ||
| 190 | u64 lt_length; | ||
| 191 | struct nfs4_stateowner * lt_stateowner; | ||
| 192 | struct nfsd4_lock_denied lt_denied; | ||
| 193 | }; | ||
| 194 | |||
| 195 | |||
| 196 | struct nfsd4_locku { | ||
| 197 | u32 lu_type; | ||
| 198 | u32 lu_seqid; | ||
| 199 | stateid_t lu_stateid; | ||
| 200 | u64 lu_offset; | ||
| 201 | u64 lu_length; | ||
| 202 | struct nfs4_stateowner *lu_stateowner; | ||
| 203 | }; | ||
| 204 | |||
| 205 | |||
| 206 | struct nfsd4_lookup { | ||
| 207 | u32 lo_len; /* request */ | ||
| 208 | char * lo_name; /* request */ | ||
| 209 | }; | ||
| 210 | |||
| 211 | struct nfsd4_putfh { | ||
| 212 | u32 pf_fhlen; /* request */ | ||
| 213 | char *pf_fhval; /* request */ | ||
| 214 | }; | ||
| 215 | |||
| 216 | struct nfsd4_open { | ||
| 217 | u32 op_claim_type; /* request */ | ||
| 218 | struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */ | ||
| 219 | u32 op_delegate_type; /* request - CLAIM_PREV only */ | ||
| 220 | stateid_t op_delegate_stateid; /* request - response */ | ||
| 221 | u32 op_create; /* request */ | ||
| 222 | u32 op_createmode; /* request */ | ||
| 223 | u32 op_bmval[3]; /* request */ | ||
| 224 | struct iattr iattr; /* UNCHECKED4, GUARDED4, EXCLUSIVE4_1 */ | ||
| 225 | nfs4_verifier verf; /* EXCLUSIVE4 */ | ||
| 226 | clientid_t op_clientid; /* request */ | ||
| 227 | struct xdr_netobj op_owner; /* request */ | ||
| 228 | u32 op_seqid; /* request */ | ||
| 229 | u32 op_share_access; /* request */ | ||
| 230 | u32 op_share_deny; /* request */ | ||
| 231 | stateid_t op_stateid; /* response */ | ||
| 232 | u32 op_recall; /* recall */ | ||
| 233 | struct nfsd4_change_info op_cinfo; /* response */ | ||
| 234 | u32 op_rflags; /* response */ | ||
| 235 | int op_truncate; /* used during processing */ | ||
| 236 | struct nfs4_stateowner *op_stateowner; /* used during processing */ | ||
| 237 | struct nfs4_acl *op_acl; | ||
| 238 | }; | ||
| 239 | #define op_iattr iattr | ||
| 240 | #define op_verf verf | ||
| 241 | |||
| 242 | struct nfsd4_open_confirm { | ||
| 243 | stateid_t oc_req_stateid /* request */; | ||
| 244 | u32 oc_seqid /* request */; | ||
| 245 | stateid_t oc_resp_stateid /* response */; | ||
| 246 | struct nfs4_stateowner * oc_stateowner; /* response */ | ||
| 247 | }; | ||
| 248 | |||
| 249 | struct nfsd4_open_downgrade { | ||
| 250 | stateid_t od_stateid; | ||
| 251 | u32 od_seqid; | ||
| 252 | u32 od_share_access; | ||
| 253 | u32 od_share_deny; | ||
| 254 | struct nfs4_stateowner *od_stateowner; | ||
| 255 | }; | ||
| 256 | |||
| 257 | |||
| 258 | struct nfsd4_read { | ||
| 259 | stateid_t rd_stateid; /* request */ | ||
| 260 | u64 rd_offset; /* request */ | ||
| 261 | u32 rd_length; /* request */ | ||
| 262 | int rd_vlen; | ||
| 263 | struct file *rd_filp; | ||
| 264 | |||
| 265 | struct svc_rqst *rd_rqstp; /* response */ | ||
| 266 | struct svc_fh * rd_fhp; /* response */ | ||
| 267 | }; | ||
| 268 | |||
| 269 | struct nfsd4_readdir { | ||
| 270 | u64 rd_cookie; /* request */ | ||
| 271 | nfs4_verifier rd_verf; /* request */ | ||
| 272 | u32 rd_dircount; /* request */ | ||
| 273 | u32 rd_maxcount; /* request */ | ||
| 274 | u32 rd_bmval[3]; /* request */ | ||
| 275 | struct svc_rqst *rd_rqstp; /* response */ | ||
| 276 | struct svc_fh * rd_fhp; /* response */ | ||
| 277 | |||
| 278 | struct readdir_cd common; | ||
| 279 | __be32 * buffer; | ||
| 280 | int buflen; | ||
| 281 | __be32 * offset; | ||
| 282 | }; | ||
| 283 | |||
| 284 | struct nfsd4_release_lockowner { | ||
| 285 | clientid_t rl_clientid; | ||
| 286 | struct xdr_netobj rl_owner; | ||
| 287 | }; | ||
| 288 | struct nfsd4_readlink { | ||
| 289 | struct svc_rqst *rl_rqstp; /* request */ | ||
| 290 | struct svc_fh * rl_fhp; /* request */ | ||
| 291 | }; | ||
| 292 | |||
| 293 | struct nfsd4_remove { | ||
| 294 | u32 rm_namelen; /* request */ | ||
| 295 | char * rm_name; /* request */ | ||
| 296 | struct nfsd4_change_info rm_cinfo; /* response */ | ||
| 297 | }; | ||
| 298 | |||
| 299 | struct nfsd4_rename { | ||
| 300 | u32 rn_snamelen; /* request */ | ||
| 301 | char * rn_sname; /* request */ | ||
| 302 | u32 rn_tnamelen; /* request */ | ||
| 303 | char * rn_tname; /* request */ | ||
| 304 | struct nfsd4_change_info rn_sinfo; /* response */ | ||
| 305 | struct nfsd4_change_info rn_tinfo; /* response */ | ||
| 306 | }; | ||
| 307 | |||
| 308 | struct nfsd4_secinfo { | ||
| 309 | u32 si_namelen; /* request */ | ||
| 310 | char *si_name; /* request */ | ||
| 311 | struct svc_export *si_exp; /* response */ | ||
| 312 | }; | ||
| 313 | |||
| 314 | struct nfsd4_setattr { | ||
| 315 | stateid_t sa_stateid; /* request */ | ||
| 316 | u32 sa_bmval[3]; /* request */ | ||
| 317 | struct iattr sa_iattr; /* request */ | ||
| 318 | struct nfs4_acl *sa_acl; | ||
| 319 | }; | ||
| 320 | |||
| 321 | struct nfsd4_setclientid { | ||
| 322 | nfs4_verifier se_verf; /* request */ | ||
| 323 | u32 se_namelen; /* request */ | ||
| 324 | char * se_name; /* request */ | ||
| 325 | u32 se_callback_prog; /* request */ | ||
| 326 | u32 se_callback_netid_len; /* request */ | ||
| 327 | char * se_callback_netid_val; /* request */ | ||
| 328 | u32 se_callback_addr_len; /* request */ | ||
| 329 | char * se_callback_addr_val; /* request */ | ||
| 330 | u32 se_callback_ident; /* request */ | ||
| 331 | clientid_t se_clientid; /* response */ | ||
| 332 | nfs4_verifier se_confirm; /* response */ | ||
| 333 | }; | ||
| 334 | |||
| 335 | struct nfsd4_setclientid_confirm { | ||
| 336 | clientid_t sc_clientid; | ||
| 337 | nfs4_verifier sc_confirm; | ||
| 338 | }; | ||
| 339 | |||
| 340 | /* also used for NVERIFY */ | ||
| 341 | struct nfsd4_verify { | ||
| 342 | u32 ve_bmval[3]; /* request */ | ||
| 343 | u32 ve_attrlen; /* request */ | ||
| 344 | char * ve_attrval; /* request */ | ||
| 345 | }; | ||
| 346 | |||
| 347 | struct nfsd4_write { | ||
| 348 | stateid_t wr_stateid; /* request */ | ||
| 349 | u64 wr_offset; /* request */ | ||
| 350 | u32 wr_stable_how; /* request */ | ||
| 351 | u32 wr_buflen; /* request */ | ||
| 352 | int wr_vlen; | ||
| 353 | |||
| 354 | u32 wr_bytes_written; /* response */ | ||
| 355 | u32 wr_how_written; /* response */ | ||
| 356 | nfs4_verifier wr_verifier; /* response */ | ||
| 357 | }; | ||
| 358 | |||
| 359 | struct nfsd4_exchange_id { | ||
| 360 | nfs4_verifier verifier; | ||
| 361 | struct xdr_netobj clname; | ||
| 362 | u32 flags; | ||
| 363 | clientid_t clientid; | ||
| 364 | u32 seqid; | ||
| 365 | int spa_how; | ||
| 366 | }; | ||
| 367 | |||
| 368 | struct nfsd4_sequence { | ||
| 369 | struct nfs4_sessionid sessionid; /* request/response */ | ||
| 370 | u32 seqid; /* request/response */ | ||
| 371 | u32 slotid; /* request/response */ | ||
| 372 | u32 maxslots; /* request/response */ | ||
| 373 | u32 cachethis; /* request */ | ||
| 374 | #if 0 | ||
| 375 | u32 target_maxslots; /* response */ | ||
| 376 | u32 status_flags; /* response */ | ||
| 377 | #endif /* not yet */ | ||
| 378 | }; | ||
| 379 | |||
| 380 | struct nfsd4_destroy_session { | ||
| 381 | struct nfs4_sessionid sessionid; | ||
| 382 | }; | ||
| 383 | |||
| 384 | struct nfsd4_op { | ||
| 385 | int opnum; | ||
| 386 | __be32 status; | ||
| 387 | union { | ||
| 388 | struct nfsd4_access access; | ||
| 389 | struct nfsd4_close close; | ||
| 390 | struct nfsd4_commit commit; | ||
| 391 | struct nfsd4_create create; | ||
| 392 | struct nfsd4_delegreturn delegreturn; | ||
| 393 | struct nfsd4_getattr getattr; | ||
| 394 | struct svc_fh * getfh; | ||
| 395 | struct nfsd4_link link; | ||
| 396 | struct nfsd4_lock lock; | ||
| 397 | struct nfsd4_lockt lockt; | ||
| 398 | struct nfsd4_locku locku; | ||
| 399 | struct nfsd4_lookup lookup; | ||
| 400 | struct nfsd4_verify nverify; | ||
| 401 | struct nfsd4_open open; | ||
| 402 | struct nfsd4_open_confirm open_confirm; | ||
| 403 | struct nfsd4_open_downgrade open_downgrade; | ||
| 404 | struct nfsd4_putfh putfh; | ||
| 405 | struct nfsd4_read read; | ||
| 406 | struct nfsd4_readdir readdir; | ||
| 407 | struct nfsd4_readlink readlink; | ||
| 408 | struct nfsd4_remove remove; | ||
| 409 | struct nfsd4_rename rename; | ||
| 410 | clientid_t renew; | ||
| 411 | struct nfsd4_secinfo secinfo; | ||
| 412 | struct nfsd4_setattr setattr; | ||
| 413 | struct nfsd4_setclientid setclientid; | ||
| 414 | struct nfsd4_setclientid_confirm setclientid_confirm; | ||
| 415 | struct nfsd4_verify verify; | ||
| 416 | struct nfsd4_write write; | ||
| 417 | struct nfsd4_release_lockowner release_lockowner; | ||
| 418 | |||
| 419 | /* NFSv4.1 */ | ||
| 420 | struct nfsd4_exchange_id exchange_id; | ||
| 421 | struct nfsd4_create_session create_session; | ||
| 422 | struct nfsd4_destroy_session destroy_session; | ||
| 423 | struct nfsd4_sequence sequence; | ||
| 424 | } u; | ||
| 425 | struct nfs4_replay * replay; | ||
| 426 | }; | ||
| 427 | |||
| 428 | struct nfsd4_compoundargs { | ||
| 429 | /* scratch variables for XDR decode */ | ||
| 430 | __be32 * p; | ||
| 431 | __be32 * end; | ||
| 432 | struct page ** pagelist; | ||
| 433 | int pagelen; | ||
| 434 | __be32 tmp[8]; | ||
| 435 | __be32 * tmpp; | ||
| 436 | struct tmpbuf { | ||
| 437 | struct tmpbuf *next; | ||
| 438 | void (*release)(const void *); | ||
| 439 | void *buf; | ||
| 440 | } *to_free; | ||
| 441 | |||
| 442 | struct svc_rqst *rqstp; | ||
| 443 | |||
| 444 | u32 taglen; | ||
| 445 | char * tag; | ||
| 446 | u32 minorversion; | ||
| 447 | u32 opcnt; | ||
| 448 | struct nfsd4_op *ops; | ||
| 449 | struct nfsd4_op iops[8]; | ||
| 450 | }; | ||
| 451 | |||
| 452 | struct nfsd4_compoundres { | ||
| 453 | /* scratch variables for XDR encode */ | ||
| 454 | __be32 * p; | ||
| 455 | __be32 * end; | ||
| 456 | struct xdr_buf * xbuf; | ||
| 457 | struct svc_rqst * rqstp; | ||
| 458 | |||
| 459 | u32 taglen; | ||
| 460 | char * tag; | ||
| 461 | u32 opcnt; | ||
| 462 | __be32 * tagp; /* tag, opcount encode location */ | ||
| 463 | struct nfsd4_compound_state cstate; | ||
| 464 | }; | ||
| 465 | |||
| 466 | static inline bool nfsd4_is_solo_sequence(struct nfsd4_compoundres *resp) | ||
| 467 | { | ||
| 468 | struct nfsd4_compoundargs *args = resp->rqstp->rq_argp; | ||
| 469 | return resp->opcnt == 1 && args->ops[0].opnum == OP_SEQUENCE; | ||
| 470 | } | ||
| 471 | |||
| 472 | static inline bool nfsd4_not_cached(struct nfsd4_compoundres *resp) | ||
| 473 | { | ||
| 474 | return !resp->cstate.slot->sl_cachethis || nfsd4_is_solo_sequence(resp); | ||
| 475 | } | ||
| 476 | |||
| 477 | #define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs) | ||
| 478 | |||
| 479 | static inline void | ||
| 480 | set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp) | ||
| 481 | { | ||
| 482 | BUG_ON(!fhp->fh_pre_saved || !fhp->fh_post_saved); | ||
| 483 | cinfo->atomic = 1; | ||
| 484 | cinfo->change_supported = IS_I_VERSION(fhp->fh_dentry->d_inode); | ||
| 485 | if (cinfo->change_supported) { | ||
| 486 | cinfo->before_change = fhp->fh_pre_change; | ||
| 487 | cinfo->after_change = fhp->fh_post_change; | ||
| 488 | } else { | ||
| 489 | cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec; | ||
| 490 | cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec; | ||
| 491 | cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec; | ||
| 492 | cinfo->after_ctime_nsec = fhp->fh_post_attr.ctime.tv_nsec; | ||
| 493 | } | ||
| 494 | } | ||
| 495 | |||
| 496 | int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *, void *); | ||
| 497 | int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *, | ||
| 498 | struct nfsd4_compoundargs *); | ||
| 499 | int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *, | ||
| 500 | struct nfsd4_compoundres *); | ||
| 501 | void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *); | ||
| 502 | void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op); | ||
| 503 | __be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, | ||
| 504 | struct dentry *dentry, __be32 *buffer, int *countp, | ||
| 505 | u32 *bmval, struct svc_rqst *, int ignore_crossmnt); | ||
| 506 | extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp, | ||
| 507 | struct nfsd4_compound_state *, | ||
| 508 | struct nfsd4_setclientid *setclid); | ||
| 509 | extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp, | ||
| 510 | struct nfsd4_compound_state *, | ||
| 511 | struct nfsd4_setclientid_confirm *setclientid_confirm); | ||
| 512 | extern void nfsd4_store_cache_entry(struct nfsd4_compoundres *resp); | ||
| 513 | extern __be32 nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp, | ||
| 514 | struct nfsd4_sequence *seq); | ||
| 515 | extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp, | ||
| 516 | struct nfsd4_compound_state *, | ||
| 517 | struct nfsd4_exchange_id *); | ||
| 518 | extern __be32 nfsd4_create_session(struct svc_rqst *, | ||
| 519 | struct nfsd4_compound_state *, | ||
| 520 | struct nfsd4_create_session *); | ||
| 521 | extern __be32 nfsd4_sequence(struct svc_rqst *, | ||
| 522 | struct nfsd4_compound_state *, | ||
| 523 | struct nfsd4_sequence *); | ||
| 524 | extern __be32 nfsd4_destroy_session(struct svc_rqst *, | ||
| 525 | struct nfsd4_compound_state *, | ||
| 526 | struct nfsd4_destroy_session *); | ||
| 527 | extern __be32 nfsd4_process_open1(struct nfsd4_compound_state *, | ||
| 528 | struct nfsd4_open *open); | ||
| 529 | extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp, | ||
| 530 | struct svc_fh *current_fh, struct nfsd4_open *open); | ||
| 531 | extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp, | ||
| 532 | struct nfsd4_compound_state *, struct nfsd4_open_confirm *oc); | ||
| 533 | extern __be32 nfsd4_close(struct svc_rqst *rqstp, | ||
| 534 | struct nfsd4_compound_state *, | ||
| 535 | struct nfsd4_close *close); | ||
| 536 | extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp, | ||
| 537 | struct nfsd4_compound_state *, | ||
| 538 | struct nfsd4_open_downgrade *od); | ||
| 539 | extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *, | ||
| 540 | struct nfsd4_lock *lock); | ||
| 541 | extern __be32 nfsd4_lockt(struct svc_rqst *rqstp, | ||
| 542 | struct nfsd4_compound_state *, | ||
| 543 | struct nfsd4_lockt *lockt); | ||
| 544 | extern __be32 nfsd4_locku(struct svc_rqst *rqstp, | ||
| 545 | struct nfsd4_compound_state *, | ||
| 546 | struct nfsd4_locku *locku); | ||
| 547 | extern __be32 | ||
| 548 | nfsd4_release_lockowner(struct svc_rqst *rqstp, | ||
| 549 | struct nfsd4_compound_state *, | ||
| 550 | struct nfsd4_release_lockowner *rlockowner); | ||
| 551 | extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *); | ||
| 552 | extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp, | ||
| 553 | struct nfsd4_compound_state *, struct nfsd4_delegreturn *dr); | ||
| 554 | extern __be32 nfsd4_renew(struct svc_rqst *rqstp, | ||
| 555 | struct nfsd4_compound_state *, clientid_t *clid); | ||
| 556 | #endif | ||
| 557 | |||
| 558 | /* | ||
| 559 | * Local variables: | ||
| 560 | * c-basic-offset: 8 | ||
| 561 | * End: | ||
| 562 | */ | ||
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 5403b3ef3a42..8173faee31e6 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c | |||
| @@ -1118,8 +1118,7 @@ nilfs_get_sb(struct file_system_type *fs_type, int flags, | |||
| 1118 | /* Abandoning the newly allocated superblock */ | 1118 | /* Abandoning the newly allocated superblock */ |
| 1119 | mutex_unlock(&nilfs->ns_mount_mutex); | 1119 | mutex_unlock(&nilfs->ns_mount_mutex); |
| 1120 | put_nilfs(nilfs); | 1120 | put_nilfs(nilfs); |
| 1121 | up_write(&s->s_umount); | 1121 | deactivate_locked_super(s); |
| 1122 | deactivate_super(s); | ||
| 1123 | /* | 1122 | /* |
| 1124 | * deactivate_super() invokes close_bdev_exclusive(). | 1123 | * deactivate_super() invokes close_bdev_exclusive(). |
| 1125 | * We must finish all post-cleaning before this call; | 1124 | * We must finish all post-cleaning before this call; |
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 5ef5f365a5c8..8271cf05c957 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c | |||
| @@ -646,6 +646,7 @@ SYSCALL_DEFINE1(inotify_init1, int, flags) | |||
| 646 | struct fsnotify_group *group; | 646 | struct fsnotify_group *group; |
| 647 | struct user_struct *user; | 647 | struct user_struct *user; |
| 648 | struct file *filp; | 648 | struct file *filp; |
| 649 | struct path path; | ||
| 649 | int fd, ret; | 650 | int fd, ret; |
| 650 | 651 | ||
| 651 | /* Check the IN_* constants for consistency. */ | 652 | /* Check the IN_* constants for consistency. */ |
| @@ -659,12 +660,6 @@ SYSCALL_DEFINE1(inotify_init1, int, flags) | |||
| 659 | if (fd < 0) | 660 | if (fd < 0) |
| 660 | return fd; | 661 | return fd; |
| 661 | 662 | ||
| 662 | filp = get_empty_filp(); | ||
| 663 | if (!filp) { | ||
| 664 | ret = -ENFILE; | ||
| 665 | goto out_put_fd; | ||
| 666 | } | ||
| 667 | |||
| 668 | user = get_current_user(); | 663 | user = get_current_user(); |
| 669 | if (unlikely(atomic_read(&user->inotify_devs) >= | 664 | if (unlikely(atomic_read(&user->inotify_devs) >= |
| 670 | inotify_max_user_instances)) { | 665 | inotify_max_user_instances)) { |
| @@ -679,24 +674,28 @@ SYSCALL_DEFINE1(inotify_init1, int, flags) | |||
| 679 | goto out_free_uid; | 674 | goto out_free_uid; |
| 680 | } | 675 | } |
| 681 | 676 | ||
| 682 | filp->f_op = &inotify_fops; | 677 | atomic_inc(&user->inotify_devs); |
| 683 | filp->f_path.mnt = mntget(inotify_mnt); | 678 | |
| 684 | filp->f_path.dentry = dget(inotify_mnt->mnt_root); | 679 | path.mnt = inotify_mnt; |
| 685 | filp->f_mapping = filp->f_path.dentry->d_inode->i_mapping; | 680 | path.dentry = inotify_mnt->mnt_root; |
| 686 | filp->f_mode = FMODE_READ; | 681 | path_get(&path); |
| 682 | filp = alloc_file(&path, FMODE_READ, &inotify_fops); | ||
| 683 | if (!filp) | ||
| 684 | goto Enfile; | ||
| 685 | |||
| 687 | filp->f_flags = O_RDONLY | (flags & O_NONBLOCK); | 686 | filp->f_flags = O_RDONLY | (flags & O_NONBLOCK); |
| 688 | filp->private_data = group; | 687 | filp->private_data = group; |
| 689 | 688 | ||
| 690 | atomic_inc(&user->inotify_devs); | ||
| 691 | |||
| 692 | fd_install(fd, filp); | 689 | fd_install(fd, filp); |
| 693 | 690 | ||
| 694 | return fd; | 691 | return fd; |
| 695 | 692 | ||
| 693 | Enfile: | ||
| 694 | ret = -ENFILE; | ||
| 695 | path_put(&path); | ||
| 696 | atomic_dec(&user->inotify_devs); | ||
| 696 | out_free_uid: | 697 | out_free_uid: |
| 697 | free_uid(user); | 698 | free_uid(user); |
| 698 | put_filp(filp); | ||
| 699 | out_put_fd: | ||
| 700 | put_unused_fd(fd); | 699 | put_unused_fd(fd); |
| 701 | return ret; | 700 | return ret; |
| 702 | } | 701 | } |
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 9938034762cc..dc2505abb6d7 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c | |||
| @@ -530,7 +530,7 @@ err_corrupt_attr: | |||
| 530 | * the ntfs inode. | 530 | * the ntfs inode. |
| 531 | * | 531 | * |
| 532 | * Q: What locks are held when the function is called? | 532 | * Q: What locks are held when the function is called? |
| 533 | * A: i_state has I_LOCK set, hence the inode is locked, also | 533 | * A: i_state has I_NEW set, hence the inode is locked, also |
| 534 | * i_count is set to 1, so it is not going to go away | 534 | * i_count is set to 1, so it is not going to go away |
| 535 | * i_flags is set to 0 and we have no business touching it. Only an ioctl() | 535 | * i_flags is set to 0 and we have no business touching it. Only an ioctl() |
| 536 | * is allowed to write to them. We should of course be honouring them but | 536 | * is allowed to write to them. We should of course be honouring them but |
| @@ -1207,7 +1207,7 @@ err_out: | |||
| 1207 | * necessary fields in @vi as well as initializing the ntfs inode. | 1207 | * necessary fields in @vi as well as initializing the ntfs inode. |
| 1208 | * | 1208 | * |
| 1209 | * Q: What locks are held when the function is called? | 1209 | * Q: What locks are held when the function is called? |
| 1210 | * A: i_state has I_LOCK set, hence the inode is locked, also | 1210 | * A: i_state has I_NEW set, hence the inode is locked, also |
| 1211 | * i_count is set to 1, so it is not going to go away | 1211 | * i_count is set to 1, so it is not going to go away |
| 1212 | * | 1212 | * |
| 1213 | * Return 0 on success and -errno on error. In the error case, the inode will | 1213 | * Return 0 on success and -errno on error. In the error case, the inode will |
| @@ -1474,7 +1474,7 @@ err_out: | |||
| 1474 | * normal directory inodes. | 1474 | * normal directory inodes. |
| 1475 | * | 1475 | * |
| 1476 | * Q: What locks are held when the function is called? | 1476 | * Q: What locks are held when the function is called? |
| 1477 | * A: i_state has I_LOCK set, hence the inode is locked, also | 1477 | * A: i_state has I_NEW set, hence the inode is locked, also |
| 1478 | * i_count is set to 1, so it is not going to go away | 1478 | * i_count is set to 1, so it is not going to go away |
| 1479 | * | 1479 | * |
| 1480 | * Return 0 on success and -errno on error. In the error case, the inode will | 1480 | * Return 0 on success and -errno on error. In the error case, the inode will |
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c index fbeaec762103..e3e47415d851 100644 --- a/fs/ocfs2/acl.c +++ b/fs/ocfs2/acl.c | |||
| @@ -331,13 +331,14 @@ cleanup: | |||
| 331 | return ret; | 331 | return ret; |
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | static size_t ocfs2_xattr_list_acl_access(struct inode *inode, | 334 | static size_t ocfs2_xattr_list_acl_access(struct dentry *dentry, |
| 335 | char *list, | 335 | char *list, |
| 336 | size_t list_len, | 336 | size_t list_len, |
| 337 | const char *name, | 337 | const char *name, |
| 338 | size_t name_len) | 338 | size_t name_len, |
| 339 | int type) | ||
| 339 | { | 340 | { |
| 340 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 341 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); |
| 341 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); | 342 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); |
| 342 | 343 | ||
| 343 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | 344 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) |
| @@ -348,13 +349,14 @@ static size_t ocfs2_xattr_list_acl_access(struct inode *inode, | |||
| 348 | return size; | 349 | return size; |
| 349 | } | 350 | } |
| 350 | 351 | ||
| 351 | static size_t ocfs2_xattr_list_acl_default(struct inode *inode, | 352 | static size_t ocfs2_xattr_list_acl_default(struct dentry *dentry, |
| 352 | char *list, | 353 | char *list, |
| 353 | size_t list_len, | 354 | size_t list_len, |
| 354 | const char *name, | 355 | const char *name, |
| 355 | size_t name_len) | 356 | size_t name_len, |
| 357 | int type) | ||
| 356 | { | 358 | { |
| 357 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 359 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); |
| 358 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); | 360 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); |
| 359 | 361 | ||
| 360 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | 362 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) |
| @@ -365,19 +367,19 @@ static size_t ocfs2_xattr_list_acl_default(struct inode *inode, | |||
| 365 | return size; | 367 | return size; |
| 366 | } | 368 | } |
| 367 | 369 | ||
| 368 | static int ocfs2_xattr_get_acl(struct inode *inode, | 370 | static int ocfs2_xattr_get_acl(struct dentry *dentry, const char *name, |
| 369 | int type, | 371 | void *buffer, size_t size, int type) |
| 370 | void *buffer, | ||
| 371 | size_t size) | ||
| 372 | { | 372 | { |
| 373 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 373 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); |
| 374 | struct posix_acl *acl; | 374 | struct posix_acl *acl; |
| 375 | int ret; | 375 | int ret; |
| 376 | 376 | ||
| 377 | if (strcmp(name, "") != 0) | ||
| 378 | return -EINVAL; | ||
| 377 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | 379 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) |
| 378 | return -EOPNOTSUPP; | 380 | return -EOPNOTSUPP; |
| 379 | 381 | ||
| 380 | acl = ocfs2_get_acl(inode, type); | 382 | acl = ocfs2_get_acl(dentry->d_inode, type); |
| 381 | if (IS_ERR(acl)) | 383 | if (IS_ERR(acl)) |
| 382 | return PTR_ERR(acl); | 384 | return PTR_ERR(acl); |
| 383 | if (acl == NULL) | 385 | if (acl == NULL) |
| @@ -388,35 +390,16 @@ static int ocfs2_xattr_get_acl(struct inode *inode, | |||
| 388 | return ret; | 390 | return ret; |
| 389 | } | 391 | } |
| 390 | 392 | ||
| 391 | static int ocfs2_xattr_get_acl_access(struct inode *inode, | 393 | static int ocfs2_xattr_set_acl(struct dentry *dentry, const char *name, |
| 392 | const char *name, | 394 | const void *value, size_t size, int flags, int type) |
| 393 | void *buffer, | ||
| 394 | size_t size) | ||
| 395 | { | ||
| 396 | if (strcmp(name, "") != 0) | ||
| 397 | return -EINVAL; | ||
| 398 | return ocfs2_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); | ||
| 399 | } | ||
| 400 | |||
| 401 | static int ocfs2_xattr_get_acl_default(struct inode *inode, | ||
| 402 | const char *name, | ||
| 403 | void *buffer, | ||
| 404 | size_t size) | ||
| 405 | { | ||
| 406 | if (strcmp(name, "") != 0) | ||
| 407 | return -EINVAL; | ||
| 408 | return ocfs2_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); | ||
| 409 | } | ||
| 410 | |||
| 411 | static int ocfs2_xattr_set_acl(struct inode *inode, | ||
| 412 | int type, | ||
| 413 | const void *value, | ||
| 414 | size_t size) | ||
| 415 | { | 395 | { |
| 396 | struct inode *inode = dentry->d_inode; | ||
| 416 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 397 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
| 417 | struct posix_acl *acl; | 398 | struct posix_acl *acl; |
| 418 | int ret = 0; | 399 | int ret = 0; |
| 419 | 400 | ||
| 401 | if (strcmp(name, "") != 0) | ||
| 402 | return -EINVAL; | ||
| 420 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | 403 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) |
| 421 | return -EOPNOTSUPP; | 404 | return -EOPNOTSUPP; |
| 422 | 405 | ||
| @@ -442,38 +425,18 @@ cleanup: | |||
| 442 | return ret; | 425 | return ret; |
| 443 | } | 426 | } |
| 444 | 427 | ||
| 445 | static int ocfs2_xattr_set_acl_access(struct inode *inode, | ||
| 446 | const char *name, | ||
| 447 | const void *value, | ||
| 448 | size_t size, | ||
| 449 | int flags) | ||
| 450 | { | ||
| 451 | if (strcmp(name, "") != 0) | ||
| 452 | return -EINVAL; | ||
| 453 | return ocfs2_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
| 454 | } | ||
| 455 | |||
| 456 | static int ocfs2_xattr_set_acl_default(struct inode *inode, | ||
| 457 | const char *name, | ||
| 458 | const void *value, | ||
| 459 | size_t size, | ||
| 460 | int flags) | ||
| 461 | { | ||
| 462 | if (strcmp(name, "") != 0) | ||
| 463 | return -EINVAL; | ||
| 464 | return ocfs2_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
| 465 | } | ||
| 466 | |||
| 467 | struct xattr_handler ocfs2_xattr_acl_access_handler = { | 428 | struct xattr_handler ocfs2_xattr_acl_access_handler = { |
| 468 | .prefix = POSIX_ACL_XATTR_ACCESS, | 429 | .prefix = POSIX_ACL_XATTR_ACCESS, |
| 430 | .flags = ACL_TYPE_ACCESS, | ||
| 469 | .list = ocfs2_xattr_list_acl_access, | 431 | .list = ocfs2_xattr_list_acl_access, |
| 470 | .get = ocfs2_xattr_get_acl_access, | 432 | .get = ocfs2_xattr_get_acl, |
| 471 | .set = ocfs2_xattr_set_acl_access, | 433 | .set = ocfs2_xattr_set_acl, |
| 472 | }; | 434 | }; |
| 473 | 435 | ||
| 474 | struct xattr_handler ocfs2_xattr_acl_default_handler = { | 436 | struct xattr_handler ocfs2_xattr_acl_default_handler = { |
| 475 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 437 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
| 438 | .flags = ACL_TYPE_DEFAULT, | ||
| 476 | .list = ocfs2_xattr_list_acl_default, | 439 | .list = ocfs2_xattr_list_acl_default, |
| 477 | .get = ocfs2_xattr_get_acl_default, | 440 | .get = ocfs2_xattr_get_acl, |
| 478 | .set = ocfs2_xattr_set_acl_default, | 441 | .set = ocfs2_xattr_set_acl, |
| 479 | }; | 442 | }; |
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 7c7198a5bc90..fb4e672579b8 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
| @@ -7190,8 +7190,8 @@ int ocfs2_zero_range_for_truncate(struct inode *inode, handle_t *handle, | |||
| 7190 | * wait on them - the truncate_inode_pages() call later will | 7190 | * wait on them - the truncate_inode_pages() call later will |
| 7191 | * do that for us. | 7191 | * do that for us. |
| 7192 | */ | 7192 | */ |
| 7193 | ret = do_sync_mapping_range(inode->i_mapping, range_start, | 7193 | ret = filemap_fdatawrite_range(inode->i_mapping, range_start, |
| 7194 | range_end - 1, SYNC_FILE_RANGE_WRITE); | 7194 | range_end - 1); |
| 7195 | if (ret) | 7195 | if (ret) |
| 7196 | mlog_errno(ret); | 7196 | mlog_errno(ret); |
| 7197 | 7197 | ||
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index deb2b132ae5e..3dae4a13f6e4 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
| @@ -547,6 +547,9 @@ bail: | |||
| 547 | * | 547 | * |
| 548 | * called like this: dio->get_blocks(dio->inode, fs_startblk, | 548 | * called like this: dio->get_blocks(dio->inode, fs_startblk, |
| 549 | * fs_count, map_bh, dio->rw == WRITE); | 549 | * fs_count, map_bh, dio->rw == WRITE); |
| 550 | * | ||
| 551 | * Note that we never bother to allocate blocks here, and thus ignore the | ||
| 552 | * create argument. | ||
| 550 | */ | 553 | */ |
| 551 | static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, | 554 | static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, |
| 552 | struct buffer_head *bh_result, int create) | 555 | struct buffer_head *bh_result, int create) |
| @@ -563,14 +566,6 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, | |||
| 563 | 566 | ||
| 564 | inode_blocks = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode)); | 567 | inode_blocks = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode)); |
| 565 | 568 | ||
| 566 | /* | ||
| 567 | * Any write past EOF is not allowed because we'd be extending. | ||
| 568 | */ | ||
| 569 | if (create && (iblock + max_blocks) > inode_blocks) { | ||
| 570 | ret = -EIO; | ||
| 571 | goto bail; | ||
| 572 | } | ||
| 573 | |||
| 574 | /* This figures out the size of the next contiguous block, and | 569 | /* This figures out the size of the next contiguous block, and |
| 575 | * our logical offset */ | 570 | * our logical offset */ |
| 576 | ret = ocfs2_extent_map_get_blocks(inode, iblock, &p_blkno, | 571 | ret = ocfs2_extent_map_get_blocks(inode, iblock, &p_blkno, |
| @@ -582,15 +577,6 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, | |||
| 582 | goto bail; | 577 | goto bail; |
| 583 | } | 578 | } |
| 584 | 579 | ||
| 585 | if (!ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb)) && !p_blkno && create) { | ||
| 586 | ocfs2_error(inode->i_sb, | ||
| 587 | "Inode %llu has a hole at block %llu\n", | ||
| 588 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | ||
| 589 | (unsigned long long)iblock); | ||
| 590 | ret = -EROFS; | ||
| 591 | goto bail; | ||
| 592 | } | ||
| 593 | |||
| 594 | /* We should already CoW the refcounted extent. */ | 580 | /* We should already CoW the refcounted extent. */ |
| 595 | BUG_ON(ext_flags & OCFS2_EXT_REFCOUNTED); | 581 | BUG_ON(ext_flags & OCFS2_EXT_REFCOUNTED); |
| 596 | /* | 582 | /* |
| @@ -601,20 +587,8 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, | |||
| 601 | */ | 587 | */ |
| 602 | if (p_blkno && !(ext_flags & OCFS2_EXT_UNWRITTEN)) | 588 | if (p_blkno && !(ext_flags & OCFS2_EXT_UNWRITTEN)) |
| 603 | map_bh(bh_result, inode->i_sb, p_blkno); | 589 | map_bh(bh_result, inode->i_sb, p_blkno); |
| 604 | else { | 590 | else |
| 605 | /* | ||
| 606 | * ocfs2_prepare_inode_for_write() should have caught | ||
| 607 | * the case where we'd be filling a hole and triggered | ||
| 608 | * a buffered write instead. | ||
| 609 | */ | ||
| 610 | if (create) { | ||
| 611 | ret = -EIO; | ||
| 612 | mlog_errno(ret); | ||
| 613 | goto bail; | ||
| 614 | } | ||
| 615 | |||
| 616 | clear_buffer_mapped(bh_result); | 591 | clear_buffer_mapped(bh_result); |
| 617 | } | ||
| 618 | 592 | ||
| 619 | /* make sure we don't map more than max_blocks blocks here as | 593 | /* make sure we don't map more than max_blocks blocks here as |
| 620 | that's all the kernel will handle at this point. */ | 594 | that's all the kernel will handle at this point. */ |
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index fe3419068df2..43c114831c0d 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
| @@ -205,8 +205,6 @@ static int ocfs2_get_xattr_tree_value_root(struct super_block *sb, | |||
| 205 | int offset, | 205 | int offset, |
| 206 | struct ocfs2_xattr_value_root **xv, | 206 | struct ocfs2_xattr_value_root **xv, |
| 207 | struct buffer_head **bh); | 207 | struct buffer_head **bh); |
| 208 | static int ocfs2_xattr_security_set(struct inode *inode, const char *name, | ||
| 209 | const void *value, size_t size, int flags); | ||
| 210 | 208 | ||
| 211 | static inline u16 ocfs2_xattr_buckets_per_cluster(struct ocfs2_super *osb) | 209 | static inline u16 ocfs2_xattr_buckets_per_cluster(struct ocfs2_super *osb) |
| 212 | { | 210 | { |
| @@ -6978,9 +6976,9 @@ int ocfs2_init_security_and_acl(struct inode *dir, | |||
| 6978 | 6976 | ||
| 6979 | ret = ocfs2_init_security_get(inode, dir, &si); | 6977 | ret = ocfs2_init_security_get(inode, dir, &si); |
| 6980 | if (!ret) { | 6978 | if (!ret) { |
| 6981 | ret = ocfs2_xattr_security_set(inode, si.name, | 6979 | ret = ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, |
| 6982 | si.value, si.value_len, | 6980 | si.name, si.value, si.value_len, |
| 6983 | XATTR_CREATE); | 6981 | XATTR_CREATE); |
| 6984 | if (ret) { | 6982 | if (ret) { |
| 6985 | mlog_errno(ret); | 6983 | mlog_errno(ret); |
| 6986 | goto leave; | 6984 | goto leave; |
| @@ -7008,9 +7006,9 @@ leave: | |||
| 7008 | /* | 7006 | /* |
| 7009 | * 'security' attributes support | 7007 | * 'security' attributes support |
| 7010 | */ | 7008 | */ |
| 7011 | static size_t ocfs2_xattr_security_list(struct inode *inode, char *list, | 7009 | static size_t ocfs2_xattr_security_list(struct dentry *dentry, char *list, |
| 7012 | size_t list_size, const char *name, | 7010 | size_t list_size, const char *name, |
| 7013 | size_t name_len) | 7011 | size_t name_len, int type) |
| 7014 | { | 7012 | { |
| 7015 | const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN; | 7013 | const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN; |
| 7016 | const size_t total_len = prefix_len + name_len + 1; | 7014 | const size_t total_len = prefix_len + name_len + 1; |
| @@ -7023,23 +7021,23 @@ static size_t ocfs2_xattr_security_list(struct inode *inode, char *list, | |||
| 7023 | return total_len; | 7021 | return total_len; |
| 7024 | } | 7022 | } |
| 7025 | 7023 | ||
| 7026 | static int ocfs2_xattr_security_get(struct inode *inode, const char *name, | 7024 | static int ocfs2_xattr_security_get(struct dentry *dentry, const char *name, |
| 7027 | void *buffer, size_t size) | 7025 | void *buffer, size_t size, int type) |
| 7028 | { | 7026 | { |
| 7029 | if (strcmp(name, "") == 0) | 7027 | if (strcmp(name, "") == 0) |
| 7030 | return -EINVAL; | 7028 | return -EINVAL; |
| 7031 | return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_SECURITY, name, | 7029 | return ocfs2_xattr_get(dentry->d_inode, OCFS2_XATTR_INDEX_SECURITY, |
| 7032 | buffer, size); | 7030 | name, buffer, size); |
| 7033 | } | 7031 | } |
| 7034 | 7032 | ||
| 7035 | static int ocfs2_xattr_security_set(struct inode *inode, const char *name, | 7033 | static int ocfs2_xattr_security_set(struct dentry *dentry, const char *name, |
| 7036 | const void *value, size_t size, int flags) | 7034 | const void *value, size_t size, int flags, int type) |
| 7037 | { | 7035 | { |
| 7038 | if (strcmp(name, "") == 0) | 7036 | if (strcmp(name, "") == 0) |
| 7039 | return -EINVAL; | 7037 | return -EINVAL; |
| 7040 | 7038 | ||
| 7041 | return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, name, value, | 7039 | return ocfs2_xattr_set(dentry->d_inode, OCFS2_XATTR_INDEX_SECURITY, |
| 7042 | size, flags); | 7040 | name, value, size, flags); |
| 7043 | } | 7041 | } |
| 7044 | 7042 | ||
| 7045 | int ocfs2_init_security_get(struct inode *inode, | 7043 | int ocfs2_init_security_get(struct inode *inode, |
| @@ -7076,9 +7074,9 @@ struct xattr_handler ocfs2_xattr_security_handler = { | |||
| 7076 | /* | 7074 | /* |
| 7077 | * 'trusted' attributes support | 7075 | * 'trusted' attributes support |
| 7078 | */ | 7076 | */ |
| 7079 | static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list, | 7077 | static size_t ocfs2_xattr_trusted_list(struct dentry *dentry, char *list, |
| 7080 | size_t list_size, const char *name, | 7078 | size_t list_size, const char *name, |
| 7081 | size_t name_len) | 7079 | size_t name_len, int type) |
| 7082 | { | 7080 | { |
| 7083 | const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; | 7081 | const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN; |
| 7084 | const size_t total_len = prefix_len + name_len + 1; | 7082 | const size_t total_len = prefix_len + name_len + 1; |
| @@ -7091,23 +7089,23 @@ static size_t ocfs2_xattr_trusted_list(struct inode *inode, char *list, | |||
| 7091 | return total_len; | 7089 | return total_len; |
| 7092 | } | 7090 | } |
| 7093 | 7091 | ||
| 7094 | static int ocfs2_xattr_trusted_get(struct inode *inode, const char *name, | 7092 | static int ocfs2_xattr_trusted_get(struct dentry *dentry, const char *name, |
| 7095 | void *buffer, size_t size) | 7093 | void *buffer, size_t size, int type) |
| 7096 | { | 7094 | { |
| 7097 | if (strcmp(name, "") == 0) | 7095 | if (strcmp(name, "") == 0) |
| 7098 | return -EINVAL; | 7096 | return -EINVAL; |
| 7099 | return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_TRUSTED, name, | 7097 | return ocfs2_xattr_get(dentry->d_inode, OCFS2_XATTR_INDEX_TRUSTED, |
| 7100 | buffer, size); | 7098 | name, buffer, size); |
| 7101 | } | 7099 | } |
| 7102 | 7100 | ||
| 7103 | static int ocfs2_xattr_trusted_set(struct inode *inode, const char *name, | 7101 | static int ocfs2_xattr_trusted_set(struct dentry *dentry, const char *name, |
| 7104 | const void *value, size_t size, int flags) | 7102 | const void *value, size_t size, int flags, int type) |
| 7105 | { | 7103 | { |
| 7106 | if (strcmp(name, "") == 0) | 7104 | if (strcmp(name, "") == 0) |
| 7107 | return -EINVAL; | 7105 | return -EINVAL; |
| 7108 | 7106 | ||
| 7109 | return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_TRUSTED, name, value, | 7107 | return ocfs2_xattr_set(dentry->d_inode, OCFS2_XATTR_INDEX_TRUSTED, |
| 7110 | size, flags); | 7108 | name, value, size, flags); |
| 7111 | } | 7109 | } |
| 7112 | 7110 | ||
| 7113 | struct xattr_handler ocfs2_xattr_trusted_handler = { | 7111 | struct xattr_handler ocfs2_xattr_trusted_handler = { |
| @@ -7120,13 +7118,13 @@ struct xattr_handler ocfs2_xattr_trusted_handler = { | |||
| 7120 | /* | 7118 | /* |
| 7121 | * 'user' attributes support | 7119 | * 'user' attributes support |
| 7122 | */ | 7120 | */ |
| 7123 | static size_t ocfs2_xattr_user_list(struct inode *inode, char *list, | 7121 | static size_t ocfs2_xattr_user_list(struct dentry *dentry, char *list, |
| 7124 | size_t list_size, const char *name, | 7122 | size_t list_size, const char *name, |
| 7125 | size_t name_len) | 7123 | size_t name_len, int type) |
| 7126 | { | 7124 | { |
| 7127 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; | 7125 | const size_t prefix_len = XATTR_USER_PREFIX_LEN; |
| 7128 | const size_t total_len = prefix_len + name_len + 1; | 7126 | const size_t total_len = prefix_len + name_len + 1; |
| 7129 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 7127 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); |
| 7130 | 7128 | ||
| 7131 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | 7129 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) |
| 7132 | return 0; | 7130 | return 0; |
| @@ -7139,31 +7137,31 @@ static size_t ocfs2_xattr_user_list(struct inode *inode, char *list, | |||
| 7139 | return total_len; | 7137 | return total_len; |
| 7140 | } | 7138 | } |
| 7141 | 7139 | ||
| 7142 | static int ocfs2_xattr_user_get(struct inode *inode, const char *name, | 7140 | static int ocfs2_xattr_user_get(struct dentry *dentry, const char *name, |
| 7143 | void *buffer, size_t size) | 7141 | void *buffer, size_t size, int type) |
| 7144 | { | 7142 | { |
| 7145 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 7143 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); |
| 7146 | 7144 | ||
| 7147 | if (strcmp(name, "") == 0) | 7145 | if (strcmp(name, "") == 0) |
| 7148 | return -EINVAL; | 7146 | return -EINVAL; |
| 7149 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | 7147 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) |
| 7150 | return -EOPNOTSUPP; | 7148 | return -EOPNOTSUPP; |
| 7151 | return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_USER, name, | 7149 | return ocfs2_xattr_get(dentry->d_inode, OCFS2_XATTR_INDEX_USER, name, |
| 7152 | buffer, size); | 7150 | buffer, size); |
| 7153 | } | 7151 | } |
| 7154 | 7152 | ||
| 7155 | static int ocfs2_xattr_user_set(struct inode *inode, const char *name, | 7153 | static int ocfs2_xattr_user_set(struct dentry *dentry, const char *name, |
| 7156 | const void *value, size_t size, int flags) | 7154 | const void *value, size_t size, int flags, int type) |
| 7157 | { | 7155 | { |
| 7158 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 7156 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); |
| 7159 | 7157 | ||
| 7160 | if (strcmp(name, "") == 0) | 7158 | if (strcmp(name, "") == 0) |
| 7161 | return -EINVAL; | 7159 | return -EINVAL; |
| 7162 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) | 7160 | if (osb->s_mount_opt & OCFS2_MOUNT_NOUSERXATTR) |
| 7163 | return -EOPNOTSUPP; | 7161 | return -EOPNOTSUPP; |
| 7164 | 7162 | ||
| 7165 | return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_USER, name, value, | 7163 | return ocfs2_xattr_set(dentry->d_inode, OCFS2_XATTR_INDEX_USER, |
| 7166 | size, flags); | 7164 | name, value, size, flags); |
| 7167 | } | 7165 | } |
| 7168 | 7166 | ||
| 7169 | struct xattr_handler ocfs2_xattr_user_handler = { | 7167 | struct xattr_handler ocfs2_xattr_user_handler = { |
| @@ -30,6 +30,9 @@ | |||
| 30 | #include <linux/audit.h> | 30 | #include <linux/audit.h> |
| 31 | #include <linux/falloc.h> | 31 | #include <linux/falloc.h> |
| 32 | #include <linux/fs_struct.h> | 32 | #include <linux/fs_struct.h> |
| 33 | #include <linux/ima.h> | ||
| 34 | |||
| 35 | #include "internal.h" | ||
| 33 | 36 | ||
| 34 | int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) | 37 | int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
| 35 | { | 38 | { |
| @@ -855,6 +858,7 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, | |||
| 855 | if (error) | 858 | if (error) |
| 856 | goto cleanup_all; | 859 | goto cleanup_all; |
| 857 | } | 860 | } |
| 861 | ima_counts_get(f); | ||
| 858 | 862 | ||
| 859 | f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); | 863 | f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); |
| 860 | 864 | ||
| @@ -906,17 +906,6 @@ void free_pipe_info(struct inode *inode) | |||
| 906 | } | 906 | } |
| 907 | 907 | ||
| 908 | static struct vfsmount *pipe_mnt __read_mostly; | 908 | static struct vfsmount *pipe_mnt __read_mostly; |
| 909 | static int pipefs_delete_dentry(struct dentry *dentry) | ||
| 910 | { | ||
| 911 | /* | ||
| 912 | * At creation time, we pretended this dentry was hashed | ||
| 913 | * (by clearing DCACHE_UNHASHED bit in d_flags) | ||
| 914 | * At delete time, we restore the truth : not hashed. | ||
| 915 | * (so that dput() can proceed correctly) | ||
| 916 | */ | ||
| 917 | dentry->d_flags |= DCACHE_UNHASHED; | ||
| 918 | return 0; | ||
| 919 | } | ||
| 920 | 909 | ||
| 921 | /* | 910 | /* |
| 922 | * pipefs_dname() is called from d_path(). | 911 | * pipefs_dname() is called from d_path(). |
| @@ -928,7 +917,6 @@ static char *pipefs_dname(struct dentry *dentry, char *buffer, int buflen) | |||
| 928 | } | 917 | } |
| 929 | 918 | ||
| 930 | static const struct dentry_operations pipefs_dentry_operations = { | 919 | static const struct dentry_operations pipefs_dentry_operations = { |
| 931 | .d_delete = pipefs_delete_dentry, | ||
| 932 | .d_dname = pipefs_dname, | 920 | .d_dname = pipefs_dname, |
| 933 | }; | 921 | }; |
| 934 | 922 | ||
| @@ -974,7 +962,7 @@ struct file *create_write_pipe(int flags) | |||
| 974 | int err; | 962 | int err; |
| 975 | struct inode *inode; | 963 | struct inode *inode; |
| 976 | struct file *f; | 964 | struct file *f; |
| 977 | struct dentry *dentry; | 965 | struct path path; |
| 978 | struct qstr name = { .name = "" }; | 966 | struct qstr name = { .name = "" }; |
| 979 | 967 | ||
| 980 | err = -ENFILE; | 968 | err = -ENFILE; |
| @@ -983,21 +971,16 @@ struct file *create_write_pipe(int flags) | |||
| 983 | goto err; | 971 | goto err; |
| 984 | 972 | ||
| 985 | err = -ENOMEM; | 973 | err = -ENOMEM; |
| 986 | dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &name); | 974 | path.dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &name); |
| 987 | if (!dentry) | 975 | if (!path.dentry) |
| 988 | goto err_inode; | 976 | goto err_inode; |
| 977 | path.mnt = mntget(pipe_mnt); | ||
| 989 | 978 | ||
| 990 | dentry->d_op = &pipefs_dentry_operations; | 979 | path.dentry->d_op = &pipefs_dentry_operations; |
| 991 | /* | 980 | d_instantiate(path.dentry, inode); |
| 992 | * We dont want to publish this dentry into global dentry hash table. | ||
| 993 | * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED | ||
| 994 | * This permits a working /proc/$pid/fd/XXX on pipes | ||
| 995 | */ | ||
| 996 | dentry->d_flags &= ~DCACHE_UNHASHED; | ||
| 997 | d_instantiate(dentry, inode); | ||
| 998 | 981 | ||
| 999 | err = -ENFILE; | 982 | err = -ENFILE; |
| 1000 | f = alloc_file(pipe_mnt, dentry, FMODE_WRITE, &write_pipefifo_fops); | 983 | f = alloc_file(&path, FMODE_WRITE, &write_pipefifo_fops); |
| 1001 | if (!f) | 984 | if (!f) |
| 1002 | goto err_dentry; | 985 | goto err_dentry; |
| 1003 | f->f_mapping = inode->i_mapping; | 986 | f->f_mapping = inode->i_mapping; |
| @@ -1009,7 +992,7 @@ struct file *create_write_pipe(int flags) | |||
| 1009 | 992 | ||
| 1010 | err_dentry: | 993 | err_dentry: |
| 1011 | free_pipe_info(inode); | 994 | free_pipe_info(inode); |
| 1012 | dput(dentry); | 995 | path_put(&path); |
| 1013 | return ERR_PTR(err); | 996 | return ERR_PTR(err); |
| 1014 | 997 | ||
| 1015 | err_inode: | 998 | err_inode: |
| @@ -1028,20 +1011,14 @@ void free_write_pipe(struct file *f) | |||
| 1028 | 1011 | ||
| 1029 | struct file *create_read_pipe(struct file *wrf, int flags) | 1012 | struct file *create_read_pipe(struct file *wrf, int flags) |
| 1030 | { | 1013 | { |
| 1031 | struct file *f = get_empty_filp(); | 1014 | /* Grab pipe from the writer */ |
| 1015 | struct file *f = alloc_file(&wrf->f_path, FMODE_READ, | ||
| 1016 | &read_pipefifo_fops); | ||
| 1032 | if (!f) | 1017 | if (!f) |
| 1033 | return ERR_PTR(-ENFILE); | 1018 | return ERR_PTR(-ENFILE); |
| 1034 | 1019 | ||
| 1035 | /* Grab pipe from the writer */ | ||
| 1036 | f->f_path = wrf->f_path; | ||
| 1037 | path_get(&wrf->f_path); | 1020 | path_get(&wrf->f_path); |
| 1038 | f->f_mapping = wrf->f_path.dentry->d_inode->i_mapping; | ||
| 1039 | |||
| 1040 | f->f_pos = 0; | ||
| 1041 | f->f_flags = O_RDONLY | (flags & O_NONBLOCK); | 1021 | f->f_flags = O_RDONLY | (flags & O_NONBLOCK); |
| 1042 | f->f_op = &read_pipefifo_fops; | ||
| 1043 | f->f_mode = FMODE_READ; | ||
| 1044 | f->f_version = 0; | ||
| 1045 | 1022 | ||
| 1046 | return f; | 1023 | return f; |
| 1047 | } | 1024 | } |
diff --git a/fs/proc/base.c b/fs/proc/base.c index af643b5aefe8..18d5cc62d8ed 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
| @@ -1265,6 +1265,72 @@ static const struct file_operations proc_pid_sched_operations = { | |||
| 1265 | 1265 | ||
| 1266 | #endif | 1266 | #endif |
| 1267 | 1267 | ||
| 1268 | static ssize_t comm_write(struct file *file, const char __user *buf, | ||
| 1269 | size_t count, loff_t *offset) | ||
| 1270 | { | ||
| 1271 | struct inode *inode = file->f_path.dentry->d_inode; | ||
| 1272 | struct task_struct *p; | ||
| 1273 | char buffer[TASK_COMM_LEN]; | ||
| 1274 | |||
| 1275 | memset(buffer, 0, sizeof(buffer)); | ||
| 1276 | if (count > sizeof(buffer) - 1) | ||
| 1277 | count = sizeof(buffer) - 1; | ||
| 1278 | if (copy_from_user(buffer, buf, count)) | ||
| 1279 | return -EFAULT; | ||
| 1280 | |||
| 1281 | p = get_proc_task(inode); | ||
| 1282 | if (!p) | ||
| 1283 | return -ESRCH; | ||
| 1284 | |||
| 1285 | if (same_thread_group(current, p)) | ||
| 1286 | set_task_comm(p, buffer); | ||
| 1287 | else | ||
| 1288 | count = -EINVAL; | ||
| 1289 | |||
| 1290 | put_task_struct(p); | ||
| 1291 | |||
| 1292 | return count; | ||
| 1293 | } | ||
| 1294 | |||
| 1295 | static int comm_show(struct seq_file *m, void *v) | ||
| 1296 | { | ||
| 1297 | struct inode *inode = m->private; | ||
| 1298 | struct task_struct *p; | ||
| 1299 | |||
| 1300 | p = get_proc_task(inode); | ||
| 1301 | if (!p) | ||
| 1302 | return -ESRCH; | ||
| 1303 | |||
| 1304 | task_lock(p); | ||
| 1305 | seq_printf(m, "%s\n", p->comm); | ||
| 1306 | task_unlock(p); | ||
| 1307 | |||
| 1308 | put_task_struct(p); | ||
| 1309 | |||
| 1310 | return 0; | ||
| 1311 | } | ||
| 1312 | |||
| 1313 | static int comm_open(struct inode *inode, struct file *filp) | ||
| 1314 | { | ||
| 1315 | int ret; | ||
| 1316 | |||
| 1317 | ret = single_open(filp, comm_show, NULL); | ||
| 1318 | if (!ret) { | ||
| 1319 | struct seq_file *m = filp->private_data; | ||
| 1320 | |||
| 1321 | m->private = inode; | ||
| 1322 | } | ||
| 1323 | return ret; | ||
| 1324 | } | ||
| 1325 | |||
| 1326 | static const struct file_operations proc_pid_set_comm_operations = { | ||
| 1327 | .open = comm_open, | ||
| 1328 | .read = seq_read, | ||
| 1329 | .write = comm_write, | ||
| 1330 | .llseek = seq_lseek, | ||
| 1331 | .release = single_release, | ||
| 1332 | }; | ||
| 1333 | |||
| 1268 | /* | 1334 | /* |
| 1269 | * We added or removed a vma mapping the executable. The vmas are only mapped | 1335 | * We added or removed a vma mapping the executable. The vmas are only mapped |
| 1270 | * during exec and are not mapped with the mmap system call. | 1336 | * during exec and are not mapped with the mmap system call. |
| @@ -2200,7 +2266,7 @@ static const struct inode_operations proc_attr_dir_inode_operations = { | |||
| 2200 | 2266 | ||
| 2201 | #endif | 2267 | #endif |
| 2202 | 2268 | ||
| 2203 | #if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE) | 2269 | #ifdef CONFIG_ELF_CORE |
| 2204 | static ssize_t proc_coredump_filter_read(struct file *file, char __user *buf, | 2270 | static ssize_t proc_coredump_filter_read(struct file *file, char __user *buf, |
| 2205 | size_t count, loff_t *ppos) | 2271 | size_t count, loff_t *ppos) |
| 2206 | { | 2272 | { |
| @@ -2504,6 +2570,7 @@ static const struct pid_entry tgid_base_stuff[] = { | |||
| 2504 | #ifdef CONFIG_SCHED_DEBUG | 2570 | #ifdef CONFIG_SCHED_DEBUG |
| 2505 | REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations), | 2571 | REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations), |
| 2506 | #endif | 2572 | #endif |
| 2573 | REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations), | ||
| 2507 | #ifdef CONFIG_HAVE_ARCH_TRACEHOOK | 2574 | #ifdef CONFIG_HAVE_ARCH_TRACEHOOK |
| 2508 | INF("syscall", S_IRUSR, proc_pid_syscall), | 2575 | INF("syscall", S_IRUSR, proc_pid_syscall), |
| 2509 | #endif | 2576 | #endif |
| @@ -2556,7 +2623,7 @@ static const struct pid_entry tgid_base_stuff[] = { | |||
| 2556 | #ifdef CONFIG_FAULT_INJECTION | 2623 | #ifdef CONFIG_FAULT_INJECTION |
| 2557 | REG("make-it-fail", S_IRUGO|S_IWUSR, proc_fault_inject_operations), | 2624 | REG("make-it-fail", S_IRUGO|S_IWUSR, proc_fault_inject_operations), |
| 2558 | #endif | 2625 | #endif |
| 2559 | #if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE) | 2626 | #ifdef CONFIG_ELF_CORE |
| 2560 | REG("coredump_filter", S_IRUGO|S_IWUSR, proc_coredump_filter_operations), | 2627 | REG("coredump_filter", S_IRUGO|S_IWUSR, proc_coredump_filter_operations), |
| 2561 | #endif | 2628 | #endif |
| 2562 | #ifdef CONFIG_TASK_IO_ACCOUNTING | 2629 | #ifdef CONFIG_TASK_IO_ACCOUNTING |
| @@ -2838,6 +2905,7 @@ static const struct pid_entry tid_base_stuff[] = { | |||
| 2838 | #ifdef CONFIG_SCHED_DEBUG | 2905 | #ifdef CONFIG_SCHED_DEBUG |
| 2839 | REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations), | 2906 | REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations), |
| 2840 | #endif | 2907 | #endif |
| 2908 | REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations), | ||
| 2841 | #ifdef CONFIG_HAVE_ARCH_TRACEHOOK | 2909 | #ifdef CONFIG_HAVE_ARCH_TRACEHOOK |
| 2842 | INF("syscall", S_IRUSR, proc_pid_syscall), | 2910 | INF("syscall", S_IRUSR, proc_pid_syscall), |
| 2843 | #endif | 2911 | #endif |
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index fa678abc9db1..480cb1065eec 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
| @@ -429,7 +429,7 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir, | |||
| 429 | unsigned int ino; | 429 | unsigned int ino; |
| 430 | 430 | ||
| 431 | ino = de->low_ino; | 431 | ino = de->low_ino; |
| 432 | de_get(de); | 432 | pde_get(de); |
| 433 | spin_unlock(&proc_subdir_lock); | 433 | spin_unlock(&proc_subdir_lock); |
| 434 | error = -EINVAL; | 434 | error = -EINVAL; |
| 435 | inode = proc_get_inode(dir->i_sb, ino, de); | 435 | inode = proc_get_inode(dir->i_sb, ino, de); |
| @@ -445,7 +445,7 @@ out_unlock: | |||
| 445 | return NULL; | 445 | return NULL; |
| 446 | } | 446 | } |
| 447 | if (de) | 447 | if (de) |
| 448 | de_put(de); | 448 | pde_put(de); |
| 449 | return ERR_PTR(error); | 449 | return ERR_PTR(error); |
| 450 | } | 450 | } |
| 451 | 451 | ||
| @@ -509,17 +509,17 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent, | |||
| 509 | struct proc_dir_entry *next; | 509 | struct proc_dir_entry *next; |
| 510 | 510 | ||
| 511 | /* filldir passes info to user space */ | 511 | /* filldir passes info to user space */ |
| 512 | de_get(de); | 512 | pde_get(de); |
| 513 | spin_unlock(&proc_subdir_lock); | 513 | spin_unlock(&proc_subdir_lock); |
| 514 | if (filldir(dirent, de->name, de->namelen, filp->f_pos, | 514 | if (filldir(dirent, de->name, de->namelen, filp->f_pos, |
| 515 | de->low_ino, de->mode >> 12) < 0) { | 515 | de->low_ino, de->mode >> 12) < 0) { |
| 516 | de_put(de); | 516 | pde_put(de); |
| 517 | goto out; | 517 | goto out; |
| 518 | } | 518 | } |
| 519 | spin_lock(&proc_subdir_lock); | 519 | spin_lock(&proc_subdir_lock); |
| 520 | filp->f_pos++; | 520 | filp->f_pos++; |
| 521 | next = de->next; | 521 | next = de->next; |
| 522 | de_put(de); | 522 | pde_put(de); |
| 523 | de = next; | 523 | de = next; |
| 524 | } while (de); | 524 | } while (de); |
| 525 | spin_unlock(&proc_subdir_lock); | 525 | spin_unlock(&proc_subdir_lock); |
| @@ -763,7 +763,7 @@ out: | |||
| 763 | return NULL; | 763 | return NULL; |
| 764 | } | 764 | } |
| 765 | 765 | ||
| 766 | void free_proc_entry(struct proc_dir_entry *de) | 766 | static void free_proc_entry(struct proc_dir_entry *de) |
| 767 | { | 767 | { |
| 768 | unsigned int ino = de->low_ino; | 768 | unsigned int ino = de->low_ino; |
| 769 | 769 | ||
| @@ -777,6 +777,12 @@ void free_proc_entry(struct proc_dir_entry *de) | |||
| 777 | kfree(de); | 777 | kfree(de); |
| 778 | } | 778 | } |
| 779 | 779 | ||
| 780 | void pde_put(struct proc_dir_entry *pde) | ||
| 781 | { | ||
| 782 | if (atomic_dec_and_test(&pde->count)) | ||
| 783 | free_proc_entry(pde); | ||
| 784 | } | ||
| 785 | |||
| 780 | /* | 786 | /* |
| 781 | * Remove a /proc entry and free it if it's not currently in use. | 787 | * Remove a /proc entry and free it if it's not currently in use. |
| 782 | */ | 788 | */ |
| @@ -845,6 +851,5 @@ continue_removing: | |||
| 845 | WARN(de->subdir, KERN_WARNING "%s: removing non-empty directory " | 851 | WARN(de->subdir, KERN_WARNING "%s: removing non-empty directory " |
| 846 | "'%s/%s', leaking at least '%s'\n", __func__, | 852 | "'%s/%s', leaking at least '%s'\n", __func__, |
| 847 | de->parent->name, de->name, de->subdir->name); | 853 | de->parent->name, de->name, de->subdir->name); |
| 848 | if (atomic_dec_and_test(&de->count)) | 854 | pde_put(de); |
| 849 | free_proc_entry(de); | ||
| 850 | } | 855 | } |
diff --git a/fs/proc/inode.c b/fs/proc/inode.c index d78ade305541..445a02bcaab3 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c | |||
| @@ -24,29 +24,6 @@ | |||
| 24 | 24 | ||
| 25 | #include "internal.h" | 25 | #include "internal.h" |
| 26 | 26 | ||
| 27 | struct proc_dir_entry *de_get(struct proc_dir_entry *de) | ||
| 28 | { | ||
| 29 | atomic_inc(&de->count); | ||
| 30 | return de; | ||
| 31 | } | ||
| 32 | |||
| 33 | /* | ||
| 34 | * Decrements the use count and checks for deferred deletion. | ||
| 35 | */ | ||
| 36 | void de_put(struct proc_dir_entry *de) | ||
| 37 | { | ||
| 38 | if (!atomic_read(&de->count)) { | ||
| 39 | printk("de_put: entry %s already free!\n", de->name); | ||
| 40 | return; | ||
| 41 | } | ||
| 42 | |||
| 43 | if (atomic_dec_and_test(&de->count)) | ||
| 44 | free_proc_entry(de); | ||
| 45 | } | ||
| 46 | |||
| 47 | /* | ||
| 48 | * Decrement the use count of the proc_dir_entry. | ||
| 49 | */ | ||
| 50 | static void proc_delete_inode(struct inode *inode) | 27 | static void proc_delete_inode(struct inode *inode) |
| 51 | { | 28 | { |
| 52 | struct proc_dir_entry *de; | 29 | struct proc_dir_entry *de; |
| @@ -59,7 +36,7 @@ static void proc_delete_inode(struct inode *inode) | |||
| 59 | /* Let go of any associated proc directory entry */ | 36 | /* Let go of any associated proc directory entry */ |
| 60 | de = PROC_I(inode)->pde; | 37 | de = PROC_I(inode)->pde; |
| 61 | if (de) | 38 | if (de) |
| 62 | de_put(de); | 39 | pde_put(de); |
| 63 | if (PROC_I(inode)->sysctl) | 40 | if (PROC_I(inode)->sysctl) |
| 64 | sysctl_head_put(PROC_I(inode)->sysctl); | 41 | sysctl_head_put(PROC_I(inode)->sysctl); |
| 65 | clear_inode(inode); | 42 | clear_inode(inode); |
| @@ -480,7 +457,7 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, | |||
| 480 | } | 457 | } |
| 481 | unlock_new_inode(inode); | 458 | unlock_new_inode(inode); |
| 482 | } else | 459 | } else |
| 483 | de_put(de); | 460 | pde_put(de); |
| 484 | return inode; | 461 | return inode; |
| 485 | } | 462 | } |
| 486 | 463 | ||
| @@ -495,7 +472,7 @@ int proc_fill_super(struct super_block *s) | |||
| 495 | s->s_op = &proc_sops; | 472 | s->s_op = &proc_sops; |
| 496 | s->s_time_gran = 1; | 473 | s->s_time_gran = 1; |
| 497 | 474 | ||
| 498 | de_get(&proc_root); | 475 | pde_get(&proc_root); |
| 499 | root_inode = proc_get_inode(s, PROC_ROOT_INO, &proc_root); | 476 | root_inode = proc_get_inode(s, PROC_ROOT_INO, &proc_root); |
| 500 | if (!root_inode) | 477 | if (!root_inode) |
| 501 | goto out_no_root; | 478 | goto out_no_root; |
| @@ -509,6 +486,6 @@ int proc_fill_super(struct super_block *s) | |||
| 509 | out_no_root: | 486 | out_no_root: |
| 510 | printk("proc_read_super: get root inode failed\n"); | 487 | printk("proc_read_super: get root inode failed\n"); |
| 511 | iput(root_inode); | 488 | iput(root_inode); |
| 512 | de_put(&proc_root); | 489 | pde_put(&proc_root); |
| 513 | return -ENOMEM; | 490 | return -ENOMEM; |
| 514 | } | 491 | } |
diff --git a/fs/proc/internal.h b/fs/proc/internal.h index 753ca37002c8..1f24a3eddd12 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h | |||
| @@ -61,8 +61,6 @@ extern const struct file_operations proc_pagemap_operations; | |||
| 61 | extern const struct file_operations proc_net_operations; | 61 | extern const struct file_operations proc_net_operations; |
| 62 | extern const struct inode_operations proc_net_inode_operations; | 62 | extern const struct inode_operations proc_net_inode_operations; |
| 63 | 63 | ||
| 64 | void free_proc_entry(struct proc_dir_entry *de); | ||
| 65 | |||
| 66 | void proc_init_inodecache(void); | 64 | void proc_init_inodecache(void); |
| 67 | 65 | ||
| 68 | static inline struct pid *proc_pid(struct inode *inode) | 66 | static inline struct pid *proc_pid(struct inode *inode) |
| @@ -101,8 +99,12 @@ unsigned long task_vsize(struct mm_struct *); | |||
| 101 | int task_statm(struct mm_struct *, int *, int *, int *, int *); | 99 | int task_statm(struct mm_struct *, int *, int *, int *, int *); |
| 102 | void task_mem(struct seq_file *, struct mm_struct *); | 100 | void task_mem(struct seq_file *, struct mm_struct *); |
| 103 | 101 | ||
| 104 | struct proc_dir_entry *de_get(struct proc_dir_entry *de); | 102 | static inline struct proc_dir_entry *pde_get(struct proc_dir_entry *pde) |
| 105 | void de_put(struct proc_dir_entry *de); | 103 | { |
| 104 | atomic_inc(&pde->count); | ||
| 105 | return pde; | ||
| 106 | } | ||
| 107 | void pde_put(struct proc_dir_entry *pde); | ||
| 106 | 108 | ||
| 107 | extern struct vfsmount *proc_mnt; | 109 | extern struct vfsmount *proc_mnt; |
| 108 | int proc_fill_super(struct super_block *); | 110 | int proc_fill_super(struct super_block *); |
diff --git a/fs/proc/page.c b/fs/proc/page.c index 5033ce0d254b..180cf5a0bd67 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <linux/proc_fs.h> | 8 | #include <linux/proc_fs.h> |
| 9 | #include <linux/seq_file.h> | 9 | #include <linux/seq_file.h> |
| 10 | #include <linux/hugetlb.h> | 10 | #include <linux/hugetlb.h> |
| 11 | #include <linux/kernel-page-flags.h> | ||
| 11 | #include <asm/uaccess.h> | 12 | #include <asm/uaccess.h> |
| 12 | #include "internal.h" | 13 | #include "internal.h" |
| 13 | 14 | ||
| @@ -71,52 +72,12 @@ static const struct file_operations proc_kpagecount_operations = { | |||
| 71 | * physical page flags. | 72 | * physical page flags. |
| 72 | */ | 73 | */ |
| 73 | 74 | ||
| 74 | /* These macros are used to decouple internal flags from exported ones */ | ||
| 75 | |||
| 76 | #define KPF_LOCKED 0 | ||
| 77 | #define KPF_ERROR 1 | ||
| 78 | #define KPF_REFERENCED 2 | ||
| 79 | #define KPF_UPTODATE 3 | ||
| 80 | #define KPF_DIRTY 4 | ||
| 81 | #define KPF_LRU 5 | ||
| 82 | #define KPF_ACTIVE 6 | ||
| 83 | #define KPF_SLAB 7 | ||
| 84 | #define KPF_WRITEBACK 8 | ||
| 85 | #define KPF_RECLAIM 9 | ||
| 86 | #define KPF_BUDDY 10 | ||
| 87 | |||
| 88 | /* 11-20: new additions in 2.6.31 */ | ||
| 89 | #define KPF_MMAP 11 | ||
| 90 | #define KPF_ANON 12 | ||
| 91 | #define KPF_SWAPCACHE 13 | ||
| 92 | #define KPF_SWAPBACKED 14 | ||
| 93 | #define KPF_COMPOUND_HEAD 15 | ||
| 94 | #define KPF_COMPOUND_TAIL 16 | ||
| 95 | #define KPF_HUGE 17 | ||
| 96 | #define KPF_UNEVICTABLE 18 | ||
| 97 | #define KPF_HWPOISON 19 | ||
| 98 | #define KPF_NOPAGE 20 | ||
| 99 | |||
| 100 | #define KPF_KSM 21 | ||
| 101 | |||
| 102 | /* kernel hacking assistances | ||
| 103 | * WARNING: subject to change, never rely on them! | ||
| 104 | */ | ||
| 105 | #define KPF_RESERVED 32 | ||
| 106 | #define KPF_MLOCKED 33 | ||
| 107 | #define KPF_MAPPEDTODISK 34 | ||
| 108 | #define KPF_PRIVATE 35 | ||
| 109 | #define KPF_PRIVATE_2 36 | ||
| 110 | #define KPF_OWNER_PRIVATE 37 | ||
| 111 | #define KPF_ARCH 38 | ||
| 112 | #define KPF_UNCACHED 39 | ||
| 113 | |||
| 114 | static inline u64 kpf_copy_bit(u64 kflags, int ubit, int kbit) | 75 | static inline u64 kpf_copy_bit(u64 kflags, int ubit, int kbit) |
| 115 | { | 76 | { |
| 116 | return ((kflags >> kbit) & 1) << ubit; | 77 | return ((kflags >> kbit) & 1) << ubit; |
| 117 | } | 78 | } |
| 118 | 79 | ||
| 119 | static u64 get_uflags(struct page *page) | 80 | u64 stable_page_flags(struct page *page) |
| 120 | { | 81 | { |
| 121 | u64 k; | 82 | u64 k; |
| 122 | u64 u; | 83 | u64 u; |
| @@ -219,7 +180,7 @@ static ssize_t kpageflags_read(struct file *file, char __user *buf, | |||
| 219 | else | 180 | else |
| 220 | ppage = NULL; | 181 | ppage = NULL; |
| 221 | 182 | ||
| 222 | if (put_user(get_uflags(ppage), out)) { | 183 | if (put_user(stable_page_flags(ppage), out)) { |
| 223 | ret = -EFAULT; | 184 | ret = -EFAULT; |
| 224 | break; | 185 | break; |
| 225 | } | 186 | } |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 2a1bef9203c6..47c03f4336b8 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
| @@ -650,6 +650,50 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, | |||
| 650 | return err; | 650 | return err; |
| 651 | } | 651 | } |
| 652 | 652 | ||
| 653 | static u64 huge_pte_to_pagemap_entry(pte_t pte, int offset) | ||
| 654 | { | ||
| 655 | u64 pme = 0; | ||
| 656 | if (pte_present(pte)) | ||
| 657 | pme = PM_PFRAME(pte_pfn(pte) + offset) | ||
| 658 | | PM_PSHIFT(PAGE_SHIFT) | PM_PRESENT; | ||
| 659 | return pme; | ||
| 660 | } | ||
| 661 | |||
| 662 | static int pagemap_hugetlb_range(pte_t *pte, unsigned long addr, | ||
| 663 | unsigned long end, struct mm_walk *walk) | ||
| 664 | { | ||
| 665 | struct vm_area_struct *vma; | ||
| 666 | struct pagemapread *pm = walk->private; | ||
| 667 | struct hstate *hs = NULL; | ||
| 668 | int err = 0; | ||
| 669 | |||
| 670 | vma = find_vma(walk->mm, addr); | ||
| 671 | if (vma) | ||
| 672 | hs = hstate_vma(vma); | ||
| 673 | for (; addr != end; addr += PAGE_SIZE) { | ||
| 674 | u64 pfn = PM_NOT_PRESENT; | ||
| 675 | |||
| 676 | if (vma && (addr >= vma->vm_end)) { | ||
| 677 | vma = find_vma(walk->mm, addr); | ||
| 678 | if (vma) | ||
| 679 | hs = hstate_vma(vma); | ||
| 680 | } | ||
| 681 | |||
| 682 | if (vma && (vma->vm_start <= addr) && is_vm_hugetlb_page(vma)) { | ||
| 683 | /* calculate pfn of the "raw" page in the hugepage. */ | ||
| 684 | int offset = (addr & ~huge_page_mask(hs)) >> PAGE_SHIFT; | ||
| 685 | pfn = huge_pte_to_pagemap_entry(*pte, offset); | ||
| 686 | } | ||
| 687 | err = add_to_pagemap(addr, pfn, pm); | ||
| 688 | if (err) | ||
| 689 | return err; | ||
| 690 | } | ||
| 691 | |||
| 692 | cond_resched(); | ||
| 693 | |||
| 694 | return err; | ||
| 695 | } | ||
| 696 | |||
| 653 | /* | 697 | /* |
| 654 | * /proc/pid/pagemap - an array mapping virtual pages to pfns | 698 | * /proc/pid/pagemap - an array mapping virtual pages to pfns |
| 655 | * | 699 | * |
| @@ -742,6 +786,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, | |||
| 742 | 786 | ||
| 743 | pagemap_walk.pmd_entry = pagemap_pte_range; | 787 | pagemap_walk.pmd_entry = pagemap_pte_range; |
| 744 | pagemap_walk.pte_hole = pagemap_pte_hole; | 788 | pagemap_walk.pte_hole = pagemap_pte_hole; |
| 789 | pagemap_walk.hugetlb_entry = pagemap_hugetlb_range; | ||
| 745 | pagemap_walk.mm = mm; | 790 | pagemap_walk.mm = mm; |
| 746 | pagemap_walk.private = ± | 791 | pagemap_walk.private = ± |
| 747 | 792 | ||
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index 8f5c05d3dbd3..5d9fd64ef81a 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c | |||
| @@ -110,9 +110,13 @@ int task_statm(struct mm_struct *mm, int *shared, int *text, | |||
| 110 | } | 110 | } |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | size += (*text = mm->end_code - mm->start_code); | 113 | *text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK)) |
| 114 | size += (*data = mm->start_stack - mm->start_data); | 114 | >> PAGE_SHIFT; |
| 115 | *data = (PAGE_ALIGN(mm->start_stack) - (mm->start_data & PAGE_MASK)) | ||
| 116 | >> PAGE_SHIFT; | ||
| 115 | up_read(&mm->mmap_sem); | 117 | up_read(&mm->mmap_sem); |
| 118 | size >>= PAGE_SHIFT; | ||
| 119 | size += *text + *data; | ||
| 116 | *resident = size; | 120 | *resident = size; |
| 117 | return size; | 121 | return size; |
| 118 | } | 122 | } |
diff --git a/fs/qnx4/bitmap.c b/fs/qnx4/bitmap.c index 32f5d131a644..22e0d60e53ef 100644 --- a/fs/qnx4/bitmap.c +++ b/fs/qnx4/bitmap.c | |||
| @@ -17,13 +17,6 @@ | |||
| 17 | #include <linux/bitops.h> | 17 | #include <linux/bitops.h> |
| 18 | #include "qnx4.h" | 18 | #include "qnx4.h" |
| 19 | 19 | ||
| 20 | #if 0 | ||
| 21 | int qnx4_new_block(struct super_block *sb) | ||
| 22 | { | ||
| 23 | return 0; | ||
| 24 | } | ||
| 25 | #endif /* 0 */ | ||
| 26 | |||
| 27 | static void count_bits(register const char *bmPart, register int size, | 20 | static void count_bits(register const char *bmPart, register int size, |
| 28 | int *const tf) | 21 | int *const tf) |
| 29 | { | 22 | { |
| @@ -35,22 +28,7 @@ static void count_bits(register const char *bmPart, register int size, | |||
| 35 | } | 28 | } |
| 36 | do { | 29 | do { |
| 37 | b = *bmPart++; | 30 | b = *bmPart++; |
| 38 | if ((b & 1) == 0) | 31 | tot += 8 - hweight8(b); |
| 39 | tot++; | ||
| 40 | if ((b & 2) == 0) | ||
| 41 | tot++; | ||
| 42 | if ((b & 4) == 0) | ||
| 43 | tot++; | ||
| 44 | if ((b & 8) == 0) | ||
| 45 | tot++; | ||
| 46 | if ((b & 16) == 0) | ||
| 47 | tot++; | ||
| 48 | if ((b & 32) == 0) | ||
| 49 | tot++; | ||
| 50 | if ((b & 64) == 0) | ||
| 51 | tot++; | ||
| 52 | if ((b & 128) == 0) | ||
| 53 | tot++; | ||
| 54 | size--; | 32 | size--; |
| 55 | } while (size != 0); | 33 | } while (size != 0); |
| 56 | *tf = tot; | 34 | *tf = tot; |
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c index 449f5a66dd34..ebf3440d28ca 100644 --- a/fs/qnx4/inode.c +++ b/fs/qnx4/inode.c | |||
| @@ -64,25 +64,7 @@ static struct buffer_head *qnx4_getblk(struct inode *inode, int nr, | |||
| 64 | result = sb_getblk(inode->i_sb, nr); | 64 | result = sb_getblk(inode->i_sb, nr); |
| 65 | return result; | 65 | return result; |
| 66 | } | 66 | } |
| 67 | if (!create) { | 67 | return NULL; |
| 68 | return NULL; | ||
| 69 | } | ||
| 70 | #if 0 | ||
| 71 | tmp = qnx4_new_block(inode->i_sb); | ||
| 72 | if (!tmp) { | ||
| 73 | return NULL; | ||
| 74 | } | ||
| 75 | result = sb_getblk(inode->i_sb, tmp); | ||
| 76 | if (tst) { | ||
| 77 | qnx4_free_block(inode->i_sb, tmp); | ||
| 78 | brelse(result); | ||
| 79 | goto repeat; | ||
| 80 | } | ||
| 81 | tst = tmp; | ||
| 82 | #endif | ||
| 83 | inode->i_ctime = CURRENT_TIME_SEC; | ||
| 84 | mark_inode_dirty(inode); | ||
| 85 | return result; | ||
| 86 | } | 68 | } |
| 87 | 69 | ||
| 88 | struct buffer_head *qnx4_bread(struct inode *inode, int block, int create) | 70 | struct buffer_head *qnx4_bread(struct inode *inode, int block, int create) |
| @@ -113,8 +95,6 @@ static int qnx4_get_block( struct inode *inode, sector_t iblock, struct buffer_h | |||
| 113 | if ( phys ) { | 95 | if ( phys ) { |
| 114 | // logical block is before EOF | 96 | // logical block is before EOF |
| 115 | map_bh(bh, inode->i_sb, phys); | 97 | map_bh(bh, inode->i_sb, phys); |
| 116 | } else if ( create ) { | ||
| 117 | // to be done. | ||
| 118 | } | 98 | } |
| 119 | return 0; | 99 | return 0; |
| 120 | } | 100 | } |
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c index 32fae4040ebf..2efc57173fd7 100644 --- a/fs/ramfs/file-nommu.c +++ b/fs/ramfs/file-nommu.c | |||
| @@ -60,7 +60,7 @@ const struct inode_operations ramfs_file_inode_operations = { | |||
| 60 | */ | 60 | */ |
| 61 | int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize) | 61 | int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize) |
| 62 | { | 62 | { |
| 63 | unsigned long npages, xpages, loop, limit; | 63 | unsigned long npages, xpages, loop; |
| 64 | struct page *pages; | 64 | struct page *pages; |
| 65 | unsigned order; | 65 | unsigned order; |
| 66 | void *data; | 66 | void *data; |
diff --git a/fs/reiserfs/Makefile b/fs/reiserfs/Makefile index 6a9e30c041dd..792b3cb2cd18 100644 --- a/fs/reiserfs/Makefile +++ b/fs/reiserfs/Makefile | |||
| @@ -7,7 +7,11 @@ obj-$(CONFIG_REISERFS_FS) += reiserfs.o | |||
| 7 | reiserfs-objs := bitmap.o do_balan.o namei.o inode.o file.o dir.o fix_node.o \ | 7 | reiserfs-objs := bitmap.o do_balan.o namei.o inode.o file.o dir.o fix_node.o \ |
| 8 | super.o prints.o objectid.o lbalance.o ibalance.o stree.o \ | 8 | super.o prints.o objectid.o lbalance.o ibalance.o stree.o \ |
| 9 | hashes.o tail_conversion.o journal.o resize.o \ | 9 | hashes.o tail_conversion.o journal.o resize.o \ |
| 10 | item_ops.o ioctl.o procfs.o xattr.o lock.o | 10 | item_ops.o ioctl.o xattr.o lock.o |
| 11 | |||
| 12 | ifeq ($(CONFIG_REISERFS_PROC_INFO),y) | ||
| 13 | reiserfs-objs += procfs.o | ||
| 14 | endif | ||
| 11 | 15 | ||
| 12 | ifeq ($(CONFIG_REISERFS_FS_XATTR),y) | 16 | ifeq ($(CONFIG_REISERFS_FS_XATTR),y) |
| 13 | reiserfs-objs += xattr_user.o xattr_trusted.o | 17 | reiserfs-objs += xattr_user.o xattr_trusted.o |
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index 3a28e7751b3c..290ae38fca8a 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c | |||
| @@ -2538,6 +2538,12 @@ static int reiserfs_writepage(struct page *page, struct writeback_control *wbc) | |||
| 2538 | return reiserfs_write_full_page(page, wbc); | 2538 | return reiserfs_write_full_page(page, wbc); |
| 2539 | } | 2539 | } |
| 2540 | 2540 | ||
| 2541 | static void reiserfs_truncate_failed_write(struct inode *inode) | ||
| 2542 | { | ||
| 2543 | truncate_inode_pages(inode->i_mapping, inode->i_size); | ||
| 2544 | reiserfs_truncate_file(inode, 0); | ||
| 2545 | } | ||
| 2546 | |||
| 2541 | static int reiserfs_write_begin(struct file *file, | 2547 | static int reiserfs_write_begin(struct file *file, |
| 2542 | struct address_space *mapping, | 2548 | struct address_space *mapping, |
| 2543 | loff_t pos, unsigned len, unsigned flags, | 2549 | loff_t pos, unsigned len, unsigned flags, |
| @@ -2604,6 +2610,8 @@ static int reiserfs_write_begin(struct file *file, | |||
| 2604 | if (ret) { | 2610 | if (ret) { |
| 2605 | unlock_page(page); | 2611 | unlock_page(page); |
| 2606 | page_cache_release(page); | 2612 | page_cache_release(page); |
| 2613 | /* Truncate allocated blocks */ | ||
| 2614 | reiserfs_truncate_failed_write(inode); | ||
| 2607 | } | 2615 | } |
| 2608 | return ret; | 2616 | return ret; |
| 2609 | } | 2617 | } |
| @@ -2701,9 +2709,7 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping, | |||
| 2701 | ** transaction tracking stuff when the size changes. So, we have | 2709 | ** transaction tracking stuff when the size changes. So, we have |
| 2702 | ** to do the i_size updates here. | 2710 | ** to do the i_size updates here. |
| 2703 | */ | 2711 | */ |
| 2704 | pos += copied; | 2712 | if (pos + copied > inode->i_size) { |
| 2705 | |||
| 2706 | if (pos > inode->i_size) { | ||
| 2707 | struct reiserfs_transaction_handle myth; | 2713 | struct reiserfs_transaction_handle myth; |
| 2708 | lock_depth = reiserfs_write_lock_once(inode->i_sb); | 2714 | lock_depth = reiserfs_write_lock_once(inode->i_sb); |
| 2709 | locked = true; | 2715 | locked = true; |
| @@ -2721,7 +2727,7 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping, | |||
| 2721 | goto journal_error; | 2727 | goto journal_error; |
| 2722 | 2728 | ||
| 2723 | reiserfs_update_inode_transaction(inode); | 2729 | reiserfs_update_inode_transaction(inode); |
| 2724 | inode->i_size = pos; | 2730 | inode->i_size = pos + copied; |
| 2725 | /* | 2731 | /* |
| 2726 | * this will just nest into our transaction. It's important | 2732 | * this will just nest into our transaction. It's important |
| 2727 | * to use mark_inode_dirty so the inode gets pushed around on the | 2733 | * to use mark_inode_dirty so the inode gets pushed around on the |
| @@ -2751,6 +2757,10 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping, | |||
| 2751 | reiserfs_write_unlock_once(inode->i_sb, lock_depth); | 2757 | reiserfs_write_unlock_once(inode->i_sb, lock_depth); |
| 2752 | unlock_page(page); | 2758 | unlock_page(page); |
| 2753 | page_cache_release(page); | 2759 | page_cache_release(page); |
| 2760 | |||
| 2761 | if (pos + len > inode->i_size) | ||
| 2762 | reiserfs_truncate_failed_write(inode); | ||
| 2763 | |||
| 2754 | return ret == 0 ? copied : ret; | 2764 | return ret == 0 ? copied : ret; |
| 2755 | 2765 | ||
| 2756 | journal_error: | 2766 | journal_error: |
diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c index 9229e5514a4e..7a9981196c1c 100644 --- a/fs/reiserfs/procfs.c +++ b/fs/reiserfs/procfs.c | |||
| @@ -17,8 +17,6 @@ | |||
| 17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
| 18 | #include <linux/proc_fs.h> | 18 | #include <linux/proc_fs.h> |
| 19 | 19 | ||
| 20 | #ifdef CONFIG_REISERFS_PROC_INFO | ||
| 21 | |||
| 22 | /* | 20 | /* |
| 23 | * LOCKING: | 21 | * LOCKING: |
| 24 | * | 22 | * |
| @@ -48,14 +46,6 @@ static int show_version(struct seq_file *m, struct super_block *sb) | |||
| 48 | return 0; | 46 | return 0; |
| 49 | } | 47 | } |
| 50 | 48 | ||
| 51 | int reiserfs_global_version_in_proc(char *buffer, char **start, off_t offset, | ||
| 52 | int count, int *eof, void *data) | ||
| 53 | { | ||
| 54 | *start = buffer; | ||
| 55 | *eof = 1; | ||
| 56 | return 0; | ||
| 57 | } | ||
| 58 | |||
| 59 | #define SF( x ) ( r -> x ) | 49 | #define SF( x ) ( r -> x ) |
| 60 | #define SFP( x ) SF( s_proc_info_data.x ) | 50 | #define SFP( x ) SF( s_proc_info_data.x ) |
| 61 | #define SFPL( x ) SFP( x[ level ] ) | 51 | #define SFPL( x ) SFP( x[ level ] ) |
| @@ -538,19 +528,6 @@ int reiserfs_proc_info_done(struct super_block *sb) | |||
| 538 | return 0; | 528 | return 0; |
| 539 | } | 529 | } |
| 540 | 530 | ||
| 541 | struct proc_dir_entry *reiserfs_proc_register_global(char *name, | ||
| 542 | read_proc_t * func) | ||
| 543 | { | ||
| 544 | return (proc_info_root) ? create_proc_read_entry(name, 0, | ||
| 545 | proc_info_root, | ||
| 546 | func, NULL) : NULL; | ||
| 547 | } | ||
| 548 | |||
| 549 | void reiserfs_proc_unregister_global(const char *name) | ||
| 550 | { | ||
| 551 | remove_proc_entry(name, proc_info_root); | ||
| 552 | } | ||
| 553 | |||
| 554 | int reiserfs_proc_info_global_init(void) | 531 | int reiserfs_proc_info_global_init(void) |
| 555 | { | 532 | { |
| 556 | if (proc_info_root == NULL) { | 533 | if (proc_info_root == NULL) { |
| @@ -572,48 +549,6 @@ int reiserfs_proc_info_global_done(void) | |||
| 572 | } | 549 | } |
| 573 | return 0; | 550 | return 0; |
| 574 | } | 551 | } |
| 575 | |||
| 576 | /* REISERFS_PROC_INFO */ | ||
| 577 | #else | ||
| 578 | |||
| 579 | int reiserfs_proc_info_init(struct super_block *sb) | ||
| 580 | { | ||
| 581 | return 0; | ||
| 582 | } | ||
| 583 | int reiserfs_proc_info_done(struct super_block *sb) | ||
| 584 | { | ||
| 585 | return 0; | ||
| 586 | } | ||
| 587 | |||
| 588 | struct proc_dir_entry *reiserfs_proc_register_global(char *name, | ||
| 589 | read_proc_t * func) | ||
| 590 | { | ||
| 591 | return NULL; | ||
| 592 | } | ||
| 593 | |||
| 594 | void reiserfs_proc_unregister_global(const char *name) | ||
| 595 | {; | ||
| 596 | } | ||
| 597 | |||
| 598 | int reiserfs_proc_info_global_init(void) | ||
| 599 | { | ||
| 600 | return 0; | ||
| 601 | } | ||
| 602 | int reiserfs_proc_info_global_done(void) | ||
| 603 | { | ||
| 604 | return 0; | ||
| 605 | } | ||
| 606 | |||
| 607 | int reiserfs_global_version_in_proc(char *buffer, char **start, | ||
| 608 | off_t offset, | ||
| 609 | int count, int *eof, void *data) | ||
| 610 | { | ||
| 611 | return 0; | ||
| 612 | } | ||
| 613 | |||
| 614 | /* REISERFS_PROC_INFO */ | ||
| 615 | #endif | ||
| 616 | |||
| 617 | /* | 552 | /* |
| 618 | * Revision 1.1.8.2 2001/07/15 17:08:42 god | 553 | * Revision 1.1.8.2 2001/07/15 17:08:42 god |
| 619 | * . use get_super() in procfs.c | 554 | * . use get_super() in procfs.c |
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index 339b0baf2af6..b4a7dd03bdb9 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c | |||
| @@ -2222,8 +2222,6 @@ static int __init init_reiserfs_fs(void) | |||
| 2222 | } | 2222 | } |
| 2223 | 2223 | ||
| 2224 | reiserfs_proc_info_global_init(); | 2224 | reiserfs_proc_info_global_init(); |
| 2225 | reiserfs_proc_register_global("version", | ||
| 2226 | reiserfs_global_version_in_proc); | ||
| 2227 | 2225 | ||
| 2228 | ret = register_filesystem(&reiserfs_fs_type); | 2226 | ret = register_filesystem(&reiserfs_fs_type); |
| 2229 | 2227 | ||
| @@ -2231,7 +2229,6 @@ static int __init init_reiserfs_fs(void) | |||
| 2231 | return 0; | 2229 | return 0; |
| 2232 | } | 2230 | } |
| 2233 | 2231 | ||
| 2234 | reiserfs_proc_unregister_global("version"); | ||
| 2235 | reiserfs_proc_info_global_done(); | 2232 | reiserfs_proc_info_global_done(); |
| 2236 | destroy_inodecache(); | 2233 | destroy_inodecache(); |
| 2237 | 2234 | ||
| @@ -2240,7 +2237,6 @@ static int __init init_reiserfs_fs(void) | |||
| 2240 | 2237 | ||
| 2241 | static void __exit exit_reiserfs_fs(void) | 2238 | static void __exit exit_reiserfs_fs(void) |
| 2242 | { | 2239 | { |
| 2243 | reiserfs_proc_unregister_global("version"); | ||
| 2244 | reiserfs_proc_info_global_done(); | 2240 | reiserfs_proc_info_global_done(); |
| 2245 | unregister_filesystem(&reiserfs_fs_type); | 2241 | unregister_filesystem(&reiserfs_fs_type); |
| 2246 | destroy_inodecache(); | 2242 | destroy_inodecache(); |
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c index 58aa8e75f7f5..8c7033a8b67e 100644 --- a/fs/reiserfs/xattr.c +++ b/fs/reiserfs/xattr.c | |||
| @@ -48,6 +48,7 @@ | |||
| 48 | #include <net/checksum.h> | 48 | #include <net/checksum.h> |
| 49 | #include <linux/stat.h> | 49 | #include <linux/stat.h> |
| 50 | #include <linux/quotaops.h> | 50 | #include <linux/quotaops.h> |
| 51 | #include <linux/security.h> | ||
| 51 | 52 | ||
| 52 | #define PRIVROOT_NAME ".reiserfs_priv" | 53 | #define PRIVROOT_NAME ".reiserfs_priv" |
| 53 | #define XAROOT_NAME "xattrs" | 54 | #define XAROOT_NAME "xattrs" |
| @@ -726,15 +727,14 @@ ssize_t | |||
| 726 | reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, | 727 | reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, |
| 727 | size_t size) | 728 | size_t size) |
| 728 | { | 729 | { |
| 729 | struct inode *inode = dentry->d_inode; | ||
| 730 | struct xattr_handler *handler; | 730 | struct xattr_handler *handler; |
| 731 | 731 | ||
| 732 | handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name); | 732 | handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); |
| 733 | 733 | ||
| 734 | if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1) | 734 | if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) |
| 735 | return -EOPNOTSUPP; | 735 | return -EOPNOTSUPP; |
| 736 | 736 | ||
| 737 | return handler->get(inode, name, buffer, size); | 737 | return handler->get(dentry, name, buffer, size, handler->flags); |
| 738 | } | 738 | } |
| 739 | 739 | ||
| 740 | /* | 740 | /* |
| @@ -746,15 +746,14 @@ int | |||
| 746 | reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, | 746 | reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, |
| 747 | size_t size, int flags) | 747 | size_t size, int flags) |
| 748 | { | 748 | { |
| 749 | struct inode *inode = dentry->d_inode; | ||
| 750 | struct xattr_handler *handler; | 749 | struct xattr_handler *handler; |
| 751 | 750 | ||
| 752 | handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name); | 751 | handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); |
| 753 | 752 | ||
| 754 | if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1) | 753 | if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) |
| 755 | return -EOPNOTSUPP; | 754 | return -EOPNOTSUPP; |
| 756 | 755 | ||
| 757 | return handler->set(inode, name, value, size, flags); | 756 | return handler->set(dentry, name, value, size, flags, handler->flags); |
| 758 | } | 757 | } |
| 759 | 758 | ||
| 760 | /* | 759 | /* |
| @@ -764,21 +763,20 @@ reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, | |||
| 764 | */ | 763 | */ |
| 765 | int reiserfs_removexattr(struct dentry *dentry, const char *name) | 764 | int reiserfs_removexattr(struct dentry *dentry, const char *name) |
| 766 | { | 765 | { |
| 767 | struct inode *inode = dentry->d_inode; | ||
| 768 | struct xattr_handler *handler; | 766 | struct xattr_handler *handler; |
| 769 | handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name); | 767 | handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name); |
| 770 | 768 | ||
| 771 | if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1) | 769 | if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1) |
| 772 | return -EOPNOTSUPP; | 770 | return -EOPNOTSUPP; |
| 773 | 771 | ||
| 774 | return handler->set(inode, name, NULL, 0, XATTR_REPLACE); | 772 | return handler->set(dentry, name, NULL, 0, XATTR_REPLACE, handler->flags); |
| 775 | } | 773 | } |
| 776 | 774 | ||
| 777 | struct listxattr_buf { | 775 | struct listxattr_buf { |
| 778 | size_t size; | 776 | size_t size; |
| 779 | size_t pos; | 777 | size_t pos; |
| 780 | char *buf; | 778 | char *buf; |
| 781 | struct inode *inode; | 779 | struct dentry *dentry; |
| 782 | }; | 780 | }; |
| 783 | 781 | ||
| 784 | static int listxattr_filler(void *buf, const char *name, int namelen, | 782 | static int listxattr_filler(void *buf, const char *name, int namelen, |
| @@ -789,17 +787,19 @@ static int listxattr_filler(void *buf, const char *name, int namelen, | |||
| 789 | if (name[0] != '.' || | 787 | if (name[0] != '.' || |
| 790 | (namelen != 1 && (name[1] != '.' || namelen != 2))) { | 788 | (namelen != 1 && (name[1] != '.' || namelen != 2))) { |
| 791 | struct xattr_handler *handler; | 789 | struct xattr_handler *handler; |
| 792 | handler = find_xattr_handler_prefix(b->inode->i_sb->s_xattr, | 790 | handler = find_xattr_handler_prefix(b->dentry->d_sb->s_xattr, |
| 793 | name); | 791 | name); |
| 794 | if (!handler) /* Unsupported xattr name */ | 792 | if (!handler) /* Unsupported xattr name */ |
| 795 | return 0; | 793 | return 0; |
| 796 | if (b->buf) { | 794 | if (b->buf) { |
| 797 | size = handler->list(b->inode, b->buf + b->pos, | 795 | size = handler->list(b->dentry, b->buf + b->pos, |
| 798 | b->size, name, namelen); | 796 | b->size, name, namelen, |
| 797 | handler->flags); | ||
| 799 | if (size > b->size) | 798 | if (size > b->size) |
| 800 | return -ERANGE; | 799 | return -ERANGE; |
| 801 | } else { | 800 | } else { |
| 802 | size = handler->list(b->inode, NULL, 0, name, namelen); | 801 | size = handler->list(b->dentry, NULL, 0, name, |
| 802 | namelen, handler->flags); | ||
| 803 | } | 803 | } |
| 804 | 804 | ||
| 805 | b->pos += size; | 805 | b->pos += size; |
| @@ -820,7 +820,7 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size) | |||
| 820 | int err = 0; | 820 | int err = 0; |
| 821 | loff_t pos = 0; | 821 | loff_t pos = 0; |
| 822 | struct listxattr_buf buf = { | 822 | struct listxattr_buf buf = { |
| 823 | .inode = dentry->d_inode, | 823 | .dentry = dentry, |
| 824 | .buf = buffer, | 824 | .buf = buffer, |
| 825 | .size = buffer ? size : 0, | 825 | .size = buffer ? size : 0, |
| 826 | }; | 826 | }; |
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c index 35d6e672a279..cc32e6ada67b 100644 --- a/fs/reiserfs/xattr_acl.c +++ b/fs/reiserfs/xattr_acl.c | |||
| @@ -15,8 +15,10 @@ static int reiserfs_set_acl(struct reiserfs_transaction_handle *th, | |||
| 15 | struct posix_acl *acl); | 15 | struct posix_acl *acl); |
| 16 | 16 | ||
| 17 | static int | 17 | static int |
| 18 | xattr_set_acl(struct inode *inode, int type, const void *value, size_t size) | 18 | posix_acl_set(struct dentry *dentry, const char *name, const void *value, |
| 19 | size_t size, int flags, int type) | ||
| 19 | { | 20 | { |
| 21 | struct inode *inode = dentry->d_inode; | ||
| 20 | struct posix_acl *acl; | 22 | struct posix_acl *acl; |
| 21 | int error, error2; | 23 | int error, error2; |
| 22 | struct reiserfs_transaction_handle th; | 24 | struct reiserfs_transaction_handle th; |
| @@ -60,15 +62,16 @@ xattr_set_acl(struct inode *inode, int type, const void *value, size_t size) | |||
| 60 | } | 62 | } |
| 61 | 63 | ||
| 62 | static int | 64 | static int |
| 63 | xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) | 65 | posix_acl_get(struct dentry *dentry, const char *name, void *buffer, |
| 66 | size_t size, int type) | ||
| 64 | { | 67 | { |
| 65 | struct posix_acl *acl; | 68 | struct posix_acl *acl; |
| 66 | int error; | 69 | int error; |
| 67 | 70 | ||
| 68 | if (!reiserfs_posixacl(inode->i_sb)) | 71 | if (!reiserfs_posixacl(dentry->d_sb)) |
| 69 | return -EOPNOTSUPP; | 72 | return -EOPNOTSUPP; |
| 70 | 73 | ||
| 71 | acl = reiserfs_get_acl(inode, type); | 74 | acl = reiserfs_get_acl(dentry->d_inode, type); |
| 72 | if (IS_ERR(acl)) | 75 | if (IS_ERR(acl)) |
| 73 | return PTR_ERR(acl); | 76 | return PTR_ERR(acl); |
| 74 | if (acl == NULL) | 77 | if (acl == NULL) |
| @@ -482,30 +485,12 @@ int reiserfs_acl_chmod(struct inode *inode) | |||
| 482 | return error; | 485 | return error; |
| 483 | } | 486 | } |
| 484 | 487 | ||
| 485 | static int | 488 | static size_t posix_acl_access_list(struct dentry *dentry, char *list, |
| 486 | posix_acl_access_get(struct inode *inode, const char *name, | ||
| 487 | void *buffer, size_t size) | ||
| 488 | { | ||
| 489 | if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1) | ||
| 490 | return -EINVAL; | ||
| 491 | return xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); | ||
| 492 | } | ||
| 493 | |||
| 494 | static int | ||
| 495 | posix_acl_access_set(struct inode *inode, const char *name, | ||
| 496 | const void *value, size_t size, int flags) | ||
| 497 | { | ||
| 498 | if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1) | ||
| 499 | return -EINVAL; | ||
| 500 | return xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
| 501 | } | ||
| 502 | |||
| 503 | static size_t posix_acl_access_list(struct inode *inode, char *list, | ||
| 504 | size_t list_size, const char *name, | 489 | size_t list_size, const char *name, |
| 505 | size_t name_len) | 490 | size_t name_len, int type) |
| 506 | { | 491 | { |
| 507 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); | 492 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); |
| 508 | if (!reiserfs_posixacl(inode->i_sb)) | 493 | if (!reiserfs_posixacl(dentry->d_sb)) |
| 509 | return 0; | 494 | return 0; |
| 510 | if (list && size <= list_size) | 495 | if (list && size <= list_size) |
| 511 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); | 496 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); |
| @@ -514,35 +499,18 @@ static size_t posix_acl_access_list(struct inode *inode, char *list, | |||
| 514 | 499 | ||
| 515 | struct xattr_handler reiserfs_posix_acl_access_handler = { | 500 | struct xattr_handler reiserfs_posix_acl_access_handler = { |
| 516 | .prefix = POSIX_ACL_XATTR_ACCESS, | 501 | .prefix = POSIX_ACL_XATTR_ACCESS, |
| 517 | .get = posix_acl_access_get, | 502 | .flags = ACL_TYPE_ACCESS, |
| 518 | .set = posix_acl_access_set, | 503 | .get = posix_acl_get, |
| 504 | .set = posix_acl_set, | ||
| 519 | .list = posix_acl_access_list, | 505 | .list = posix_acl_access_list, |
| 520 | }; | 506 | }; |
| 521 | 507 | ||
| 522 | static int | 508 | static size_t posix_acl_default_list(struct dentry *dentry, char *list, |
| 523 | posix_acl_default_get(struct inode *inode, const char *name, | ||
| 524 | void *buffer, size_t size) | ||
| 525 | { | ||
| 526 | if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1) | ||
| 527 | return -EINVAL; | ||
| 528 | return xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); | ||
| 529 | } | ||
| 530 | |||
| 531 | static int | ||
| 532 | posix_acl_default_set(struct inode *inode, const char *name, | ||
| 533 | const void *value, size_t size, int flags) | ||
| 534 | { | ||
| 535 | if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1) | ||
| 536 | return -EINVAL; | ||
| 537 | return xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
| 538 | } | ||
| 539 | |||
| 540 | static size_t posix_acl_default_list(struct inode *inode, char *list, | ||
| 541 | size_t list_size, const char *name, | 509 | size_t list_size, const char *name, |
| 542 | size_t name_len) | 510 | size_t name_len, int type) |
| 543 | { | 511 | { |
| 544 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); | 512 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); |
| 545 | if (!reiserfs_posixacl(inode->i_sb)) | 513 | if (!reiserfs_posixacl(dentry->d_sb)) |
| 546 | return 0; | 514 | return 0; |
| 547 | if (list && size <= list_size) | 515 | if (list && size <= list_size) |
| 548 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); | 516 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); |
| @@ -551,7 +519,8 @@ static size_t posix_acl_default_list(struct inode *inode, char *list, | |||
| 551 | 519 | ||
| 552 | struct xattr_handler reiserfs_posix_acl_default_handler = { | 520 | struct xattr_handler reiserfs_posix_acl_default_handler = { |
| 553 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 521 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
| 554 | .get = posix_acl_default_get, | 522 | .flags = ACL_TYPE_DEFAULT, |
| 555 | .set = posix_acl_default_set, | 523 | .get = posix_acl_get, |
| 524 | .set = posix_acl_set, | ||
| 556 | .list = posix_acl_default_list, | 525 | .list = posix_acl_default_list, |
| 557 | }; | 526 | }; |
diff --git a/fs/reiserfs/xattr_security.c b/fs/reiserfs/xattr_security.c index a92c8792c0f6..d8b5bfcbdd30 100644 --- a/fs/reiserfs/xattr_security.c +++ b/fs/reiserfs/xattr_security.c | |||
| @@ -8,36 +8,37 @@ | |||
| 8 | #include <asm/uaccess.h> | 8 | #include <asm/uaccess.h> |
| 9 | 9 | ||
| 10 | static int | 10 | static int |
| 11 | security_get(struct inode *inode, const char *name, void *buffer, size_t size) | 11 | security_get(struct dentry *dentry, const char *name, void *buffer, size_t size, |
| 12 | int handler_flags) | ||
| 12 | { | 13 | { |
| 13 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) | 14 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) |
| 14 | return -EINVAL; | 15 | return -EINVAL; |
| 15 | 16 | ||
| 16 | if (IS_PRIVATE(inode)) | 17 | if (IS_PRIVATE(dentry->d_inode)) |
| 17 | return -EPERM; | 18 | return -EPERM; |
| 18 | 19 | ||
| 19 | return reiserfs_xattr_get(inode, name, buffer, size); | 20 | return reiserfs_xattr_get(dentry->d_inode, name, buffer, size); |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 22 | static int | 23 | static int |
| 23 | security_set(struct inode *inode, const char *name, const void *buffer, | 24 | security_set(struct dentry *dentry, const char *name, const void *buffer, |
| 24 | size_t size, int flags) | 25 | size_t size, int flags, int handler_flags) |
| 25 | { | 26 | { |
| 26 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) | 27 | if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX)) |
| 27 | return -EINVAL; | 28 | return -EINVAL; |
| 28 | 29 | ||
| 29 | if (IS_PRIVATE(inode)) | 30 | if (IS_PRIVATE(dentry->d_inode)) |
| 30 | return -EPERM; | 31 | return -EPERM; |
| 31 | 32 | ||
| 32 | return reiserfs_xattr_set(inode, name, buffer, size, flags); | 33 | return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags); |
| 33 | } | 34 | } |
| 34 | 35 | ||
| 35 | static size_t security_list(struct inode *inode, char *list, size_t list_len, | 36 | static size_t security_list(struct dentry *dentry, char *list, size_t list_len, |
| 36 | const char *name, size_t namelen) | 37 | const char *name, size_t namelen, int handler_flags) |
| 37 | { | 38 | { |
| 38 | const size_t len = namelen + 1; | 39 | const size_t len = namelen + 1; |
| 39 | 40 | ||
| 40 | if (IS_PRIVATE(inode)) | 41 | if (IS_PRIVATE(dentry->d_inode)) |
| 41 | return 0; | 42 | return 0; |
| 42 | 43 | ||
| 43 | if (list && len <= list_len) { | 44 | if (list && len <= list_len) { |
diff --git a/fs/reiserfs/xattr_trusted.c b/fs/reiserfs/xattr_trusted.c index a865042f75e2..5b08aaca3daf 100644 --- a/fs/reiserfs/xattr_trusted.c +++ b/fs/reiserfs/xattr_trusted.c | |||
| @@ -8,36 +8,37 @@ | |||
| 8 | #include <asm/uaccess.h> | 8 | #include <asm/uaccess.h> |
| 9 | 9 | ||
| 10 | static int | 10 | static int |
| 11 | trusted_get(struct inode *inode, const char *name, void *buffer, size_t size) | 11 | trusted_get(struct dentry *dentry, const char *name, void *buffer, size_t size, |
| 12 | int handler_flags) | ||
| 12 | { | 13 | { |
| 13 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) | 14 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) |
| 14 | return -EINVAL; | 15 | return -EINVAL; |
| 15 | 16 | ||
| 16 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) | 17 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(dentry->d_inode)) |
| 17 | return -EPERM; | 18 | return -EPERM; |
| 18 | 19 | ||
| 19 | return reiserfs_xattr_get(inode, name, buffer, size); | 20 | return reiserfs_xattr_get(dentry->d_inode, name, buffer, size); |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 22 | static int | 23 | static int |
| 23 | trusted_set(struct inode *inode, const char *name, const void *buffer, | 24 | trusted_set(struct dentry *dentry, const char *name, const void *buffer, |
| 24 | size_t size, int flags) | 25 | size_t size, int flags, int handler_flags) |
| 25 | { | 26 | { |
| 26 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) | 27 | if (strlen(name) < sizeof(XATTR_TRUSTED_PREFIX)) |
| 27 | return -EINVAL; | 28 | return -EINVAL; |
| 28 | 29 | ||
| 29 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) | 30 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(dentry->d_inode)) |
| 30 | return -EPERM; | 31 | return -EPERM; |
| 31 | 32 | ||
| 32 | return reiserfs_xattr_set(inode, name, buffer, size, flags); | 33 | return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags); |
| 33 | } | 34 | } |
| 34 | 35 | ||
| 35 | static size_t trusted_list(struct inode *inode, char *list, size_t list_size, | 36 | static size_t trusted_list(struct dentry *dentry, char *list, size_t list_size, |
| 36 | const char *name, size_t name_len) | 37 | const char *name, size_t name_len, int handler_flags) |
| 37 | { | 38 | { |
| 38 | const size_t len = name_len + 1; | 39 | const size_t len = name_len + 1; |
| 39 | 40 | ||
| 40 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(inode)) | 41 | if (!capable(CAP_SYS_ADMIN) || IS_PRIVATE(dentry->d_inode)) |
| 41 | return 0; | 42 | return 0; |
| 42 | 43 | ||
| 43 | if (list && len <= list_size) { | 44 | if (list && len <= list_size) { |
diff --git a/fs/reiserfs/xattr_user.c b/fs/reiserfs/xattr_user.c index e3238dc4f3db..75d59c49b911 100644 --- a/fs/reiserfs/xattr_user.c +++ b/fs/reiserfs/xattr_user.c | |||
| @@ -7,34 +7,35 @@ | |||
| 7 | #include <asm/uaccess.h> | 7 | #include <asm/uaccess.h> |
| 8 | 8 | ||
| 9 | static int | 9 | static int |
| 10 | user_get(struct inode *inode, const char *name, void *buffer, size_t size) | 10 | user_get(struct dentry *dentry, const char *name, void *buffer, size_t size, |
| 11 | int handler_flags) | ||
| 11 | { | 12 | { |
| 12 | 13 | ||
| 13 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) | 14 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) |
| 14 | return -EINVAL; | 15 | return -EINVAL; |
| 15 | if (!reiserfs_xattrs_user(inode->i_sb)) | 16 | if (!reiserfs_xattrs_user(dentry->d_sb)) |
| 16 | return -EOPNOTSUPP; | 17 | return -EOPNOTSUPP; |
| 17 | return reiserfs_xattr_get(inode, name, buffer, size); | 18 | return reiserfs_xattr_get(dentry->d_inode, name, buffer, size); |
| 18 | } | 19 | } |
| 19 | 20 | ||
| 20 | static int | 21 | static int |
| 21 | user_set(struct inode *inode, const char *name, const void *buffer, | 22 | user_set(struct dentry *dentry, const char *name, const void *buffer, |
| 22 | size_t size, int flags) | 23 | size_t size, int flags, int handler_flags) |
| 23 | { | 24 | { |
| 24 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) | 25 | if (strlen(name) < sizeof(XATTR_USER_PREFIX)) |
| 25 | return -EINVAL; | 26 | return -EINVAL; |
| 26 | 27 | ||
| 27 | if (!reiserfs_xattrs_user(inode->i_sb)) | 28 | if (!reiserfs_xattrs_user(dentry->d_sb)) |
| 28 | return -EOPNOTSUPP; | 29 | return -EOPNOTSUPP; |
| 29 | return reiserfs_xattr_set(inode, name, buffer, size, flags); | 30 | return reiserfs_xattr_set(dentry->d_inode, name, buffer, size, flags); |
| 30 | } | 31 | } |
| 31 | 32 | ||
| 32 | static size_t user_list(struct inode *inode, char *list, size_t list_size, | 33 | static size_t user_list(struct dentry *dentry, char *list, size_t list_size, |
| 33 | const char *name, size_t name_len) | 34 | const char *name, size_t name_len, int handler_flags) |
| 34 | { | 35 | { |
| 35 | const size_t len = name_len + 1; | 36 | const size_t len = name_len + 1; |
| 36 | 37 | ||
| 37 | if (!reiserfs_xattrs_user(inode->i_sb)) | 38 | if (!reiserfs_xattrs_user(dentry->d_sb)) |
| 38 | return 0; | 39 | return 0; |
| 39 | if (list && len <= list_size) { | 40 | if (list && len <= list_size) { |
| 40 | memcpy(list, name, name_len); | 41 | memcpy(list, name, name_len); |
diff --git a/fs/stack.c b/fs/stack.c index 67716f6a1a4a..4a6f7f440658 100644 --- a/fs/stack.c +++ b/fs/stack.c | |||
| @@ -7,18 +7,63 @@ | |||
| 7 | * This function cannot be inlined since i_size_{read,write} is rather | 7 | * This function cannot be inlined since i_size_{read,write} is rather |
| 8 | * heavy-weight on 32-bit systems | 8 | * heavy-weight on 32-bit systems |
| 9 | */ | 9 | */ |
| 10 | void fsstack_copy_inode_size(struct inode *dst, const struct inode *src) | 10 | void fsstack_copy_inode_size(struct inode *dst, struct inode *src) |
| 11 | { | 11 | { |
| 12 | i_size_write(dst, i_size_read((struct inode *)src)); | 12 | loff_t i_size; |
| 13 | dst->i_blocks = src->i_blocks; | 13 | blkcnt_t i_blocks; |
| 14 | |||
| 15 | /* | ||
| 16 | * i_size_read() includes its own seqlocking and protection from | ||
| 17 | * preemption (see include/linux/fs.h): we need nothing extra for | ||
| 18 | * that here, and prefer to avoid nesting locks than attempt to keep | ||
| 19 | * i_size and i_blocks in sync together. | ||
| 20 | */ | ||
| 21 | i_size = i_size_read(src); | ||
| 22 | |||
| 23 | /* | ||
| 24 | * But if CONFIG_LBDAF (on 32-bit), we ought to make an effort to | ||
| 25 | * keep the two halves of i_blocks in sync despite SMP or PREEMPT - | ||
| 26 | * though stat's generic_fillattr() doesn't bother, and we won't be | ||
| 27 | * applying quotas (where i_blocks does become important) at the | ||
| 28 | * upper level. | ||
| 29 | * | ||
| 30 | * We don't actually know what locking is used at the lower level; | ||
| 31 | * but if it's a filesystem that supports quotas, it will be using | ||
| 32 | * i_lock as in inode_add_bytes(). tmpfs uses other locking, and | ||
| 33 | * its 32-bit is (just) able to exceed 2TB i_size with the aid of | ||
| 34 | * holes; but its i_blocks cannot carry into the upper long without | ||
| 35 | * almost 2TB swap - let's ignore that case. | ||
| 36 | */ | ||
| 37 | if (sizeof(i_blocks) > sizeof(long)) | ||
| 38 | spin_lock(&src->i_lock); | ||
| 39 | i_blocks = src->i_blocks; | ||
| 40 | if (sizeof(i_blocks) > sizeof(long)) | ||
| 41 | spin_unlock(&src->i_lock); | ||
| 42 | |||
| 43 | /* | ||
| 44 | * If CONFIG_SMP or CONFIG_PREEMPT on 32-bit, it's vital for | ||
| 45 | * fsstack_copy_inode_size() to hold some lock around | ||
| 46 | * i_size_write(), otherwise i_size_read() may spin forever (see | ||
| 47 | * include/linux/fs.h). We don't necessarily hold i_mutex when this | ||
| 48 | * is called, so take i_lock for that case. | ||
| 49 | * | ||
| 50 | * And if CONFIG_LBADF (on 32-bit), continue our effort to keep the | ||
| 51 | * two halves of i_blocks in sync despite SMP or PREEMPT: use i_lock | ||
| 52 | * for that case too, and do both at once by combining the tests. | ||
| 53 | * | ||
| 54 | * There is none of this locking overhead in the 64-bit case. | ||
| 55 | */ | ||
| 56 | if (sizeof(i_size) > sizeof(long) || sizeof(i_blocks) > sizeof(long)) | ||
| 57 | spin_lock(&dst->i_lock); | ||
| 58 | i_size_write(dst, i_size); | ||
| 59 | dst->i_blocks = i_blocks; | ||
| 60 | if (sizeof(i_size) > sizeof(long) || sizeof(i_blocks) > sizeof(long)) | ||
| 61 | spin_unlock(&dst->i_lock); | ||
| 14 | } | 62 | } |
| 15 | EXPORT_SYMBOL_GPL(fsstack_copy_inode_size); | 63 | EXPORT_SYMBOL_GPL(fsstack_copy_inode_size); |
| 16 | 64 | ||
| 17 | /* copy all attributes; get_nlinks is optional way to override the i_nlink | 65 | /* copy all attributes */ |
| 18 | * copying | 66 | void fsstack_copy_attr_all(struct inode *dest, const struct inode *src) |
| 19 | */ | ||
| 20 | void fsstack_copy_attr_all(struct inode *dest, const struct inode *src, | ||
| 21 | int (*get_nlinks)(struct inode *)) | ||
| 22 | { | 67 | { |
| 23 | dest->i_mode = src->i_mode; | 68 | dest->i_mode = src->i_mode; |
| 24 | dest->i_uid = src->i_uid; | 69 | dest->i_uid = src->i_uid; |
| @@ -29,14 +74,6 @@ void fsstack_copy_attr_all(struct inode *dest, const struct inode *src, | |||
| 29 | dest->i_ctime = src->i_ctime; | 74 | dest->i_ctime = src->i_ctime; |
| 30 | dest->i_blkbits = src->i_blkbits; | 75 | dest->i_blkbits = src->i_blkbits; |
| 31 | dest->i_flags = src->i_flags; | 76 | dest->i_flags = src->i_flags; |
| 32 | 77 | dest->i_nlink = src->i_nlink; | |
| 33 | /* | ||
| 34 | * Update the nlinks AFTER updating the above fields, because the | ||
| 35 | * get_links callback may depend on them. | ||
| 36 | */ | ||
| 37 | if (!get_nlinks) | ||
| 38 | dest->i_nlink = src->i_nlink; | ||
| 39 | else | ||
| 40 | dest->i_nlink = (*get_nlinks)(dest); | ||
| 41 | } | 78 | } |
| 42 | EXPORT_SYMBOL_GPL(fsstack_copy_attr_all); | 79 | EXPORT_SYMBOL_GPL(fsstack_copy_attr_all); |
| @@ -355,6 +355,7 @@ SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes, | |||
| 355 | { | 355 | { |
| 356 | int ret; | 356 | int ret; |
| 357 | struct file *file; | 357 | struct file *file; |
| 358 | struct address_space *mapping; | ||
| 358 | loff_t endbyte; /* inclusive */ | 359 | loff_t endbyte; /* inclusive */ |
| 359 | int fput_needed; | 360 | int fput_needed; |
| 360 | umode_t i_mode; | 361 | umode_t i_mode; |
| @@ -405,7 +406,28 @@ SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes, | |||
| 405 | !S_ISLNK(i_mode)) | 406 | !S_ISLNK(i_mode)) |
| 406 | goto out_put; | 407 | goto out_put; |
| 407 | 408 | ||
| 408 | ret = do_sync_mapping_range(file->f_mapping, offset, endbyte, flags); | 409 | mapping = file->f_mapping; |
| 410 | if (!mapping) { | ||
| 411 | ret = -EINVAL; | ||
| 412 | goto out_put; | ||
| 413 | } | ||
| 414 | |||
| 415 | ret = 0; | ||
| 416 | if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) { | ||
| 417 | ret = filemap_fdatawait_range(mapping, offset, endbyte); | ||
| 418 | if (ret < 0) | ||
| 419 | goto out_put; | ||
| 420 | } | ||
| 421 | |||
| 422 | if (flags & SYNC_FILE_RANGE_WRITE) { | ||
| 423 | ret = filemap_fdatawrite_range(mapping, offset, endbyte); | ||
| 424 | if (ret < 0) | ||
| 425 | goto out_put; | ||
| 426 | } | ||
| 427 | |||
| 428 | if (flags & SYNC_FILE_RANGE_WAIT_AFTER) | ||
| 429 | ret = filemap_fdatawait_range(mapping, offset, endbyte); | ||
| 430 | |||
| 409 | out_put: | 431 | out_put: |
| 410 | fput_light(file, fput_needed); | 432 | fput_light(file, fput_needed); |
| 411 | out: | 433 | out: |
| @@ -437,38 +459,3 @@ asmlinkage long SyS_sync_file_range2(long fd, long flags, | |||
| 437 | } | 459 | } |
| 438 | SYSCALL_ALIAS(sys_sync_file_range2, SyS_sync_file_range2); | 460 | SYSCALL_ALIAS(sys_sync_file_range2, SyS_sync_file_range2); |
| 439 | #endif | 461 | #endif |
| 440 | |||
| 441 | /* | ||
| 442 | * `endbyte' is inclusive | ||
| 443 | */ | ||
| 444 | int do_sync_mapping_range(struct address_space *mapping, loff_t offset, | ||
| 445 | loff_t endbyte, unsigned int flags) | ||
| 446 | { | ||
| 447 | int ret; | ||
| 448 | |||
| 449 | if (!mapping) { | ||
| 450 | ret = -EINVAL; | ||
| 451 | goto out; | ||
| 452 | } | ||
| 453 | |||
| 454 | ret = 0; | ||
| 455 | if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) { | ||
| 456 | ret = filemap_fdatawait_range(mapping, offset, endbyte); | ||
| 457 | if (ret < 0) | ||
| 458 | goto out; | ||
| 459 | } | ||
| 460 | |||
| 461 | if (flags & SYNC_FILE_RANGE_WRITE) { | ||
| 462 | ret = __filemap_fdatawrite_range(mapping, offset, endbyte, | ||
| 463 | WB_SYNC_ALL); | ||
| 464 | if (ret < 0) | ||
| 465 | goto out; | ||
| 466 | } | ||
| 467 | |||
| 468 | if (flags & SYNC_FILE_RANGE_WAIT_AFTER) { | ||
| 469 | ret = filemap_fdatawait_range(mapping, offset, endbyte); | ||
| 470 | } | ||
| 471 | out: | ||
| 472 | return ret; | ||
| 473 | } | ||
| 474 | EXPORT_SYMBOL_GPL(do_sync_mapping_range); | ||
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 8a771c59ac3e..90492327b383 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c | |||
| @@ -350,13 +350,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node) | |||
| 350 | le32_to_cpu(sup->fmt_version)); | 350 | le32_to_cpu(sup->fmt_version)); |
| 351 | printk(KERN_DEBUG "\ttime_gran %u\n", | 351 | printk(KERN_DEBUG "\ttime_gran %u\n", |
| 352 | le32_to_cpu(sup->time_gran)); | 352 | le32_to_cpu(sup->time_gran)); |
| 353 | printk(KERN_DEBUG "\tUUID %02X%02X%02X%02X-%02X%02X" | 353 | printk(KERN_DEBUG "\tUUID %pUB\n", |
| 354 | "-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X\n", | 354 | sup->uuid); |
| 355 | sup->uuid[0], sup->uuid[1], sup->uuid[2], sup->uuid[3], | ||
| 356 | sup->uuid[4], sup->uuid[5], sup->uuid[6], sup->uuid[7], | ||
| 357 | sup->uuid[8], sup->uuid[9], sup->uuid[10], sup->uuid[11], | ||
| 358 | sup->uuid[12], sup->uuid[13], sup->uuid[14], | ||
| 359 | sup->uuid[15]); | ||
| 360 | break; | 355 | break; |
| 361 | } | 356 | } |
| 362 | case UBIFS_MST_NODE: | 357 | case UBIFS_MST_NODE: |
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 39849f887e72..16a6444330ec 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c | |||
| @@ -45,7 +45,7 @@ | |||
| 45 | * | 45 | * |
| 46 | * Similarly, @i_mutex is not always locked in 'ubifs_readpage()', e.g., the | 46 | * Similarly, @i_mutex is not always locked in 'ubifs_readpage()', e.g., the |
| 47 | * read-ahead path does not lock it ("sys_read -> generic_file_aio_read -> | 47 | * read-ahead path does not lock it ("sys_read -> generic_file_aio_read -> |
| 48 | * ondemand_readahead -> readpage"). In case of readahead, @I_LOCK flag is not | 48 | * ondemand_readahead -> readpage"). In case of readahead, @I_SYNC flag is not |
| 49 | * set as well. However, UBIFS disables readahead. | 49 | * set as well. However, UBIFS disables readahead. |
| 50 | */ | 50 | */ |
| 51 | 51 | ||
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 943ad5624530..43f9d19a6f33 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
| @@ -1393,12 +1393,7 @@ static int mount_ubifs(struct ubifs_info *c) | |||
| 1393 | c->leb_size, c->leb_size >> 10); | 1393 | c->leb_size, c->leb_size >> 10); |
| 1394 | dbg_msg("data journal heads: %d", | 1394 | dbg_msg("data journal heads: %d", |
| 1395 | c->jhead_cnt - NONDATA_JHEADS_CNT); | 1395 | c->jhead_cnt - NONDATA_JHEADS_CNT); |
| 1396 | dbg_msg("UUID: %02X%02X%02X%02X-%02X%02X" | 1396 | dbg_msg("UUID: %pUB", c->uuid); |
| 1397 | "-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X", | ||
| 1398 | c->uuid[0], c->uuid[1], c->uuid[2], c->uuid[3], | ||
| 1399 | c->uuid[4], c->uuid[5], c->uuid[6], c->uuid[7], | ||
| 1400 | c->uuid[8], c->uuid[9], c->uuid[10], c->uuid[11], | ||
| 1401 | c->uuid[12], c->uuid[13], c->uuid[14], c->uuid[15]); | ||
| 1402 | dbg_msg("big_lpt %d", c->big_lpt); | 1397 | dbg_msg("big_lpt %d", c->big_lpt); |
| 1403 | dbg_msg("log LEBs: %d (%d - %d)", | 1398 | dbg_msg("log LEBs: %d (%d - %d)", |
| 1404 | c->log_lebs, UBIFS_LOG_LNUM, c->log_last); | 1399 | c->log_lebs, UBIFS_LOG_LNUM, c->log_last); |
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c index 1e068535b58b..82372e332f08 100644 --- a/fs/udf/balloc.c +++ b/fs/udf/balloc.c | |||
| @@ -440,7 +440,7 @@ static void udf_table_free_blocks(struct super_block *sb, | |||
| 440 | (bloc->logicalBlockNum + count) > | 440 | (bloc->logicalBlockNum + count) > |
| 441 | partmap->s_partition_len) { | 441 | partmap->s_partition_len) { |
| 442 | udf_debug("%d < %d || %d + %d > %d\n", | 442 | udf_debug("%d < %d || %d + %d > %d\n", |
| 443 | bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count, | 443 | bloc->logicalBlockNum, 0, bloc->logicalBlockNum, count, |
| 444 | partmap->s_partition_len); | 444 | partmap->s_partition_len); |
| 445 | goto error_return; | 445 | goto error_return; |
| 446 | } | 446 | } |
diff --git a/fs/udf/file.c b/fs/udf/file.c index b80cbd78833c..f311d509b6a3 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c | |||
| @@ -196,6 +196,7 @@ static int udf_release_file(struct inode *inode, struct file *filp) | |||
| 196 | mutex_lock(&inode->i_mutex); | 196 | mutex_lock(&inode->i_mutex); |
| 197 | lock_kernel(); | 197 | lock_kernel(); |
| 198 | udf_discard_prealloc(inode); | 198 | udf_discard_prealloc(inode); |
| 199 | udf_truncate_tail_extent(inode); | ||
| 199 | unlock_kernel(); | 200 | unlock_kernel(); |
| 200 | mutex_unlock(&inode->i_mutex); | 201 | mutex_unlock(&inode->i_mutex); |
| 201 | } | 202 | } |
diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 6d24c2c63f93..f90231eb2916 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c | |||
| @@ -97,15 +97,17 @@ no_delete: | |||
| 97 | */ | 97 | */ |
| 98 | void udf_clear_inode(struct inode *inode) | 98 | void udf_clear_inode(struct inode *inode) |
| 99 | { | 99 | { |
| 100 | struct udf_inode_info *iinfo; | 100 | struct udf_inode_info *iinfo = UDF_I(inode); |
| 101 | if (!(inode->i_sb->s_flags & MS_RDONLY)) { | 101 | |
| 102 | lock_kernel(); | 102 | if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB && |
| 103 | udf_truncate_tail_extent(inode); | 103 | inode->i_size != iinfo->i_lenExtents) { |
| 104 | unlock_kernel(); | 104 | printk(KERN_WARNING "UDF-fs (%s): Inode %lu (mode %o) has " |
| 105 | write_inode_now(inode, 0); | 105 | "inode size %llu different from extent lenght %llu. " |
| 106 | invalidate_inode_buffers(inode); | 106 | "Filesystem need not be standards compliant.\n", |
| 107 | inode->i_sb->s_id, inode->i_ino, inode->i_mode, | ||
| 108 | (unsigned long long)inode->i_size, | ||
| 109 | (unsigned long long)iinfo->i_lenExtents); | ||
| 107 | } | 110 | } |
| 108 | iinfo = UDF_I(inode); | ||
| 109 | kfree(iinfo->i_ext.i_data); | 111 | kfree(iinfo->i_ext.i_data); |
| 110 | iinfo->i_ext.i_data = NULL; | 112 | iinfo->i_ext.i_data = NULL; |
| 111 | } | 113 | } |
| @@ -198,7 +200,6 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
| 198 | int newblock; | 200 | int newblock; |
| 199 | struct buffer_head *dbh = NULL; | 201 | struct buffer_head *dbh = NULL; |
| 200 | struct kernel_lb_addr eloc; | 202 | struct kernel_lb_addr eloc; |
| 201 | uint32_t elen; | ||
| 202 | uint8_t alloctype; | 203 | uint8_t alloctype; |
| 203 | struct extent_position epos; | 204 | struct extent_position epos; |
| 204 | 205 | ||
| @@ -273,12 +274,11 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block, | |||
| 273 | eloc.logicalBlockNum = *block; | 274 | eloc.logicalBlockNum = *block; |
| 274 | eloc.partitionReferenceNum = | 275 | eloc.partitionReferenceNum = |
| 275 | iinfo->i_location.partitionReferenceNum; | 276 | iinfo->i_location.partitionReferenceNum; |
| 276 | elen = inode->i_sb->s_blocksize; | 277 | iinfo->i_lenExtents = inode->i_size; |
| 277 | iinfo->i_lenExtents = elen; | ||
| 278 | epos.bh = NULL; | 278 | epos.bh = NULL; |
| 279 | epos.block = iinfo->i_location; | 279 | epos.block = iinfo->i_location; |
| 280 | epos.offset = udf_file_entry_alloc_offset(inode); | 280 | epos.offset = udf_file_entry_alloc_offset(inode); |
| 281 | udf_add_aext(inode, &epos, &eloc, elen, 0); | 281 | udf_add_aext(inode, &epos, &eloc, inode->i_size, 0); |
| 282 | /* UniqueID stuff */ | 282 | /* UniqueID stuff */ |
| 283 | 283 | ||
| 284 | brelse(epos.bh); | 284 | brelse(epos.bh); |
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 21dad8c608f9..cd2115060fdc 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c | |||
| @@ -408,15 +408,6 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
| 408 | } | 408 | } |
| 409 | 409 | ||
| 410 | add: | 410 | add: |
| 411 | /* Is there any extent whose size we need to round up? */ | ||
| 412 | if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB && elen) { | ||
| 413 | elen = (elen + sb->s_blocksize - 1) & ~(sb->s_blocksize - 1); | ||
| 414 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) | ||
| 415 | epos.offset -= sizeof(struct short_ad); | ||
| 416 | else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) | ||
| 417 | epos.offset -= sizeof(struct long_ad); | ||
| 418 | udf_write_aext(dir, &epos, &eloc, elen, 1); | ||
| 419 | } | ||
| 420 | f_pos += nfidlen; | 411 | f_pos += nfidlen; |
| 421 | 412 | ||
| 422 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB && | 413 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB && |
| @@ -439,6 +430,7 @@ add: | |||
| 439 | udf_current_aext(dir, &epos, &eloc, &elen, 1); | 430 | udf_current_aext(dir, &epos, &eloc, &elen, 1); |
| 440 | } | 431 | } |
| 441 | 432 | ||
| 433 | /* Entry fits into current block? */ | ||
| 442 | if (sb->s_blocksize - fibh->eoffset >= nfidlen) { | 434 | if (sb->s_blocksize - fibh->eoffset >= nfidlen) { |
| 443 | fibh->soffset = fibh->eoffset; | 435 | fibh->soffset = fibh->eoffset; |
| 444 | fibh->eoffset += nfidlen; | 436 | fibh->eoffset += nfidlen; |
| @@ -462,6 +454,16 @@ add: | |||
| 462 | (fibh->sbh->b_data + fibh->soffset); | 454 | (fibh->sbh->b_data + fibh->soffset); |
| 463 | } | 455 | } |
| 464 | } else { | 456 | } else { |
| 457 | /* Round up last extent in the file */ | ||
| 458 | elen = (elen + sb->s_blocksize - 1) & ~(sb->s_blocksize - 1); | ||
| 459 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) | ||
| 460 | epos.offset -= sizeof(struct short_ad); | ||
| 461 | else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) | ||
| 462 | epos.offset -= sizeof(struct long_ad); | ||
| 463 | udf_write_aext(dir, &epos, &eloc, elen, 1); | ||
| 464 | dinfo->i_lenExtents = (dinfo->i_lenExtents + sb->s_blocksize | ||
| 465 | - 1) & ~(sb->s_blocksize - 1); | ||
| 466 | |||
| 465 | fibh->soffset = fibh->eoffset - sb->s_blocksize; | 467 | fibh->soffset = fibh->eoffset - sb->s_blocksize; |
| 466 | fibh->eoffset += nfidlen - sb->s_blocksize; | 468 | fibh->eoffset += nfidlen - sb->s_blocksize; |
| 467 | if (fibh->sbh != fibh->ebh) { | 469 | if (fibh->sbh != fibh->ebh) { |
| @@ -508,6 +510,20 @@ add: | |||
| 508 | dir->i_size += nfidlen; | 510 | dir->i_size += nfidlen; |
| 509 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | 511 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
| 510 | dinfo->i_lenAlloc += nfidlen; | 512 | dinfo->i_lenAlloc += nfidlen; |
| 513 | else { | ||
| 514 | /* Find the last extent and truncate it to proper size */ | ||
| 515 | while (udf_next_aext(dir, &epos, &eloc, &elen, 1) == | ||
| 516 | (EXT_RECORDED_ALLOCATED >> 30)) | ||
| 517 | ; | ||
| 518 | elen -= dinfo->i_lenExtents - dir->i_size; | ||
| 519 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) | ||
| 520 | epos.offset -= sizeof(struct short_ad); | ||
| 521 | else if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) | ||
| 522 | epos.offset -= sizeof(struct long_ad); | ||
| 523 | udf_write_aext(dir, &epos, &eloc, elen, 1); | ||
| 524 | dinfo->i_lenExtents = dir->i_size; | ||
| 525 | } | ||
| 526 | |||
| 511 | mark_inode_dirty(dir); | 527 | mark_inode_dirty(dir); |
| 512 | goto out_ok; | 528 | goto out_ok; |
| 513 | } else { | 529 | } else { |
| @@ -922,7 +938,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
| 922 | block = udf_get_pblock(inode->i_sb, block, | 938 | block = udf_get_pblock(inode->i_sb, block, |
| 923 | iinfo->i_location.partitionReferenceNum, | 939 | iinfo->i_location.partitionReferenceNum, |
| 924 | 0); | 940 | 0); |
| 925 | epos.bh = udf_tread(inode->i_sb, block); | 941 | epos.bh = udf_tgetblk(inode->i_sb, block); |
| 926 | lock_buffer(epos.bh); | 942 | lock_buffer(epos.bh); |
| 927 | memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize); | 943 | memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize); |
| 928 | set_buffer_uptodate(epos.bh); | 944 | set_buffer_uptodate(epos.bh); |
| @@ -999,6 +1015,8 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, | |||
| 999 | inode->i_size = elen; | 1015 | inode->i_size = elen; |
| 1000 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) | 1016 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) |
| 1001 | iinfo->i_lenAlloc = inode->i_size; | 1017 | iinfo->i_lenAlloc = inode->i_size; |
| 1018 | else | ||
| 1019 | udf_truncate_tail_extent(inode); | ||
| 1002 | mark_inode_dirty(inode); | 1020 | mark_inode_dirty(inode); |
| 1003 | 1021 | ||
| 1004 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); | 1022 | fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); |
diff --git a/fs/udf/super.c b/fs/udf/super.c index 9d1b8c2e6c45..1e4543cbcd27 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
| @@ -1078,21 +1078,39 @@ static int udf_fill_partdesc_info(struct super_block *sb, | |||
| 1078 | return 0; | 1078 | return 0; |
| 1079 | } | 1079 | } |
| 1080 | 1080 | ||
| 1081 | static int udf_load_vat(struct super_block *sb, int p_index, int type1_index) | 1081 | static void udf_find_vat_block(struct super_block *sb, int p_index, |
| 1082 | int type1_index, sector_t start_block) | ||
| 1082 | { | 1083 | { |
| 1083 | struct udf_sb_info *sbi = UDF_SB(sb); | 1084 | struct udf_sb_info *sbi = UDF_SB(sb); |
| 1084 | struct udf_part_map *map = &sbi->s_partmaps[p_index]; | 1085 | struct udf_part_map *map = &sbi->s_partmaps[p_index]; |
| 1086 | sector_t vat_block; | ||
| 1085 | struct kernel_lb_addr ino; | 1087 | struct kernel_lb_addr ino; |
| 1088 | |||
| 1089 | /* | ||
| 1090 | * VAT file entry is in the last recorded block. Some broken disks have | ||
| 1091 | * it a few blocks before so try a bit harder... | ||
| 1092 | */ | ||
| 1093 | ino.partitionReferenceNum = type1_index; | ||
| 1094 | for (vat_block = start_block; | ||
| 1095 | vat_block >= map->s_partition_root && | ||
| 1096 | vat_block >= start_block - 3 && | ||
| 1097 | !sbi->s_vat_inode; vat_block--) { | ||
| 1098 | ino.logicalBlockNum = vat_block - map->s_partition_root; | ||
| 1099 | sbi->s_vat_inode = udf_iget(sb, &ino); | ||
| 1100 | } | ||
| 1101 | } | ||
| 1102 | |||
| 1103 | static int udf_load_vat(struct super_block *sb, int p_index, int type1_index) | ||
| 1104 | { | ||
| 1105 | struct udf_sb_info *sbi = UDF_SB(sb); | ||
| 1106 | struct udf_part_map *map = &sbi->s_partmaps[p_index]; | ||
| 1086 | struct buffer_head *bh = NULL; | 1107 | struct buffer_head *bh = NULL; |
| 1087 | struct udf_inode_info *vati; | 1108 | struct udf_inode_info *vati; |
| 1088 | uint32_t pos; | 1109 | uint32_t pos; |
| 1089 | struct virtualAllocationTable20 *vat20; | 1110 | struct virtualAllocationTable20 *vat20; |
| 1090 | sector_t blocks = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; | 1111 | sector_t blocks = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; |
| 1091 | 1112 | ||
| 1092 | /* VAT file entry is in the last recorded block */ | 1113 | udf_find_vat_block(sb, p_index, type1_index, sbi->s_last_block); |
| 1093 | ino.partitionReferenceNum = type1_index; | ||
| 1094 | ino.logicalBlockNum = sbi->s_last_block - map->s_partition_root; | ||
| 1095 | sbi->s_vat_inode = udf_iget(sb, &ino); | ||
| 1096 | if (!sbi->s_vat_inode && | 1114 | if (!sbi->s_vat_inode && |
| 1097 | sbi->s_last_block != blocks - 1) { | 1115 | sbi->s_last_block != blocks - 1) { |
| 1098 | printk(KERN_NOTICE "UDF-fs: Failed to read VAT inode from the" | 1116 | printk(KERN_NOTICE "UDF-fs: Failed to read VAT inode from the" |
| @@ -1100,9 +1118,7 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index) | |||
| 1100 | "block of the device (%lu).\n", | 1118 | "block of the device (%lu).\n", |
| 1101 | (unsigned long)sbi->s_last_block, | 1119 | (unsigned long)sbi->s_last_block, |
| 1102 | (unsigned long)blocks - 1); | 1120 | (unsigned long)blocks - 1); |
| 1103 | ino.partitionReferenceNum = type1_index; | 1121 | udf_find_vat_block(sb, p_index, type1_index, blocks - 1); |
| 1104 | ino.logicalBlockNum = blocks - 1 - map->s_partition_root; | ||
| 1105 | sbi->s_vat_inode = udf_iget(sb, &ino); | ||
| 1106 | } | 1122 | } |
| 1107 | if (!sbi->s_vat_inode) | 1123 | if (!sbi->s_vat_inode) |
| 1108 | return 1; | 1124 | return 1; |
diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index 6f671f1ac271..22af68f8b682 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c | |||
| @@ -70,13 +70,13 @@ static inline unsigned long ufs_dir_pages(struct inode *inode) | |||
| 70 | return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT; | 70 | return (inode->i_size+PAGE_CACHE_SIZE-1)>>PAGE_CACHE_SHIFT; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | ino_t ufs_inode_by_name(struct inode *dir, struct dentry *dentry) | 73 | ino_t ufs_inode_by_name(struct inode *dir, struct qstr *qstr) |
| 74 | { | 74 | { |
| 75 | ino_t res = 0; | 75 | ino_t res = 0; |
| 76 | struct ufs_dir_entry *de; | 76 | struct ufs_dir_entry *de; |
| 77 | struct page *page; | 77 | struct page *page; |
| 78 | 78 | ||
| 79 | de = ufs_find_entry(dir, dentry, &page); | 79 | de = ufs_find_entry(dir, qstr, &page); |
| 80 | if (de) { | 80 | if (de) { |
| 81 | res = fs32_to_cpu(dir->i_sb, de->d_ino); | 81 | res = fs32_to_cpu(dir->i_sb, de->d_ino); |
| 82 | ufs_put_page(page); | 82 | ufs_put_page(page); |
| @@ -249,12 +249,12 @@ struct ufs_dir_entry *ufs_dotdot(struct inode *dir, struct page **p) | |||
| 249 | * (as a parameter - res_dir). Page is returned mapped and unlocked. | 249 | * (as a parameter - res_dir). Page is returned mapped and unlocked. |
| 250 | * Entry is guaranteed to be valid. | 250 | * Entry is guaranteed to be valid. |
| 251 | */ | 251 | */ |
| 252 | struct ufs_dir_entry *ufs_find_entry(struct inode *dir, struct dentry *dentry, | 252 | struct ufs_dir_entry *ufs_find_entry(struct inode *dir, struct qstr *qstr, |
| 253 | struct page **res_page) | 253 | struct page **res_page) |
| 254 | { | 254 | { |
| 255 | struct super_block *sb = dir->i_sb; | 255 | struct super_block *sb = dir->i_sb; |
| 256 | const char *name = dentry->d_name.name; | 256 | const char *name = qstr->name; |
| 257 | int namelen = dentry->d_name.len; | 257 | int namelen = qstr->len; |
| 258 | unsigned reclen = UFS_DIR_REC_LEN(namelen); | 258 | unsigned reclen = UFS_DIR_REC_LEN(namelen); |
| 259 | unsigned long start, n; | 259 | unsigned long start, n; |
| 260 | unsigned long npages = ufs_dir_pages(dir); | 260 | unsigned long npages = ufs_dir_pages(dir); |
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index 23119fe7ad62..4c26d9e8bc94 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c | |||
| @@ -56,7 +56,7 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, stru | |||
| 56 | return ERR_PTR(-ENAMETOOLONG); | 56 | return ERR_PTR(-ENAMETOOLONG); |
| 57 | 57 | ||
| 58 | lock_kernel(); | 58 | lock_kernel(); |
| 59 | ino = ufs_inode_by_name(dir, dentry); | 59 | ino = ufs_inode_by_name(dir, &dentry->d_name); |
| 60 | if (ino) { | 60 | if (ino) { |
| 61 | inode = ufs_iget(dir->i_sb, ino); | 61 | inode = ufs_iget(dir->i_sb, ino); |
| 62 | if (IS_ERR(inode)) { | 62 | if (IS_ERR(inode)) { |
| @@ -237,7 +237,7 @@ static int ufs_unlink(struct inode *dir, struct dentry *dentry) | |||
| 237 | struct page *page; | 237 | struct page *page; |
| 238 | int err = -ENOENT; | 238 | int err = -ENOENT; |
| 239 | 239 | ||
| 240 | de = ufs_find_entry(dir, dentry, &page); | 240 | de = ufs_find_entry(dir, &dentry->d_name, &page); |
| 241 | if (!de) | 241 | if (!de) |
| 242 | goto out; | 242 | goto out; |
| 243 | 243 | ||
| @@ -281,7 +281,7 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 281 | struct ufs_dir_entry *old_de; | 281 | struct ufs_dir_entry *old_de; |
| 282 | int err = -ENOENT; | 282 | int err = -ENOENT; |
| 283 | 283 | ||
| 284 | old_de = ufs_find_entry(old_dir, old_dentry, &old_page); | 284 | old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_page); |
| 285 | if (!old_de) | 285 | if (!old_de) |
| 286 | goto out; | 286 | goto out; |
| 287 | 287 | ||
| @@ -301,7 +301,7 @@ static int ufs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 301 | goto out_dir; | 301 | goto out_dir; |
| 302 | 302 | ||
| 303 | err = -ENOENT; | 303 | err = -ENOENT; |
| 304 | new_de = ufs_find_entry(new_dir, new_dentry, &new_page); | 304 | new_de = ufs_find_entry(new_dir, &new_dentry->d_name, &new_page); |
| 305 | if (!new_de) | 305 | if (!new_de) |
| 306 | goto out_dir; | 306 | goto out_dir; |
| 307 | inode_inc_link_count(old_inode); | 307 | inode_inc_link_count(old_inode); |
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 5faed7954d0a..143c20bfb04b 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
| @@ -66,6 +66,7 @@ | |||
| 66 | */ | 66 | */ |
| 67 | 67 | ||
| 68 | 68 | ||
| 69 | #include <linux/exportfs.h> | ||
| 69 | #include <linux/module.h> | 70 | #include <linux/module.h> |
| 70 | #include <linux/bitops.h> | 71 | #include <linux/bitops.h> |
| 71 | 72 | ||
| @@ -96,6 +97,56 @@ | |||
| 96 | #include "swab.h" | 97 | #include "swab.h" |
| 97 | #include "util.h" | 98 | #include "util.h" |
| 98 | 99 | ||
| 100 | static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 generation) | ||
| 101 | { | ||
| 102 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; | ||
| 103 | struct inode *inode; | ||
| 104 | |||
| 105 | if (ino < UFS_ROOTINO || ino > uspi->s_ncg * uspi->s_ipg) | ||
| 106 | return ERR_PTR(-ESTALE); | ||
| 107 | |||
| 108 | inode = ufs_iget(sb, ino); | ||
| 109 | if (IS_ERR(inode)) | ||
| 110 | return ERR_CAST(inode); | ||
| 111 | if (generation && inode->i_generation != generation) { | ||
| 112 | iput(inode); | ||
| 113 | return ERR_PTR(-ESTALE); | ||
| 114 | } | ||
| 115 | return inode; | ||
| 116 | } | ||
| 117 | |||
| 118 | static struct dentry *ufs_fh_to_dentry(struct super_block *sb, struct fid *fid, | ||
| 119 | int fh_len, int fh_type) | ||
| 120 | { | ||
| 121 | return generic_fh_to_dentry(sb, fid, fh_len, fh_type, ufs_nfs_get_inode); | ||
| 122 | } | ||
| 123 | |||
| 124 | static struct dentry *ufs_fh_to_parent(struct super_block *sb, struct fid *fid, | ||
| 125 | int fh_len, int fh_type) | ||
| 126 | { | ||
| 127 | return generic_fh_to_parent(sb, fid, fh_len, fh_type, ufs_nfs_get_inode); | ||
| 128 | } | ||
| 129 | |||
| 130 | static struct dentry *ufs_get_parent(struct dentry *child) | ||
| 131 | { | ||
| 132 | struct qstr dot_dot = { | ||
| 133 | .name = "..", | ||
| 134 | .len = 2, | ||
| 135 | }; | ||
| 136 | ino_t ino; | ||
| 137 | |||
| 138 | ino = ufs_inode_by_name(child->d_inode, &dot_dot); | ||
| 139 | if (!ino) | ||
| 140 | return ERR_PTR(-ENOENT); | ||
| 141 | return d_obtain_alias(ufs_iget(child->d_inode->i_sb, ino)); | ||
| 142 | } | ||
| 143 | |||
| 144 | static const struct export_operations ufs_export_ops = { | ||
| 145 | .fh_to_dentry = ufs_fh_to_dentry, | ||
| 146 | .fh_to_parent = ufs_fh_to_parent, | ||
| 147 | .get_parent = ufs_get_parent, | ||
| 148 | }; | ||
| 149 | |||
| 99 | #ifdef CONFIG_UFS_DEBUG | 150 | #ifdef CONFIG_UFS_DEBUG |
| 100 | /* | 151 | /* |
| 101 | * Print contents of ufs_super_block, useful for debugging | 152 | * Print contents of ufs_super_block, useful for debugging |
| @@ -990,6 +1041,7 @@ magic_found: | |||
| 990 | * Read ufs_super_block into internal data structures | 1041 | * Read ufs_super_block into internal data structures |
| 991 | */ | 1042 | */ |
| 992 | sb->s_op = &ufs_super_ops; | 1043 | sb->s_op = &ufs_super_ops; |
| 1044 | sb->s_export_op = &ufs_export_ops; | ||
| 993 | sb->dq_op = NULL; /***/ | 1045 | sb->dq_op = NULL; /***/ |
| 994 | sb->s_magic = fs32_to_cpu(sb, usb3->fs_magic); | 1046 | sb->s_magic = fs32_to_cpu(sb, usb3->fs_magic); |
| 995 | 1047 | ||
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h index 644e77e13599..0b4c39bc0d9e 100644 --- a/fs/ufs/ufs.h +++ b/fs/ufs/ufs.h | |||
| @@ -86,9 +86,9 @@ extern void ufs_put_cylinder (struct super_block *, unsigned); | |||
| 86 | /* dir.c */ | 86 | /* dir.c */ |
| 87 | extern const struct inode_operations ufs_dir_inode_operations; | 87 | extern const struct inode_operations ufs_dir_inode_operations; |
| 88 | extern int ufs_add_link (struct dentry *, struct inode *); | 88 | extern int ufs_add_link (struct dentry *, struct inode *); |
| 89 | extern ino_t ufs_inode_by_name(struct inode *, struct dentry *); | 89 | extern ino_t ufs_inode_by_name(struct inode *, struct qstr *); |
| 90 | extern int ufs_make_empty(struct inode *, struct inode *); | 90 | extern int ufs_make_empty(struct inode *, struct inode *); |
| 91 | extern struct ufs_dir_entry *ufs_find_entry(struct inode *, struct dentry *, struct page **); | 91 | extern struct ufs_dir_entry *ufs_find_entry(struct inode *, struct qstr *, struct page **); |
| 92 | extern int ufs_delete_entry(struct inode *, struct ufs_dir_entry *, struct page *); | 92 | extern int ufs_delete_entry(struct inode *, struct ufs_dir_entry *, struct page *); |
| 93 | extern int ufs_empty_dir (struct inode *); | 93 | extern int ufs_empty_dir (struct inode *); |
| 94 | extern struct ufs_dir_entry *ufs_dotdot(struct inode *, struct page **); | 94 | extern struct ufs_dir_entry *ufs_dotdot(struct inode *, struct page **); |
diff --git a/fs/xattr.c b/fs/xattr.c index 6d4f6d3449fb..46f87e828b48 100644 --- a/fs/xattr.c +++ b/fs/xattr.c | |||
| @@ -615,12 +615,11 @@ ssize_t | |||
| 615 | generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size) | 615 | generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size) |
| 616 | { | 616 | { |
| 617 | struct xattr_handler *handler; | 617 | struct xattr_handler *handler; |
| 618 | struct inode *inode = dentry->d_inode; | ||
| 619 | 618 | ||
| 620 | handler = xattr_resolve_name(inode->i_sb->s_xattr, &name); | 619 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); |
| 621 | if (!handler) | 620 | if (!handler) |
| 622 | return -EOPNOTSUPP; | 621 | return -EOPNOTSUPP; |
| 623 | return handler->get(inode, name, buffer, size); | 622 | return handler->get(dentry, name, buffer, size, handler->flags); |
| 624 | } | 623 | } |
| 625 | 624 | ||
| 626 | /* | 625 | /* |
| @@ -630,18 +629,20 @@ generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t s | |||
| 630 | ssize_t | 629 | ssize_t |
| 631 | generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) | 630 | generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) |
| 632 | { | 631 | { |
| 633 | struct inode *inode = dentry->d_inode; | 632 | struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr; |
| 634 | struct xattr_handler *handler, **handlers = inode->i_sb->s_xattr; | ||
| 635 | unsigned int size = 0; | 633 | unsigned int size = 0; |
| 636 | 634 | ||
| 637 | if (!buffer) { | 635 | if (!buffer) { |
| 638 | for_each_xattr_handler(handlers, handler) | 636 | for_each_xattr_handler(handlers, handler) { |
| 639 | size += handler->list(inode, NULL, 0, NULL, 0); | 637 | size += handler->list(dentry, NULL, 0, NULL, 0, |
| 638 | handler->flags); | ||
| 639 | } | ||
| 640 | } else { | 640 | } else { |
| 641 | char *buf = buffer; | 641 | char *buf = buffer; |
| 642 | 642 | ||
| 643 | for_each_xattr_handler(handlers, handler) { | 643 | for_each_xattr_handler(handlers, handler) { |
| 644 | size = handler->list(inode, buf, buffer_size, NULL, 0); | 644 | size = handler->list(dentry, buf, buffer_size, |
| 645 | NULL, 0, handler->flags); | ||
| 645 | if (size > buffer_size) | 646 | if (size > buffer_size) |
| 646 | return -ERANGE; | 647 | return -ERANGE; |
| 647 | buf += size; | 648 | buf += size; |
| @@ -659,14 +660,13 @@ int | |||
| 659 | generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) | 660 | generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) |
| 660 | { | 661 | { |
| 661 | struct xattr_handler *handler; | 662 | struct xattr_handler *handler; |
| 662 | struct inode *inode = dentry->d_inode; | ||
| 663 | 663 | ||
| 664 | if (size == 0) | 664 | if (size == 0) |
| 665 | value = ""; /* empty EA, do not remove */ | 665 | value = ""; /* empty EA, do not remove */ |
| 666 | handler = xattr_resolve_name(inode->i_sb->s_xattr, &name); | 666 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); |
| 667 | if (!handler) | 667 | if (!handler) |
| 668 | return -EOPNOTSUPP; | 668 | return -EOPNOTSUPP; |
| 669 | return handler->set(inode, name, value, size, flags); | 669 | return handler->set(dentry, name, value, size, 0, handler->flags); |
| 670 | } | 670 | } |
| 671 | 671 | ||
| 672 | /* | 672 | /* |
| @@ -677,12 +677,12 @@ int | |||
| 677 | generic_removexattr(struct dentry *dentry, const char *name) | 677 | generic_removexattr(struct dentry *dentry, const char *name) |
| 678 | { | 678 | { |
| 679 | struct xattr_handler *handler; | 679 | struct xattr_handler *handler; |
| 680 | struct inode *inode = dentry->d_inode; | ||
| 681 | 680 | ||
| 682 | handler = xattr_resolve_name(inode->i_sb->s_xattr, &name); | 681 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); |
| 683 | if (!handler) | 682 | if (!handler) |
| 684 | return -EOPNOTSUPP; | 683 | return -EOPNOTSUPP; |
| 685 | return handler->set(inode, name, NULL, 0, XATTR_REPLACE); | 684 | return handler->set(dentry, name, NULL, 0, |
| 685 | XATTR_REPLACE, handler->flags); | ||
| 686 | } | 686 | } |
| 687 | 687 | ||
| 688 | EXPORT_SYMBOL(generic_getxattr); | 688 | EXPORT_SYMBOL(generic_getxattr); |
diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile index 7a59daed1782..56641fe52a23 100644 --- a/fs/xfs/Makefile +++ b/fs/xfs/Makefile | |||
| @@ -26,6 +26,8 @@ endif | |||
| 26 | 26 | ||
| 27 | obj-$(CONFIG_XFS_FS) += xfs.o | 27 | obj-$(CONFIG_XFS_FS) += xfs.o |
| 28 | 28 | ||
| 29 | xfs-y += linux-2.6/xfs_trace.o | ||
| 30 | |||
| 29 | xfs-$(CONFIG_XFS_QUOTA) += $(addprefix quota/, \ | 31 | xfs-$(CONFIG_XFS_QUOTA) += $(addprefix quota/, \ |
| 30 | xfs_dquot.o \ | 32 | xfs_dquot.o \ |
| 31 | xfs_dquot_item.o \ | 33 | xfs_dquot_item.o \ |
| @@ -90,8 +92,7 @@ xfs-y += xfs_alloc.o \ | |||
| 90 | xfs_rw.o \ | 92 | xfs_rw.o \ |
| 91 | xfs_dmops.o | 93 | xfs_dmops.o |
| 92 | 94 | ||
| 93 | xfs-$(CONFIG_XFS_TRACE) += xfs_btree_trace.o \ | 95 | xfs-$(CONFIG_XFS_TRACE) += xfs_btree_trace.o |
| 94 | xfs_dir2_trace.o | ||
| 95 | 96 | ||
| 96 | # Objects in linux/ | 97 | # Objects in linux/ |
| 97 | xfs-y += $(addprefix $(XFS_LINUX)/, \ | 98 | xfs-y += $(addprefix $(XFS_LINUX)/, \ |
| @@ -113,6 +114,3 @@ xfs-y += $(addprefix $(XFS_LINUX)/, \ | |||
| 113 | xfs-y += $(addprefix support/, \ | 114 | xfs-y += $(addprefix support/, \ |
| 114 | debug.o \ | 115 | debug.o \ |
| 115 | uuid.o) | 116 | uuid.o) |
| 116 | |||
| 117 | xfs-$(CONFIG_XFS_TRACE) += support/ktrace.o | ||
| 118 | |||
diff --git a/fs/xfs/linux-2.6/xfs_acl.c b/fs/xfs/linux-2.6/xfs_acl.c index b23a54506446..2512125dfa7c 100644 --- a/fs/xfs/linux-2.6/xfs_acl.c +++ b/fs/xfs/linux-2.6/xfs_acl.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include "xfs_bmap_btree.h" | 21 | #include "xfs_bmap_btree.h" |
| 22 | #include "xfs_inode.h" | 22 | #include "xfs_inode.h" |
| 23 | #include "xfs_vnodeops.h" | 23 | #include "xfs_vnodeops.h" |
| 24 | #include "xfs_trace.h" | ||
| 24 | #include <linux/xattr.h> | 25 | #include <linux/xattr.h> |
| 25 | #include <linux/posix_acl_xattr.h> | 26 | #include <linux/posix_acl_xattr.h> |
| 26 | 27 | ||
| @@ -353,37 +354,14 @@ xfs_acl_chmod(struct inode *inode) | |||
| 353 | return error; | 354 | return error; |
| 354 | } | 355 | } |
| 355 | 356 | ||
| 356 | /* | ||
| 357 | * System xattr handlers. | ||
| 358 | * | ||
| 359 | * Currently Posix ACLs are the only system namespace extended attribute | ||
| 360 | * handlers supported by XFS, so we just implement the handlers here. | ||
| 361 | * If we ever support other system extended attributes this will need | ||
| 362 | * some refactoring. | ||
| 363 | */ | ||
| 364 | |||
| 365 | static int | 357 | static int |
| 366 | xfs_decode_acl(const char *name) | 358 | xfs_xattr_acl_get(struct dentry *dentry, const char *name, |
| 367 | { | 359 | void *value, size_t size, int type) |
| 368 | if (strcmp(name, "posix_acl_access") == 0) | ||
| 369 | return ACL_TYPE_ACCESS; | ||
| 370 | else if (strcmp(name, "posix_acl_default") == 0) | ||
| 371 | return ACL_TYPE_DEFAULT; | ||
| 372 | return -EINVAL; | ||
| 373 | } | ||
| 374 | |||
| 375 | static int | ||
| 376 | xfs_xattr_system_get(struct inode *inode, const char *name, | ||
| 377 | void *value, size_t size) | ||
| 378 | { | 360 | { |
| 379 | struct posix_acl *acl; | 361 | struct posix_acl *acl; |
| 380 | int type, error; | 362 | int error; |
| 381 | |||
| 382 | type = xfs_decode_acl(name); | ||
| 383 | if (type < 0) | ||
| 384 | return type; | ||
| 385 | 363 | ||
| 386 | acl = xfs_get_acl(inode, type); | 364 | acl = xfs_get_acl(dentry->d_inode, type); |
| 387 | if (IS_ERR(acl)) | 365 | if (IS_ERR(acl)) |
| 388 | return PTR_ERR(acl); | 366 | return PTR_ERR(acl); |
| 389 | if (acl == NULL) | 367 | if (acl == NULL) |
| @@ -396,15 +374,13 @@ xfs_xattr_system_get(struct inode *inode, const char *name, | |||
| 396 | } | 374 | } |
| 397 | 375 | ||
| 398 | static int | 376 | static int |
| 399 | xfs_xattr_system_set(struct inode *inode, const char *name, | 377 | xfs_xattr_acl_set(struct dentry *dentry, const char *name, |
| 400 | const void *value, size_t size, int flags) | 378 | const void *value, size_t size, int flags, int type) |
| 401 | { | 379 | { |
| 380 | struct inode *inode = dentry->d_inode; | ||
| 402 | struct posix_acl *acl = NULL; | 381 | struct posix_acl *acl = NULL; |
| 403 | int error = 0, type; | 382 | int error = 0; |
| 404 | 383 | ||
| 405 | type = xfs_decode_acl(name); | ||
| 406 | if (type < 0) | ||
| 407 | return type; | ||
| 408 | if (flags & XATTR_CREATE) | 384 | if (flags & XATTR_CREATE) |
| 409 | return -EINVAL; | 385 | return -EINVAL; |
| 410 | if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) | 386 | if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) |
| @@ -461,8 +437,16 @@ xfs_xattr_system_set(struct inode *inode, const char *name, | |||
| 461 | return error; | 437 | return error; |
| 462 | } | 438 | } |
| 463 | 439 | ||
| 464 | struct xattr_handler xfs_xattr_system_handler = { | 440 | struct xattr_handler xfs_xattr_acl_access_handler = { |
| 465 | .prefix = XATTR_SYSTEM_PREFIX, | 441 | .prefix = POSIX_ACL_XATTR_ACCESS, |
| 466 | .get = xfs_xattr_system_get, | 442 | .flags = ACL_TYPE_ACCESS, |
| 467 | .set = xfs_xattr_system_set, | 443 | .get = xfs_xattr_acl_get, |
| 444 | .set = xfs_xattr_acl_set, | ||
| 445 | }; | ||
| 446 | |||
| 447 | struct xattr_handler xfs_xattr_acl_default_handler = { | ||
| 448 | .prefix = POSIX_ACL_XATTR_DEFAULT, | ||
| 449 | .flags = ACL_TYPE_DEFAULT, | ||
| 450 | .get = xfs_xattr_acl_get, | ||
| 451 | .set = xfs_xattr_acl_set, | ||
| 468 | }; | 452 | }; |
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c index 87813e405cef..66abe36c1213 100644 --- a/fs/xfs/linux-2.6/xfs_aops.c +++ b/fs/xfs/linux-2.6/xfs_aops.c | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | #include "xfs_rw.h" | 38 | #include "xfs_rw.h" |
| 39 | #include "xfs_iomap.h" | 39 | #include "xfs_iomap.h" |
| 40 | #include "xfs_vnodeops.h" | 40 | #include "xfs_vnodeops.h" |
| 41 | #include "xfs_trace.h" | ||
| 41 | #include <linux/mpage.h> | 42 | #include <linux/mpage.h> |
| 42 | #include <linux/pagevec.h> | 43 | #include <linux/pagevec.h> |
| 43 | #include <linux/writeback.h> | 44 | #include <linux/writeback.h> |
| @@ -76,7 +77,7 @@ xfs_ioend_wake( | |||
| 76 | wake_up(to_ioend_wq(ip)); | 77 | wake_up(to_ioend_wq(ip)); |
| 77 | } | 78 | } |
| 78 | 79 | ||
| 79 | STATIC void | 80 | void |
| 80 | xfs_count_page_state( | 81 | xfs_count_page_state( |
| 81 | struct page *page, | 82 | struct page *page, |
| 82 | int *delalloc, | 83 | int *delalloc, |
| @@ -98,48 +99,6 @@ xfs_count_page_state( | |||
| 98 | } while ((bh = bh->b_this_page) != head); | 99 | } while ((bh = bh->b_this_page) != head); |
| 99 | } | 100 | } |
| 100 | 101 | ||
| 101 | #if defined(XFS_RW_TRACE) | ||
| 102 | void | ||
| 103 | xfs_page_trace( | ||
| 104 | int tag, | ||
| 105 | struct inode *inode, | ||
| 106 | struct page *page, | ||
| 107 | unsigned long pgoff) | ||
| 108 | { | ||
| 109 | xfs_inode_t *ip; | ||
| 110 | loff_t isize = i_size_read(inode); | ||
| 111 | loff_t offset = page_offset(page); | ||
| 112 | int delalloc = -1, unmapped = -1, unwritten = -1; | ||
| 113 | |||
| 114 | if (page_has_buffers(page)) | ||
| 115 | xfs_count_page_state(page, &delalloc, &unmapped, &unwritten); | ||
| 116 | |||
| 117 | ip = XFS_I(inode); | ||
| 118 | if (!ip->i_rwtrace) | ||
| 119 | return; | ||
| 120 | |||
| 121 | ktrace_enter(ip->i_rwtrace, | ||
| 122 | (void *)((unsigned long)tag), | ||
| 123 | (void *)ip, | ||
| 124 | (void *)inode, | ||
| 125 | (void *)page, | ||
| 126 | (void *)pgoff, | ||
| 127 | (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)), | ||
| 128 | (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)), | ||
| 129 | (void *)((unsigned long)((isize >> 32) & 0xffffffff)), | ||
| 130 | (void *)((unsigned long)(isize & 0xffffffff)), | ||
| 131 | (void *)((unsigned long)((offset >> 32) & 0xffffffff)), | ||
| 132 | (void *)((unsigned long)(offset & 0xffffffff)), | ||
| 133 | (void *)((unsigned long)delalloc), | ||
| 134 | (void *)((unsigned long)unmapped), | ||
| 135 | (void *)((unsigned long)unwritten), | ||
| 136 | (void *)((unsigned long)current_pid()), | ||
| 137 | (void *)NULL); | ||
| 138 | } | ||
| 139 | #else | ||
| 140 | #define xfs_page_trace(tag, inode, page, pgoff) | ||
| 141 | #endif | ||
| 142 | |||
| 143 | STATIC struct block_device * | 102 | STATIC struct block_device * |
| 144 | xfs_find_bdev_for_inode( | 103 | xfs_find_bdev_for_inode( |
| 145 | struct xfs_inode *ip) | 104 | struct xfs_inode *ip) |
| @@ -1202,7 +1161,7 @@ xfs_vm_writepage( | |||
| 1202 | int delalloc, unmapped, unwritten; | 1161 | int delalloc, unmapped, unwritten; |
| 1203 | struct inode *inode = page->mapping->host; | 1162 | struct inode *inode = page->mapping->host; |
| 1204 | 1163 | ||
| 1205 | xfs_page_trace(XFS_WRITEPAGE_ENTER, inode, page, 0); | 1164 | trace_xfs_writepage(inode, page, 0); |
| 1206 | 1165 | ||
| 1207 | /* | 1166 | /* |
| 1208 | * We need a transaction if: | 1167 | * We need a transaction if: |
| @@ -1307,7 +1266,7 @@ xfs_vm_releasepage( | |||
| 1307 | .nr_to_write = 1, | 1266 | .nr_to_write = 1, |
| 1308 | }; | 1267 | }; |
| 1309 | 1268 | ||
| 1310 | xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, 0); | 1269 | trace_xfs_releasepage(inode, page, 0); |
| 1311 | 1270 | ||
| 1312 | if (!page_has_buffers(page)) | 1271 | if (!page_has_buffers(page)) |
| 1313 | return 0; | 1272 | return 0; |
| @@ -1515,19 +1474,13 @@ xfs_vm_direct_IO( | |||
| 1515 | 1474 | ||
| 1516 | bdev = xfs_find_bdev_for_inode(XFS_I(inode)); | 1475 | bdev = xfs_find_bdev_for_inode(XFS_I(inode)); |
| 1517 | 1476 | ||
| 1518 | if (rw == WRITE) { | 1477 | iocb->private = xfs_alloc_ioend(inode, rw == WRITE ? |
| 1519 | iocb->private = xfs_alloc_ioend(inode, IOMAP_UNWRITTEN); | 1478 | IOMAP_UNWRITTEN : IOMAP_READ); |
| 1520 | ret = blockdev_direct_IO_own_locking(rw, iocb, inode, | 1479 | |
| 1521 | bdev, iov, offset, nr_segs, | 1480 | ret = blockdev_direct_IO_no_locking(rw, iocb, inode, bdev, iov, |
| 1522 | xfs_get_blocks_direct, | 1481 | offset, nr_segs, |
| 1523 | xfs_end_io_direct); | 1482 | xfs_get_blocks_direct, |
| 1524 | } else { | 1483 | xfs_end_io_direct); |
| 1525 | iocb->private = xfs_alloc_ioend(inode, IOMAP_READ); | ||
| 1526 | ret = blockdev_direct_IO_no_locking(rw, iocb, inode, | ||
| 1527 | bdev, iov, offset, nr_segs, | ||
| 1528 | xfs_get_blocks_direct, | ||
| 1529 | xfs_end_io_direct); | ||
| 1530 | } | ||
| 1531 | 1484 | ||
| 1532 | if (unlikely(ret != -EIOCBQUEUED && iocb->private)) | 1485 | if (unlikely(ret != -EIOCBQUEUED && iocb->private)) |
| 1533 | xfs_destroy_ioend(iocb->private); | 1486 | xfs_destroy_ioend(iocb->private); |
| @@ -1587,8 +1540,7 @@ xfs_vm_invalidatepage( | |||
| 1587 | struct page *page, | 1540 | struct page *page, |
| 1588 | unsigned long offset) | 1541 | unsigned long offset) |
| 1589 | { | 1542 | { |
| 1590 | xfs_page_trace(XFS_INVALIDPAGE_ENTER, | 1543 | trace_xfs_invalidatepage(page->mapping->host, page, offset); |
| 1591 | page->mapping->host, page, offset); | ||
| 1592 | block_invalidatepage(page, offset); | 1544 | block_invalidatepage(page, offset); |
| 1593 | } | 1545 | } |
| 1594 | 1546 | ||
diff --git a/fs/xfs/linux-2.6/xfs_aops.h b/fs/xfs/linux-2.6/xfs_aops.h index 221b3e66ceef..4cfc6ea87df8 100644 --- a/fs/xfs/linux-2.6/xfs_aops.h +++ b/fs/xfs/linux-2.6/xfs_aops.h | |||
| @@ -45,4 +45,6 @@ extern int xfs_get_blocks(struct inode *, sector_t, struct buffer_head *, int); | |||
| 45 | extern void xfs_ioend_init(void); | 45 | extern void xfs_ioend_init(void); |
| 46 | extern void xfs_ioend_wait(struct xfs_inode *); | 46 | extern void xfs_ioend_wait(struct xfs_inode *); |
| 47 | 47 | ||
| 48 | extern void xfs_count_page_state(struct page *, int *, int *, int *); | ||
| 49 | |||
| 48 | #endif /* __XFS_AOPS_H__ */ | 50 | #endif /* __XFS_AOPS_H__ */ |
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c index 4ddc973aea7a..77b8be81c769 100644 --- a/fs/xfs/linux-2.6/xfs_buf.c +++ b/fs/xfs/linux-2.6/xfs_buf.c | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | #include "xfs_ag.h" | 39 | #include "xfs_ag.h" |
| 40 | #include "xfs_dmapi.h" | 40 | #include "xfs_dmapi.h" |
| 41 | #include "xfs_mount.h" | 41 | #include "xfs_mount.h" |
| 42 | #include "xfs_trace.h" | ||
| 42 | 43 | ||
| 43 | static kmem_zone_t *xfs_buf_zone; | 44 | static kmem_zone_t *xfs_buf_zone; |
| 44 | STATIC int xfsbufd(void *); | 45 | STATIC int xfsbufd(void *); |
| @@ -53,34 +54,6 @@ static struct workqueue_struct *xfslogd_workqueue; | |||
| 53 | struct workqueue_struct *xfsdatad_workqueue; | 54 | struct workqueue_struct *xfsdatad_workqueue; |
| 54 | struct workqueue_struct *xfsconvertd_workqueue; | 55 | struct workqueue_struct *xfsconvertd_workqueue; |
| 55 | 56 | ||
| 56 | #ifdef XFS_BUF_TRACE | ||
| 57 | void | ||
| 58 | xfs_buf_trace( | ||
| 59 | xfs_buf_t *bp, | ||
| 60 | char *id, | ||
| 61 | void *data, | ||
| 62 | void *ra) | ||
| 63 | { | ||
| 64 | ktrace_enter(xfs_buf_trace_buf, | ||
| 65 | bp, id, | ||
| 66 | (void *)(unsigned long)bp->b_flags, | ||
| 67 | (void *)(unsigned long)bp->b_hold.counter, | ||
| 68 | (void *)(unsigned long)bp->b_sema.count, | ||
| 69 | (void *)current, | ||
| 70 | data, ra, | ||
| 71 | (void *)(unsigned long)((bp->b_file_offset>>32) & 0xffffffff), | ||
| 72 | (void *)(unsigned long)(bp->b_file_offset & 0xffffffff), | ||
| 73 | (void *)(unsigned long)bp->b_buffer_length, | ||
| 74 | NULL, NULL, NULL, NULL, NULL); | ||
| 75 | } | ||
| 76 | ktrace_t *xfs_buf_trace_buf; | ||
| 77 | #define XFS_BUF_TRACE_SIZE 4096 | ||
| 78 | #define XB_TRACE(bp, id, data) \ | ||
| 79 | xfs_buf_trace(bp, id, (void *)data, (void *)__builtin_return_address(0)) | ||
| 80 | #else | ||
| 81 | #define XB_TRACE(bp, id, data) do { } while (0) | ||
| 82 | #endif | ||
| 83 | |||
| 84 | #ifdef XFS_BUF_LOCK_TRACKING | 57 | #ifdef XFS_BUF_LOCK_TRACKING |
| 85 | # define XB_SET_OWNER(bp) ((bp)->b_last_holder = current->pid) | 58 | # define XB_SET_OWNER(bp) ((bp)->b_last_holder = current->pid) |
| 86 | # define XB_CLEAR_OWNER(bp) ((bp)->b_last_holder = -1) | 59 | # define XB_CLEAR_OWNER(bp) ((bp)->b_last_holder = -1) |
| @@ -279,7 +252,8 @@ _xfs_buf_initialize( | |||
| 279 | init_waitqueue_head(&bp->b_waiters); | 252 | init_waitqueue_head(&bp->b_waiters); |
| 280 | 253 | ||
| 281 | XFS_STATS_INC(xb_create); | 254 | XFS_STATS_INC(xb_create); |
| 282 | XB_TRACE(bp, "initialize", target); | 255 | |
| 256 | trace_xfs_buf_init(bp, _RET_IP_); | ||
| 283 | } | 257 | } |
| 284 | 258 | ||
| 285 | /* | 259 | /* |
| @@ -318,6 +292,7 @@ _xfs_buf_free_pages( | |||
| 318 | { | 292 | { |
| 319 | if (bp->b_pages != bp->b_page_array) { | 293 | if (bp->b_pages != bp->b_page_array) { |
| 320 | kmem_free(bp->b_pages); | 294 | kmem_free(bp->b_pages); |
| 295 | bp->b_pages = NULL; | ||
| 321 | } | 296 | } |
| 322 | } | 297 | } |
| 323 | 298 | ||
| @@ -332,7 +307,7 @@ void | |||
| 332 | xfs_buf_free( | 307 | xfs_buf_free( |
| 333 | xfs_buf_t *bp) | 308 | xfs_buf_t *bp) |
| 334 | { | 309 | { |
| 335 | XB_TRACE(bp, "free", 0); | 310 | trace_xfs_buf_free(bp, _RET_IP_); |
| 336 | 311 | ||
| 337 | ASSERT(list_empty(&bp->b_hash_list)); | 312 | ASSERT(list_empty(&bp->b_hash_list)); |
| 338 | 313 | ||
| @@ -349,9 +324,8 @@ xfs_buf_free( | |||
| 349 | ASSERT(!PagePrivate(page)); | 324 | ASSERT(!PagePrivate(page)); |
| 350 | page_cache_release(page); | 325 | page_cache_release(page); |
| 351 | } | 326 | } |
| 352 | _xfs_buf_free_pages(bp); | ||
| 353 | } | 327 | } |
| 354 | 328 | _xfs_buf_free_pages(bp); | |
| 355 | xfs_buf_deallocate(bp); | 329 | xfs_buf_deallocate(bp); |
| 356 | } | 330 | } |
| 357 | 331 | ||
| @@ -445,7 +419,6 @@ _xfs_buf_lookup_pages( | |||
| 445 | if (page_count == bp->b_page_count) | 419 | if (page_count == bp->b_page_count) |
| 446 | bp->b_flags |= XBF_DONE; | 420 | bp->b_flags |= XBF_DONE; |
| 447 | 421 | ||
| 448 | XB_TRACE(bp, "lookup_pages", (long)page_count); | ||
| 449 | return error; | 422 | return error; |
| 450 | } | 423 | } |
| 451 | 424 | ||
| @@ -548,7 +521,6 @@ found: | |||
| 548 | if (down_trylock(&bp->b_sema)) { | 521 | if (down_trylock(&bp->b_sema)) { |
| 549 | if (!(flags & XBF_TRYLOCK)) { | 522 | if (!(flags & XBF_TRYLOCK)) { |
| 550 | /* wait for buffer ownership */ | 523 | /* wait for buffer ownership */ |
| 551 | XB_TRACE(bp, "get_lock", 0); | ||
| 552 | xfs_buf_lock(bp); | 524 | xfs_buf_lock(bp); |
| 553 | XFS_STATS_INC(xb_get_locked_waited); | 525 | XFS_STATS_INC(xb_get_locked_waited); |
| 554 | } else { | 526 | } else { |
| @@ -571,7 +543,8 @@ found: | |||
| 571 | ASSERT((bp->b_flags & _XBF_DELWRI_Q) == 0); | 543 | ASSERT((bp->b_flags & _XBF_DELWRI_Q) == 0); |
| 572 | bp->b_flags &= XBF_MAPPED; | 544 | bp->b_flags &= XBF_MAPPED; |
| 573 | } | 545 | } |
| 574 | XB_TRACE(bp, "got_lock", 0); | 546 | |
| 547 | trace_xfs_buf_find(bp, flags, _RET_IP_); | ||
| 575 | XFS_STATS_INC(xb_get_locked); | 548 | XFS_STATS_INC(xb_get_locked); |
| 576 | return bp; | 549 | return bp; |
| 577 | } | 550 | } |
| @@ -627,7 +600,7 @@ xfs_buf_get( | |||
| 627 | bp->b_bn = ioff; | 600 | bp->b_bn = ioff; |
| 628 | bp->b_count_desired = bp->b_buffer_length; | 601 | bp->b_count_desired = bp->b_buffer_length; |
| 629 | 602 | ||
| 630 | XB_TRACE(bp, "get", (unsigned long)flags); | 603 | trace_xfs_buf_get(bp, flags, _RET_IP_); |
| 631 | return bp; | 604 | return bp; |
| 632 | 605 | ||
| 633 | no_buffer: | 606 | no_buffer: |
| @@ -644,8 +617,6 @@ _xfs_buf_read( | |||
| 644 | { | 617 | { |
| 645 | int status; | 618 | int status; |
| 646 | 619 | ||
| 647 | XB_TRACE(bp, "_xfs_buf_read", (unsigned long)flags); | ||
| 648 | |||
| 649 | ASSERT(!(flags & (XBF_DELWRI|XBF_WRITE))); | 620 | ASSERT(!(flags & (XBF_DELWRI|XBF_WRITE))); |
| 650 | ASSERT(bp->b_bn != XFS_BUF_DADDR_NULL); | 621 | ASSERT(bp->b_bn != XFS_BUF_DADDR_NULL); |
| 651 | 622 | ||
| @@ -673,19 +644,18 @@ xfs_buf_read( | |||
| 673 | 644 | ||
| 674 | bp = xfs_buf_get(target, ioff, isize, flags); | 645 | bp = xfs_buf_get(target, ioff, isize, flags); |
| 675 | if (bp) { | 646 | if (bp) { |
| 647 | trace_xfs_buf_read(bp, flags, _RET_IP_); | ||
| 648 | |||
| 676 | if (!XFS_BUF_ISDONE(bp)) { | 649 | if (!XFS_BUF_ISDONE(bp)) { |
| 677 | XB_TRACE(bp, "read", (unsigned long)flags); | ||
| 678 | XFS_STATS_INC(xb_get_read); | 650 | XFS_STATS_INC(xb_get_read); |
| 679 | _xfs_buf_read(bp, flags); | 651 | _xfs_buf_read(bp, flags); |
| 680 | } else if (flags & XBF_ASYNC) { | 652 | } else if (flags & XBF_ASYNC) { |
| 681 | XB_TRACE(bp, "read_async", (unsigned long)flags); | ||
| 682 | /* | 653 | /* |
| 683 | * Read ahead call which is already satisfied, | 654 | * Read ahead call which is already satisfied, |
| 684 | * drop the buffer | 655 | * drop the buffer |
| 685 | */ | 656 | */ |
| 686 | goto no_buffer; | 657 | goto no_buffer; |
| 687 | } else { | 658 | } else { |
| 688 | XB_TRACE(bp, "read_done", (unsigned long)flags); | ||
| 689 | /* We do not want read in the flags */ | 659 | /* We do not want read in the flags */ |
| 690 | bp->b_flags &= ~XBF_READ; | 660 | bp->b_flags &= ~XBF_READ; |
| 691 | } | 661 | } |
| @@ -823,7 +793,7 @@ xfs_buf_get_noaddr( | |||
| 823 | 793 | ||
| 824 | xfs_buf_unlock(bp); | 794 | xfs_buf_unlock(bp); |
| 825 | 795 | ||
| 826 | XB_TRACE(bp, "no_daddr", len); | 796 | trace_xfs_buf_get_noaddr(bp, _RET_IP_); |
| 827 | return bp; | 797 | return bp; |
| 828 | 798 | ||
| 829 | fail_free_mem: | 799 | fail_free_mem: |
| @@ -845,8 +815,8 @@ void | |||
| 845 | xfs_buf_hold( | 815 | xfs_buf_hold( |
| 846 | xfs_buf_t *bp) | 816 | xfs_buf_t *bp) |
| 847 | { | 817 | { |
| 818 | trace_xfs_buf_hold(bp, _RET_IP_); | ||
| 848 | atomic_inc(&bp->b_hold); | 819 | atomic_inc(&bp->b_hold); |
| 849 | XB_TRACE(bp, "hold", 0); | ||
| 850 | } | 820 | } |
| 851 | 821 | ||
| 852 | /* | 822 | /* |
| @@ -859,7 +829,7 @@ xfs_buf_rele( | |||
| 859 | { | 829 | { |
| 860 | xfs_bufhash_t *hash = bp->b_hash; | 830 | xfs_bufhash_t *hash = bp->b_hash; |
| 861 | 831 | ||
| 862 | XB_TRACE(bp, "rele", bp->b_relse); | 832 | trace_xfs_buf_rele(bp, _RET_IP_); |
| 863 | 833 | ||
| 864 | if (unlikely(!hash)) { | 834 | if (unlikely(!hash)) { |
| 865 | ASSERT(!bp->b_relse); | 835 | ASSERT(!bp->b_relse); |
| @@ -909,21 +879,19 @@ xfs_buf_cond_lock( | |||
| 909 | int locked; | 879 | int locked; |
| 910 | 880 | ||
| 911 | locked = down_trylock(&bp->b_sema) == 0; | 881 | locked = down_trylock(&bp->b_sema) == 0; |
| 912 | if (locked) { | 882 | if (locked) |
| 913 | XB_SET_OWNER(bp); | 883 | XB_SET_OWNER(bp); |
| 914 | } | 884 | |
| 915 | XB_TRACE(bp, "cond_lock", (long)locked); | 885 | trace_xfs_buf_cond_lock(bp, _RET_IP_); |
| 916 | return locked ? 0 : -EBUSY; | 886 | return locked ? 0 : -EBUSY; |
| 917 | } | 887 | } |
| 918 | 888 | ||
| 919 | #if defined(DEBUG) || defined(XFS_BLI_TRACE) | ||
| 920 | int | 889 | int |
| 921 | xfs_buf_lock_value( | 890 | xfs_buf_lock_value( |
| 922 | xfs_buf_t *bp) | 891 | xfs_buf_t *bp) |
| 923 | { | 892 | { |
| 924 | return bp->b_sema.count; | 893 | return bp->b_sema.count; |
| 925 | } | 894 | } |
| 926 | #endif | ||
| 927 | 895 | ||
| 928 | /* | 896 | /* |
| 929 | * Locks a buffer object. | 897 | * Locks a buffer object. |
| @@ -935,12 +903,14 @@ void | |||
| 935 | xfs_buf_lock( | 903 | xfs_buf_lock( |
| 936 | xfs_buf_t *bp) | 904 | xfs_buf_t *bp) |
| 937 | { | 905 | { |
| 938 | XB_TRACE(bp, "lock", 0); | 906 | trace_xfs_buf_lock(bp, _RET_IP_); |
| 907 | |||
| 939 | if (atomic_read(&bp->b_io_remaining)) | 908 | if (atomic_read(&bp->b_io_remaining)) |
| 940 | blk_run_address_space(bp->b_target->bt_mapping); | 909 | blk_run_address_space(bp->b_target->bt_mapping); |
| 941 | down(&bp->b_sema); | 910 | down(&bp->b_sema); |
| 942 | XB_SET_OWNER(bp); | 911 | XB_SET_OWNER(bp); |
| 943 | XB_TRACE(bp, "locked", 0); | 912 | |
| 913 | trace_xfs_buf_lock_done(bp, _RET_IP_); | ||
| 944 | } | 914 | } |
| 945 | 915 | ||
| 946 | /* | 916 | /* |
| @@ -962,7 +932,8 @@ xfs_buf_unlock( | |||
| 962 | 932 | ||
| 963 | XB_CLEAR_OWNER(bp); | 933 | XB_CLEAR_OWNER(bp); |
| 964 | up(&bp->b_sema); | 934 | up(&bp->b_sema); |
| 965 | XB_TRACE(bp, "unlock", 0); | 935 | |
| 936 | trace_xfs_buf_unlock(bp, _RET_IP_); | ||
| 966 | } | 937 | } |
| 967 | 938 | ||
| 968 | 939 | ||
| @@ -974,17 +945,18 @@ void | |||
| 974 | xfs_buf_pin( | 945 | xfs_buf_pin( |
| 975 | xfs_buf_t *bp) | 946 | xfs_buf_t *bp) |
| 976 | { | 947 | { |
| 948 | trace_xfs_buf_pin(bp, _RET_IP_); | ||
| 977 | atomic_inc(&bp->b_pin_count); | 949 | atomic_inc(&bp->b_pin_count); |
| 978 | XB_TRACE(bp, "pin", (long)bp->b_pin_count.counter); | ||
| 979 | } | 950 | } |
| 980 | 951 | ||
| 981 | void | 952 | void |
| 982 | xfs_buf_unpin( | 953 | xfs_buf_unpin( |
| 983 | xfs_buf_t *bp) | 954 | xfs_buf_t *bp) |
| 984 | { | 955 | { |
| 956 | trace_xfs_buf_unpin(bp, _RET_IP_); | ||
| 957 | |||
| 985 | if (atomic_dec_and_test(&bp->b_pin_count)) | 958 | if (atomic_dec_and_test(&bp->b_pin_count)) |
| 986 | wake_up_all(&bp->b_waiters); | 959 | wake_up_all(&bp->b_waiters); |
| 987 | XB_TRACE(bp, "unpin", (long)bp->b_pin_count.counter); | ||
| 988 | } | 960 | } |
| 989 | 961 | ||
| 990 | int | 962 | int |
| @@ -1035,7 +1007,7 @@ xfs_buf_iodone_work( | |||
| 1035 | */ | 1007 | */ |
| 1036 | if ((bp->b_error == EOPNOTSUPP) && | 1008 | if ((bp->b_error == EOPNOTSUPP) && |
| 1037 | (bp->b_flags & (XBF_ORDERED|XBF_ASYNC)) == (XBF_ORDERED|XBF_ASYNC)) { | 1009 | (bp->b_flags & (XBF_ORDERED|XBF_ASYNC)) == (XBF_ORDERED|XBF_ASYNC)) { |
| 1038 | XB_TRACE(bp, "ordered_retry", bp->b_iodone); | 1010 | trace_xfs_buf_ordered_retry(bp, _RET_IP_); |
| 1039 | bp->b_flags &= ~XBF_ORDERED; | 1011 | bp->b_flags &= ~XBF_ORDERED; |
| 1040 | bp->b_flags |= _XFS_BARRIER_FAILED; | 1012 | bp->b_flags |= _XFS_BARRIER_FAILED; |
| 1041 | xfs_buf_iorequest(bp); | 1013 | xfs_buf_iorequest(bp); |
| @@ -1050,12 +1022,12 @@ xfs_buf_ioend( | |||
| 1050 | xfs_buf_t *bp, | 1022 | xfs_buf_t *bp, |
| 1051 | int schedule) | 1023 | int schedule) |
| 1052 | { | 1024 | { |
| 1025 | trace_xfs_buf_iodone(bp, _RET_IP_); | ||
| 1026 | |||
| 1053 | bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_READ_AHEAD); | 1027 | bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_READ_AHEAD); |
| 1054 | if (bp->b_error == 0) | 1028 | if (bp->b_error == 0) |
| 1055 | bp->b_flags |= XBF_DONE; | 1029 | bp->b_flags |= XBF_DONE; |
| 1056 | 1030 | ||
| 1057 | XB_TRACE(bp, "iodone", bp->b_iodone); | ||
| 1058 | |||
| 1059 | if ((bp->b_iodone) || (bp->b_flags & XBF_ASYNC)) { | 1031 | if ((bp->b_iodone) || (bp->b_flags & XBF_ASYNC)) { |
| 1060 | if (schedule) { | 1032 | if (schedule) { |
| 1061 | INIT_WORK(&bp->b_iodone_work, xfs_buf_iodone_work); | 1033 | INIT_WORK(&bp->b_iodone_work, xfs_buf_iodone_work); |
| @@ -1075,7 +1047,7 @@ xfs_buf_ioerror( | |||
| 1075 | { | 1047 | { |
| 1076 | ASSERT(error >= 0 && error <= 0xffff); | 1048 | ASSERT(error >= 0 && error <= 0xffff); |
| 1077 | bp->b_error = (unsigned short)error; | 1049 | bp->b_error = (unsigned short)error; |
| 1078 | XB_TRACE(bp, "ioerror", (unsigned long)error); | 1050 | trace_xfs_buf_ioerror(bp, error, _RET_IP_); |
| 1079 | } | 1051 | } |
| 1080 | 1052 | ||
| 1081 | int | 1053 | int |
| @@ -1083,7 +1055,7 @@ xfs_bawrite( | |||
| 1083 | void *mp, | 1055 | void *mp, |
| 1084 | struct xfs_buf *bp) | 1056 | struct xfs_buf *bp) |
| 1085 | { | 1057 | { |
| 1086 | XB_TRACE(bp, "bawrite", 0); | 1058 | trace_xfs_buf_bawrite(bp, _RET_IP_); |
| 1087 | 1059 | ||
| 1088 | ASSERT(bp->b_bn != XFS_BUF_DADDR_NULL); | 1060 | ASSERT(bp->b_bn != XFS_BUF_DADDR_NULL); |
| 1089 | 1061 | ||
| @@ -1102,7 +1074,7 @@ xfs_bdwrite( | |||
| 1102 | void *mp, | 1074 | void *mp, |
| 1103 | struct xfs_buf *bp) | 1075 | struct xfs_buf *bp) |
| 1104 | { | 1076 | { |
| 1105 | XB_TRACE(bp, "bdwrite", 0); | 1077 | trace_xfs_buf_bdwrite(bp, _RET_IP_); |
| 1106 | 1078 | ||
| 1107 | bp->b_strat = xfs_bdstrat_cb; | 1079 | bp->b_strat = xfs_bdstrat_cb; |
| 1108 | bp->b_mount = mp; | 1080 | bp->b_mount = mp; |
| @@ -1177,10 +1149,14 @@ _xfs_buf_ioapply( | |||
| 1177 | if (bp->b_flags & XBF_ORDERED) { | 1149 | if (bp->b_flags & XBF_ORDERED) { |
| 1178 | ASSERT(!(bp->b_flags & XBF_READ)); | 1150 | ASSERT(!(bp->b_flags & XBF_READ)); |
| 1179 | rw = WRITE_BARRIER; | 1151 | rw = WRITE_BARRIER; |
| 1180 | } else if (bp->b_flags & _XBF_RUN_QUEUES) { | 1152 | } else if (bp->b_flags & XBF_LOG_BUFFER) { |
| 1181 | ASSERT(!(bp->b_flags & XBF_READ_AHEAD)); | 1153 | ASSERT(!(bp->b_flags & XBF_READ_AHEAD)); |
| 1182 | bp->b_flags &= ~_XBF_RUN_QUEUES; | 1154 | bp->b_flags &= ~_XBF_RUN_QUEUES; |
| 1183 | rw = (bp->b_flags & XBF_WRITE) ? WRITE_SYNC : READ_SYNC; | 1155 | rw = (bp->b_flags & XBF_WRITE) ? WRITE_SYNC : READ_SYNC; |
| 1156 | } else if (bp->b_flags & _XBF_RUN_QUEUES) { | ||
| 1157 | ASSERT(!(bp->b_flags & XBF_READ_AHEAD)); | ||
| 1158 | bp->b_flags &= ~_XBF_RUN_QUEUES; | ||
| 1159 | rw = (bp->b_flags & XBF_WRITE) ? WRITE_META : READ_META; | ||
| 1184 | } else { | 1160 | } else { |
| 1185 | rw = (bp->b_flags & XBF_WRITE) ? WRITE : | 1161 | rw = (bp->b_flags & XBF_WRITE) ? WRITE : |
| 1186 | (bp->b_flags & XBF_READ_AHEAD) ? READA : READ; | 1162 | (bp->b_flags & XBF_READ_AHEAD) ? READA : READ; |
| @@ -1253,7 +1229,7 @@ int | |||
| 1253 | xfs_buf_iorequest( | 1229 | xfs_buf_iorequest( |
| 1254 | xfs_buf_t *bp) | 1230 | xfs_buf_t *bp) |
| 1255 | { | 1231 | { |
| 1256 | XB_TRACE(bp, "iorequest", 0); | 1232 | trace_xfs_buf_iorequest(bp, _RET_IP_); |
| 1257 | 1233 | ||
| 1258 | if (bp->b_flags & XBF_DELWRI) { | 1234 | if (bp->b_flags & XBF_DELWRI) { |
| 1259 | xfs_buf_delwri_queue(bp, 1); | 1235 | xfs_buf_delwri_queue(bp, 1); |
| @@ -1287,11 +1263,13 @@ int | |||
| 1287 | xfs_buf_iowait( | 1263 | xfs_buf_iowait( |
| 1288 | xfs_buf_t *bp) | 1264 | xfs_buf_t *bp) |
| 1289 | { | 1265 | { |
| 1290 | XB_TRACE(bp, "iowait", 0); | 1266 | trace_xfs_buf_iowait(bp, _RET_IP_); |
| 1267 | |||
| 1291 | if (atomic_read(&bp->b_io_remaining)) | 1268 | if (atomic_read(&bp->b_io_remaining)) |
| 1292 | blk_run_address_space(bp->b_target->bt_mapping); | 1269 | blk_run_address_space(bp->b_target->bt_mapping); |
| 1293 | wait_for_completion(&bp->b_iowait); | 1270 | wait_for_completion(&bp->b_iowait); |
| 1294 | XB_TRACE(bp, "iowaited", (long)bp->b_error); | 1271 | |
| 1272 | trace_xfs_buf_iowait_done(bp, _RET_IP_); | ||
| 1295 | return bp->b_error; | 1273 | return bp->b_error; |
| 1296 | } | 1274 | } |
| 1297 | 1275 | ||
| @@ -1604,7 +1582,8 @@ xfs_buf_delwri_queue( | |||
| 1604 | struct list_head *dwq = &bp->b_target->bt_delwrite_queue; | 1582 | struct list_head *dwq = &bp->b_target->bt_delwrite_queue; |
| 1605 | spinlock_t *dwlk = &bp->b_target->bt_delwrite_lock; | 1583 | spinlock_t *dwlk = &bp->b_target->bt_delwrite_lock; |
| 1606 | 1584 | ||
| 1607 | XB_TRACE(bp, "delwri_q", (long)unlock); | 1585 | trace_xfs_buf_delwri_queue(bp, _RET_IP_); |
| 1586 | |||
| 1608 | ASSERT((bp->b_flags&(XBF_DELWRI|XBF_ASYNC)) == (XBF_DELWRI|XBF_ASYNC)); | 1587 | ASSERT((bp->b_flags&(XBF_DELWRI|XBF_ASYNC)) == (XBF_DELWRI|XBF_ASYNC)); |
| 1609 | 1588 | ||
| 1610 | spin_lock(dwlk); | 1589 | spin_lock(dwlk); |
| @@ -1644,7 +1623,7 @@ xfs_buf_delwri_dequeue( | |||
| 1644 | if (dequeued) | 1623 | if (dequeued) |
| 1645 | xfs_buf_rele(bp); | 1624 | xfs_buf_rele(bp); |
| 1646 | 1625 | ||
| 1647 | XB_TRACE(bp, "delwri_dq", (long)dequeued); | 1626 | trace_xfs_buf_delwri_dequeue(bp, _RET_IP_); |
| 1648 | } | 1627 | } |
| 1649 | 1628 | ||
| 1650 | STATIC void | 1629 | STATIC void |
| @@ -1692,7 +1671,7 @@ xfs_buf_delwri_split( | |||
| 1692 | INIT_LIST_HEAD(list); | 1671 | INIT_LIST_HEAD(list); |
| 1693 | spin_lock(dwlk); | 1672 | spin_lock(dwlk); |
| 1694 | list_for_each_entry_safe(bp, n, dwq, b_list) { | 1673 | list_for_each_entry_safe(bp, n, dwq, b_list) { |
| 1695 | XB_TRACE(bp, "walkq1", (long)xfs_buf_ispin(bp)); | 1674 | trace_xfs_buf_delwri_split(bp, _RET_IP_); |
| 1696 | ASSERT(bp->b_flags & XBF_DELWRI); | 1675 | ASSERT(bp->b_flags & XBF_DELWRI); |
| 1697 | 1676 | ||
| 1698 | if (!xfs_buf_ispin(bp) && !xfs_buf_cond_lock(bp)) { | 1677 | if (!xfs_buf_ispin(bp) && !xfs_buf_cond_lock(bp)) { |
| @@ -1816,14 +1795,10 @@ xfs_flush_buftarg( | |||
| 1816 | int __init | 1795 | int __init |
| 1817 | xfs_buf_init(void) | 1796 | xfs_buf_init(void) |
| 1818 | { | 1797 | { |
| 1819 | #ifdef XFS_BUF_TRACE | ||
| 1820 | xfs_buf_trace_buf = ktrace_alloc(XFS_BUF_TRACE_SIZE, KM_NOFS); | ||
| 1821 | #endif | ||
| 1822 | |||
| 1823 | xfs_buf_zone = kmem_zone_init_flags(sizeof(xfs_buf_t), "xfs_buf", | 1798 | xfs_buf_zone = kmem_zone_init_flags(sizeof(xfs_buf_t), "xfs_buf", |
| 1824 | KM_ZONE_HWALIGN, NULL); | 1799 | KM_ZONE_HWALIGN, NULL); |
| 1825 | if (!xfs_buf_zone) | 1800 | if (!xfs_buf_zone) |
| 1826 | goto out_free_trace_buf; | 1801 | goto out; |
| 1827 | 1802 | ||
| 1828 | xfslogd_workqueue = create_workqueue("xfslogd"); | 1803 | xfslogd_workqueue = create_workqueue("xfslogd"); |
| 1829 | if (!xfslogd_workqueue) | 1804 | if (!xfslogd_workqueue) |
| @@ -1846,10 +1821,7 @@ xfs_buf_init(void) | |||
| 1846 | destroy_workqueue(xfslogd_workqueue); | 1821 | destroy_workqueue(xfslogd_workqueue); |
| 1847 | out_free_buf_zone: | 1822 | out_free_buf_zone: |
| 1848 | kmem_zone_destroy(xfs_buf_zone); | 1823 | kmem_zone_destroy(xfs_buf_zone); |
| 1849 | out_free_trace_buf: | 1824 | out: |
| 1850 | #ifdef XFS_BUF_TRACE | ||
| 1851 | ktrace_free(xfs_buf_trace_buf); | ||
| 1852 | #endif | ||
| 1853 | return -ENOMEM; | 1825 | return -ENOMEM; |
| 1854 | } | 1826 | } |
| 1855 | 1827 | ||
| @@ -1861,9 +1833,6 @@ xfs_buf_terminate(void) | |||
| 1861 | destroy_workqueue(xfsdatad_workqueue); | 1833 | destroy_workqueue(xfsdatad_workqueue); |
| 1862 | destroy_workqueue(xfslogd_workqueue); | 1834 | destroy_workqueue(xfslogd_workqueue); |
| 1863 | kmem_zone_destroy(xfs_buf_zone); | 1835 | kmem_zone_destroy(xfs_buf_zone); |
| 1864 | #ifdef XFS_BUF_TRACE | ||
| 1865 | ktrace_free(xfs_buf_trace_buf); | ||
| 1866 | #endif | ||
| 1867 | } | 1836 | } |
| 1868 | 1837 | ||
| 1869 | #ifdef CONFIG_KDB_MODULES | 1838 | #ifdef CONFIG_KDB_MODULES |
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h index 5f07dd91c5fa..a34c7b54822d 100644 --- a/fs/xfs/linux-2.6/xfs_buf.h +++ b/fs/xfs/linux-2.6/xfs_buf.h | |||
| @@ -55,6 +55,7 @@ typedef enum { | |||
| 55 | XBF_FS_MANAGED = (1 << 8), /* filesystem controls freeing memory */ | 55 | XBF_FS_MANAGED = (1 << 8), /* filesystem controls freeing memory */ |
| 56 | XBF_ORDERED = (1 << 11), /* use ordered writes */ | 56 | XBF_ORDERED = (1 << 11), /* use ordered writes */ |
| 57 | XBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead */ | 57 | XBF_READ_AHEAD = (1 << 12), /* asynchronous read-ahead */ |
| 58 | XBF_LOG_BUFFER = (1 << 13), /* this is a buffer used for the log */ | ||
| 58 | 59 | ||
| 59 | /* flags used only as arguments to access routines */ | 60 | /* flags used only as arguments to access routines */ |
| 60 | XBF_LOCK = (1 << 14), /* lock requested */ | 61 | XBF_LOCK = (1 << 14), /* lock requested */ |
| @@ -95,6 +96,28 @@ typedef enum { | |||
| 95 | _XFS_BARRIER_FAILED = (1 << 23), | 96 | _XFS_BARRIER_FAILED = (1 << 23), |
| 96 | } xfs_buf_flags_t; | 97 | } xfs_buf_flags_t; |
| 97 | 98 | ||
| 99 | #define XFS_BUF_FLAGS \ | ||
| 100 | { XBF_READ, "READ" }, \ | ||
| 101 | { XBF_WRITE, "WRITE" }, \ | ||
| 102 | { XBF_MAPPED, "MAPPED" }, \ | ||
| 103 | { XBF_ASYNC, "ASYNC" }, \ | ||
| 104 | { XBF_DONE, "DONE" }, \ | ||
| 105 | { XBF_DELWRI, "DELWRI" }, \ | ||
| 106 | { XBF_STALE, "STALE" }, \ | ||
| 107 | { XBF_FS_MANAGED, "FS_MANAGED" }, \ | ||
| 108 | { XBF_ORDERED, "ORDERED" }, \ | ||
| 109 | { XBF_READ_AHEAD, "READ_AHEAD" }, \ | ||
| 110 | { XBF_LOCK, "LOCK" }, /* should never be set */\ | ||
| 111 | { XBF_TRYLOCK, "TRYLOCK" }, /* ditto */\ | ||
| 112 | { XBF_DONT_BLOCK, "DONT_BLOCK" }, /* ditto */\ | ||
| 113 | { _XBF_PAGE_CACHE, "PAGE_CACHE" }, \ | ||
| 114 | { _XBF_PAGES, "PAGES" }, \ | ||
| 115 | { _XBF_RUN_QUEUES, "RUN_QUEUES" }, \ | ||
| 116 | { _XBF_DELWRI_Q, "DELWRI_Q" }, \ | ||
| 117 | { _XBF_PAGE_LOCKED, "PAGE_LOCKED" }, \ | ||
| 118 | { _XFS_BARRIER_FAILED, "BARRIER_FAILED" } | ||
| 119 | |||
| 120 | |||
| 98 | typedef enum { | 121 | typedef enum { |
| 99 | XBT_FORCE_SLEEP = 0, | 122 | XBT_FORCE_SLEEP = 0, |
| 100 | XBT_FORCE_FLUSH = 1, | 123 | XBT_FORCE_FLUSH = 1, |
| @@ -243,13 +266,6 @@ extern void xfs_buf_delwri_dequeue(xfs_buf_t *); | |||
| 243 | extern int xfs_buf_init(void); | 266 | extern int xfs_buf_init(void); |
| 244 | extern void xfs_buf_terminate(void); | 267 | extern void xfs_buf_terminate(void); |
| 245 | 268 | ||
| 246 | #ifdef XFS_BUF_TRACE | ||
| 247 | extern ktrace_t *xfs_buf_trace_buf; | ||
| 248 | extern void xfs_buf_trace(xfs_buf_t *, char *, void *, void *); | ||
| 249 | #else | ||
| 250 | #define xfs_buf_trace(bp,id,ptr,ra) do { } while (0) | ||
| 251 | #endif | ||
| 252 | |||
| 253 | #define xfs_buf_target_name(target) \ | 269 | #define xfs_buf_target_name(target) \ |
| 254 | ({ char __b[BDEVNAME_SIZE]; bdevname((target)->bt_bdev, __b); __b; }) | 270 | ({ char __b[BDEVNAME_SIZE]; bdevname((target)->bt_bdev, __b); __b; }) |
| 255 | 271 | ||
| @@ -365,10 +381,6 @@ static inline void xfs_buf_relse(xfs_buf_t *bp) | |||
| 365 | 381 | ||
| 366 | #define xfs_bpin(bp) xfs_buf_pin(bp) | 382 | #define xfs_bpin(bp) xfs_buf_pin(bp) |
| 367 | #define xfs_bunpin(bp) xfs_buf_unpin(bp) | 383 | #define xfs_bunpin(bp) xfs_buf_unpin(bp) |
| 368 | |||
| 369 | #define xfs_buftrace(id, bp) \ | ||
| 370 | xfs_buf_trace(bp, id, NULL, (void *)__builtin_return_address(0)) | ||
| 371 | |||
| 372 | #define xfs_biodone(bp) xfs_buf_ioend(bp, 0) | 384 | #define xfs_biodone(bp) xfs_buf_ioend(bp, 0) |
| 373 | 385 | ||
| 374 | #define xfs_biomove(bp, off, len, data, rw) \ | 386 | #define xfs_biomove(bp, off, len, data, rw) \ |
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.c b/fs/xfs/linux-2.6/xfs_fs_subr.c index 08be36d7326c..7501b85fd860 100644 --- a/fs/xfs/linux-2.6/xfs_fs_subr.c +++ b/fs/xfs/linux-2.6/xfs_fs_subr.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include "xfs_vnodeops.h" | 19 | #include "xfs_vnodeops.h" |
| 20 | #include "xfs_bmap_btree.h" | 20 | #include "xfs_bmap_btree.h" |
| 21 | #include "xfs_inode.h" | 21 | #include "xfs_inode.h" |
| 22 | #include "xfs_trace.h" | ||
| 22 | 23 | ||
| 23 | int fs_noerr(void) { return 0; } | 24 | int fs_noerr(void) { return 0; } |
| 24 | int fs_nosys(void) { return ENOSYS; } | 25 | int fs_nosys(void) { return ENOSYS; } |
| @@ -51,6 +52,8 @@ xfs_flushinval_pages( | |||
| 51 | struct address_space *mapping = VFS_I(ip)->i_mapping; | 52 | struct address_space *mapping = VFS_I(ip)->i_mapping; |
| 52 | int ret = 0; | 53 | int ret = 0; |
| 53 | 54 | ||
| 55 | trace_xfs_pagecache_inval(ip, first, last); | ||
| 56 | |||
| 54 | if (mapping->nrpages) { | 57 | if (mapping->nrpages) { |
| 55 | xfs_iflags_clear(ip, XFS_ITRUNCATED); | 58 | xfs_iflags_clear(ip, XFS_ITRUNCATED); |
| 56 | ret = filemap_write_and_wait(mapping); | 59 | ret = filemap_write_and_wait(mapping); |
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c index 5bb523d7f37e..a034cf624437 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl.c +++ b/fs/xfs/linux-2.6/xfs_ioctl.c | |||
| @@ -51,6 +51,7 @@ | |||
| 51 | #include "xfs_quota.h" | 51 | #include "xfs_quota.h" |
| 52 | #include "xfs_inode_item.h" | 52 | #include "xfs_inode_item.h" |
| 53 | #include "xfs_export.h" | 53 | #include "xfs_export.h" |
| 54 | #include "xfs_trace.h" | ||
| 54 | 55 | ||
| 55 | #include <linux/capability.h> | 56 | #include <linux/capability.h> |
| 56 | #include <linux/dcache.h> | 57 | #include <linux/dcache.h> |
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.c b/fs/xfs/linux-2.6/xfs_ioctl32.c index eafcc7c18706..be1527b1670c 100644 --- a/fs/xfs/linux-2.6/xfs_ioctl32.c +++ b/fs/xfs/linux-2.6/xfs_ioctl32.c | |||
| @@ -46,6 +46,7 @@ | |||
| 46 | #include "xfs_attr.h" | 46 | #include "xfs_attr.h" |
| 47 | #include "xfs_ioctl.h" | 47 | #include "xfs_ioctl.h" |
| 48 | #include "xfs_ioctl32.h" | 48 | #include "xfs_ioctl32.h" |
| 49 | #include "xfs_trace.h" | ||
| 49 | 50 | ||
| 50 | #define _NATIVE_IOC(cmd, type) \ | 51 | #define _NATIVE_IOC(cmd, type) \ |
| 51 | _IOC(_IOC_DIR(cmd), _IOC_TYPE(cmd), _IOC_NR(cmd), sizeof(type)) | 52 | _IOC(_IOC_DIR(cmd), _IOC_TYPE(cmd), _IOC_NR(cmd), sizeof(type)) |
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c index 1f3b4b8f7dd4..225946012d0b 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c | |||
| @@ -47,6 +47,7 @@ | |||
| 47 | #include "xfs_buf_item.h" | 47 | #include "xfs_buf_item.h" |
| 48 | #include "xfs_utils.h" | 48 | #include "xfs_utils.h" |
| 49 | #include "xfs_vnodeops.h" | 49 | #include "xfs_vnodeops.h" |
| 50 | #include "xfs_trace.h" | ||
| 50 | 51 | ||
| 51 | #include <linux/capability.h> | 52 | #include <linux/capability.h> |
| 52 | #include <linux/xattr.h> | 53 | #include <linux/xattr.h> |
| @@ -793,7 +794,7 @@ xfs_setup_inode( | |||
| 793 | struct inode *inode = &ip->i_vnode; | 794 | struct inode *inode = &ip->i_vnode; |
| 794 | 795 | ||
| 795 | inode->i_ino = ip->i_ino; | 796 | inode->i_ino = ip->i_ino; |
| 796 | inode->i_state = I_NEW|I_LOCK; | 797 | inode->i_state = I_NEW; |
| 797 | inode_add_to_lists(ip->i_mount->m_super, inode); | 798 | inode_add_to_lists(ip->i_mount->m_super, inode); |
| 798 | 799 | ||
| 799 | inode->i_mode = ip->i_d.di_mode; | 800 | inode->i_mode = ip->i_d.di_mode; |
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h index 6127e24062d0..5af0c81ca1ae 100644 --- a/fs/xfs/linux-2.6/xfs_linux.h +++ b/fs/xfs/linux-2.6/xfs_linux.h | |||
| @@ -40,7 +40,6 @@ | |||
| 40 | #include <sv.h> | 40 | #include <sv.h> |
| 41 | #include <time.h> | 41 | #include <time.h> |
| 42 | 42 | ||
| 43 | #include <support/ktrace.h> | ||
| 44 | #include <support/debug.h> | 43 | #include <support/debug.h> |
| 45 | #include <support/uuid.h> | 44 | #include <support/uuid.h> |
| 46 | 45 | ||
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c index 1bf47f219c97..0d32457abef1 100644 --- a/fs/xfs/linux-2.6/xfs_lrw.c +++ b/fs/xfs/linux-2.6/xfs_lrw.c | |||
| @@ -48,73 +48,12 @@ | |||
| 48 | #include "xfs_utils.h" | 48 | #include "xfs_utils.h" |
| 49 | #include "xfs_iomap.h" | 49 | #include "xfs_iomap.h" |
| 50 | #include "xfs_vnodeops.h" | 50 | #include "xfs_vnodeops.h" |
| 51 | #include "xfs_trace.h" | ||
| 51 | 52 | ||
| 52 | #include <linux/capability.h> | 53 | #include <linux/capability.h> |
| 53 | #include <linux/writeback.h> | 54 | #include <linux/writeback.h> |
| 54 | 55 | ||
| 55 | 56 | ||
| 56 | #if defined(XFS_RW_TRACE) | ||
| 57 | void | ||
| 58 | xfs_rw_enter_trace( | ||
| 59 | int tag, | ||
| 60 | xfs_inode_t *ip, | ||
| 61 | void *data, | ||
| 62 | size_t segs, | ||
| 63 | loff_t offset, | ||
| 64 | int ioflags) | ||
| 65 | { | ||
| 66 | if (ip->i_rwtrace == NULL) | ||
| 67 | return; | ||
| 68 | ktrace_enter(ip->i_rwtrace, | ||
| 69 | (void *)(unsigned long)tag, | ||
| 70 | (void *)ip, | ||
| 71 | (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)), | ||
| 72 | (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)), | ||
| 73 | (void *)data, | ||
| 74 | (void *)((unsigned long)segs), | ||
| 75 | (void *)((unsigned long)((offset >> 32) & 0xffffffff)), | ||
| 76 | (void *)((unsigned long)(offset & 0xffffffff)), | ||
| 77 | (void *)((unsigned long)ioflags), | ||
| 78 | (void *)((unsigned long)((ip->i_new_size >> 32) & 0xffffffff)), | ||
| 79 | (void *)((unsigned long)(ip->i_new_size & 0xffffffff)), | ||
| 80 | (void *)((unsigned long)current_pid()), | ||
| 81 | (void *)NULL, | ||
| 82 | (void *)NULL, | ||
| 83 | (void *)NULL, | ||
| 84 | (void *)NULL); | ||
| 85 | } | ||
| 86 | |||
| 87 | void | ||
| 88 | xfs_inval_cached_trace( | ||
| 89 | xfs_inode_t *ip, | ||
| 90 | xfs_off_t offset, | ||
| 91 | xfs_off_t len, | ||
| 92 | xfs_off_t first, | ||
| 93 | xfs_off_t last) | ||
| 94 | { | ||
| 95 | |||
| 96 | if (ip->i_rwtrace == NULL) | ||
| 97 | return; | ||
| 98 | ktrace_enter(ip->i_rwtrace, | ||
| 99 | (void *)(__psint_t)XFS_INVAL_CACHED, | ||
| 100 | (void *)ip, | ||
| 101 | (void *)((unsigned long)((offset >> 32) & 0xffffffff)), | ||
| 102 | (void *)((unsigned long)(offset & 0xffffffff)), | ||
| 103 | (void *)((unsigned long)((len >> 32) & 0xffffffff)), | ||
| 104 | (void *)((unsigned long)(len & 0xffffffff)), | ||
| 105 | (void *)((unsigned long)((first >> 32) & 0xffffffff)), | ||
| 106 | (void *)((unsigned long)(first & 0xffffffff)), | ||
| 107 | (void *)((unsigned long)((last >> 32) & 0xffffffff)), | ||
| 108 | (void *)((unsigned long)(last & 0xffffffff)), | ||
| 109 | (void *)((unsigned long)current_pid()), | ||
| 110 | (void *)NULL, | ||
| 111 | (void *)NULL, | ||
| 112 | (void *)NULL, | ||
| 113 | (void *)NULL, | ||
| 114 | (void *)NULL); | ||
| 115 | } | ||
| 116 | #endif | ||
| 117 | |||
| 118 | /* | 57 | /* |
| 119 | * xfs_iozero | 58 | * xfs_iozero |
| 120 | * | 59 | * |
| @@ -250,8 +189,7 @@ xfs_read( | |||
| 250 | } | 189 | } |
| 251 | } | 190 | } |
| 252 | 191 | ||
| 253 | xfs_rw_enter_trace(XFS_READ_ENTER, ip, | 192 | trace_xfs_file_read(ip, size, *offset, ioflags); |
| 254 | (void *)iovp, segs, *offset, ioflags); | ||
| 255 | 193 | ||
| 256 | iocb->ki_pos = *offset; | 194 | iocb->ki_pos = *offset; |
| 257 | ret = generic_file_aio_read(iocb, iovp, segs, *offset); | 195 | ret = generic_file_aio_read(iocb, iovp, segs, *offset); |
| @@ -292,8 +230,9 @@ xfs_splice_read( | |||
| 292 | return -error; | 230 | return -error; |
| 293 | } | 231 | } |
| 294 | } | 232 | } |
| 295 | xfs_rw_enter_trace(XFS_SPLICE_READ_ENTER, ip, | 233 | |
| 296 | pipe, count, *ppos, ioflags); | 234 | trace_xfs_file_splice_read(ip, count, *ppos, ioflags); |
| 235 | |||
| 297 | ret = generic_file_splice_read(infilp, ppos, pipe, count, flags); | 236 | ret = generic_file_splice_read(infilp, ppos, pipe, count, flags); |
| 298 | if (ret > 0) | 237 | if (ret > 0) |
| 299 | XFS_STATS_ADD(xs_read_bytes, ret); | 238 | XFS_STATS_ADD(xs_read_bytes, ret); |
| @@ -342,8 +281,8 @@ xfs_splice_write( | |||
| 342 | ip->i_new_size = new_size; | 281 | ip->i_new_size = new_size; |
| 343 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 282 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
| 344 | 283 | ||
| 345 | xfs_rw_enter_trace(XFS_SPLICE_WRITE_ENTER, ip, | 284 | trace_xfs_file_splice_write(ip, count, *ppos, ioflags); |
| 346 | pipe, count, *ppos, ioflags); | 285 | |
| 347 | ret = generic_file_splice_write(pipe, outfilp, ppos, count, flags); | 286 | ret = generic_file_splice_write(pipe, outfilp, ppos, count, flags); |
| 348 | if (ret > 0) | 287 | if (ret > 0) |
| 349 | XFS_STATS_ADD(xs_write_bytes, ret); | 288 | XFS_STATS_ADD(xs_write_bytes, ret); |
| @@ -710,8 +649,6 @@ start: | |||
| 710 | if ((ioflags & IO_ISDIRECT)) { | 649 | if ((ioflags & IO_ISDIRECT)) { |
| 711 | if (mapping->nrpages) { | 650 | if (mapping->nrpages) { |
| 712 | WARN_ON(need_i_mutex == 0); | 651 | WARN_ON(need_i_mutex == 0); |
| 713 | xfs_inval_cached_trace(xip, pos, -1, | ||
| 714 | (pos & PAGE_CACHE_MASK), -1); | ||
| 715 | error = xfs_flushinval_pages(xip, | 652 | error = xfs_flushinval_pages(xip, |
| 716 | (pos & PAGE_CACHE_MASK), | 653 | (pos & PAGE_CACHE_MASK), |
| 717 | -1, FI_REMAPF_LOCKED); | 654 | -1, FI_REMAPF_LOCKED); |
| @@ -728,8 +665,7 @@ start: | |||
| 728 | need_i_mutex = 0; | 665 | need_i_mutex = 0; |
| 729 | } | 666 | } |
| 730 | 667 | ||
| 731 | xfs_rw_enter_trace(XFS_DIOWR_ENTER, xip, (void *)iovp, segs, | 668 | trace_xfs_file_direct_write(xip, count, *offset, ioflags); |
| 732 | *offset, ioflags); | ||
| 733 | ret = generic_file_direct_write(iocb, iovp, | 669 | ret = generic_file_direct_write(iocb, iovp, |
| 734 | &segs, pos, offset, count, ocount); | 670 | &segs, pos, offset, count, ocount); |
| 735 | 671 | ||
| @@ -752,8 +688,7 @@ start: | |||
| 752 | ssize_t ret2 = 0; | 688 | ssize_t ret2 = 0; |
| 753 | 689 | ||
| 754 | write_retry: | 690 | write_retry: |
| 755 | xfs_rw_enter_trace(XFS_WRITE_ENTER, xip, (void *)iovp, segs, | 691 | trace_xfs_file_buffered_write(xip, count, *offset, ioflags); |
| 756 | *offset, ioflags); | ||
| 757 | ret2 = generic_file_buffered_write(iocb, iovp, segs, | 692 | ret2 = generic_file_buffered_write(iocb, iovp, segs, |
| 758 | pos, offset, count, ret); | 693 | pos, offset, count, ret); |
| 759 | /* | 694 | /* |
| @@ -858,7 +793,7 @@ int | |||
| 858 | xfs_bdstrat_cb(struct xfs_buf *bp) | 793 | xfs_bdstrat_cb(struct xfs_buf *bp) |
| 859 | { | 794 | { |
| 860 | if (XFS_FORCED_SHUTDOWN(bp->b_mount)) { | 795 | if (XFS_FORCED_SHUTDOWN(bp->b_mount)) { |
| 861 | xfs_buftrace("XFS__BDSTRAT IOERROR", bp); | 796 | trace_xfs_bdstrat_shut(bp, _RET_IP_); |
| 862 | /* | 797 | /* |
| 863 | * Metadata write that didn't get logged but | 798 | * Metadata write that didn't get logged but |
| 864 | * written delayed anyway. These aren't associated | 799 | * written delayed anyway. These aren't associated |
| @@ -891,7 +826,7 @@ xfsbdstrat( | |||
| 891 | return; | 826 | return; |
| 892 | } | 827 | } |
| 893 | 828 | ||
| 894 | xfs_buftrace("XFSBDSTRAT IOERROR", bp); | 829 | trace_xfs_bdstrat_shut(bp, _RET_IP_); |
| 895 | xfs_bioerror_relse(bp); | 830 | xfs_bioerror_relse(bp); |
| 896 | } | 831 | } |
| 897 | 832 | ||
diff --git a/fs/xfs/linux-2.6/xfs_lrw.h b/fs/xfs/linux-2.6/xfs_lrw.h index e6be37dbd0e9..d1f7789c7ffb 100644 --- a/fs/xfs/linux-2.6/xfs_lrw.h +++ b/fs/xfs/linux-2.6/xfs_lrw.h | |||
| @@ -20,52 +20,7 @@ | |||
| 20 | 20 | ||
| 21 | struct xfs_mount; | 21 | struct xfs_mount; |
| 22 | struct xfs_inode; | 22 | struct xfs_inode; |
| 23 | struct xfs_bmbt_irec; | ||
| 24 | struct xfs_buf; | 23 | struct xfs_buf; |
| 25 | struct xfs_iomap; | ||
| 26 | |||
| 27 | #if defined(XFS_RW_TRACE) | ||
| 28 | /* | ||
| 29 | * Defines for the trace mechanisms in xfs_lrw.c. | ||
| 30 | */ | ||
| 31 | #define XFS_RW_KTRACE_SIZE 128 | ||
| 32 | |||
| 33 | #define XFS_READ_ENTER 1 | ||
| 34 | #define XFS_WRITE_ENTER 2 | ||
| 35 | #define XFS_IOMAP_READ_ENTER 3 | ||
| 36 | #define XFS_IOMAP_WRITE_ENTER 4 | ||
| 37 | #define XFS_IOMAP_READ_MAP 5 | ||
| 38 | #define XFS_IOMAP_WRITE_MAP 6 | ||
| 39 | #define XFS_IOMAP_WRITE_NOSPACE 7 | ||
| 40 | #define XFS_ITRUNC_START 8 | ||
| 41 | #define XFS_ITRUNC_FINISH1 9 | ||
| 42 | #define XFS_ITRUNC_FINISH2 10 | ||
| 43 | #define XFS_CTRUNC1 11 | ||
| 44 | #define XFS_CTRUNC2 12 | ||
| 45 | #define XFS_CTRUNC3 13 | ||
| 46 | #define XFS_CTRUNC4 14 | ||
| 47 | #define XFS_CTRUNC5 15 | ||
| 48 | #define XFS_CTRUNC6 16 | ||
| 49 | #define XFS_BUNMAP 17 | ||
| 50 | #define XFS_INVAL_CACHED 18 | ||
| 51 | #define XFS_DIORD_ENTER 19 | ||
| 52 | #define XFS_DIOWR_ENTER 20 | ||
| 53 | #define XFS_WRITEPAGE_ENTER 22 | ||
| 54 | #define XFS_RELEASEPAGE_ENTER 23 | ||
| 55 | #define XFS_INVALIDPAGE_ENTER 24 | ||
| 56 | #define XFS_IOMAP_ALLOC_ENTER 25 | ||
| 57 | #define XFS_IOMAP_ALLOC_MAP 26 | ||
| 58 | #define XFS_IOMAP_UNWRITTEN 27 | ||
| 59 | #define XFS_SPLICE_READ_ENTER 28 | ||
| 60 | #define XFS_SPLICE_WRITE_ENTER 29 | ||
| 61 | extern void xfs_rw_enter_trace(int, struct xfs_inode *, | ||
| 62 | void *, size_t, loff_t, int); | ||
| 63 | extern void xfs_inval_cached_trace(struct xfs_inode *, | ||
| 64 | xfs_off_t, xfs_off_t, xfs_off_t, xfs_off_t); | ||
| 65 | #else | ||
| 66 | #define xfs_rw_enter_trace(tag, ip, data, size, offset, ioflags) | ||
| 67 | #define xfs_inval_cached_trace(ip, offset, len, first, last) | ||
| 68 | #endif | ||
| 69 | 24 | ||
| 70 | /* errors from xfsbdstrat() must be extracted from the buffer */ | 25 | /* errors from xfsbdstrat() must be extracted from the buffer */ |
| 71 | extern void xfsbdstrat(struct xfs_mount *, struct xfs_buf *); | 26 | extern void xfsbdstrat(struct xfs_mount *, struct xfs_buf *); |
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index 1bfb0e980193..09783cc444ac 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/linux-2.6/xfs_super.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | * along with this program; if not, write the Free Software Foundation, | 15 | * along with this program; if not, write the Free Software Foundation, |
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ | 17 | */ |
| 18 | |||
| 18 | #include "xfs.h" | 19 | #include "xfs.h" |
| 19 | #include "xfs_bit.h" | 20 | #include "xfs_bit.h" |
| 20 | #include "xfs_log.h" | 21 | #include "xfs_log.h" |
| @@ -52,11 +53,11 @@ | |||
| 52 | #include "xfs_trans_priv.h" | 53 | #include "xfs_trans_priv.h" |
| 53 | #include "xfs_filestream.h" | 54 | #include "xfs_filestream.h" |
| 54 | #include "xfs_da_btree.h" | 55 | #include "xfs_da_btree.h" |
| 55 | #include "xfs_dir2_trace.h" | ||
| 56 | #include "xfs_extfree_item.h" | 56 | #include "xfs_extfree_item.h" |
| 57 | #include "xfs_mru_cache.h" | 57 | #include "xfs_mru_cache.h" |
| 58 | #include "xfs_inode_item.h" | 58 | #include "xfs_inode_item.h" |
| 59 | #include "xfs_sync.h" | 59 | #include "xfs_sync.h" |
| 60 | #include "xfs_trace.h" | ||
| 60 | 61 | ||
| 61 | #include <linux/namei.h> | 62 | #include <linux/namei.h> |
| 62 | #include <linux/init.h> | 63 | #include <linux/init.h> |
| @@ -1525,8 +1526,6 @@ xfs_fs_fill_super( | |||
| 1525 | goto fail_vnrele; | 1526 | goto fail_vnrele; |
| 1526 | 1527 | ||
| 1527 | kfree(mtpt); | 1528 | kfree(mtpt); |
| 1528 | |||
| 1529 | xfs_itrace_exit(XFS_I(sb->s_root->d_inode)); | ||
| 1530 | return 0; | 1529 | return 0; |
| 1531 | 1530 | ||
| 1532 | out_filestream_unmount: | 1531 | out_filestream_unmount: |
| @@ -1602,94 +1601,6 @@ static struct file_system_type xfs_fs_type = { | |||
| 1602 | }; | 1601 | }; |
| 1603 | 1602 | ||
| 1604 | STATIC int __init | 1603 | STATIC int __init |
| 1605 | xfs_alloc_trace_bufs(void) | ||
| 1606 | { | ||
| 1607 | #ifdef XFS_ALLOC_TRACE | ||
| 1608 | xfs_alloc_trace_buf = ktrace_alloc(XFS_ALLOC_TRACE_SIZE, KM_MAYFAIL); | ||
| 1609 | if (!xfs_alloc_trace_buf) | ||
| 1610 | goto out; | ||
| 1611 | #endif | ||
| 1612 | #ifdef XFS_BMAP_TRACE | ||
| 1613 | xfs_bmap_trace_buf = ktrace_alloc(XFS_BMAP_TRACE_SIZE, KM_MAYFAIL); | ||
| 1614 | if (!xfs_bmap_trace_buf) | ||
| 1615 | goto out_free_alloc_trace; | ||
| 1616 | #endif | ||
| 1617 | #ifdef XFS_BTREE_TRACE | ||
| 1618 | xfs_allocbt_trace_buf = ktrace_alloc(XFS_ALLOCBT_TRACE_SIZE, | ||
| 1619 | KM_MAYFAIL); | ||
| 1620 | if (!xfs_allocbt_trace_buf) | ||
| 1621 | goto out_free_bmap_trace; | ||
| 1622 | |||
| 1623 | xfs_inobt_trace_buf = ktrace_alloc(XFS_INOBT_TRACE_SIZE, KM_MAYFAIL); | ||
| 1624 | if (!xfs_inobt_trace_buf) | ||
| 1625 | goto out_free_allocbt_trace; | ||
| 1626 | |||
| 1627 | xfs_bmbt_trace_buf = ktrace_alloc(XFS_BMBT_TRACE_SIZE, KM_MAYFAIL); | ||
| 1628 | if (!xfs_bmbt_trace_buf) | ||
| 1629 | goto out_free_inobt_trace; | ||
| 1630 | #endif | ||
| 1631 | #ifdef XFS_ATTR_TRACE | ||
| 1632 | xfs_attr_trace_buf = ktrace_alloc(XFS_ATTR_TRACE_SIZE, KM_MAYFAIL); | ||
| 1633 | if (!xfs_attr_trace_buf) | ||
| 1634 | goto out_free_bmbt_trace; | ||
| 1635 | #endif | ||
| 1636 | #ifdef XFS_DIR2_TRACE | ||
| 1637 | xfs_dir2_trace_buf = ktrace_alloc(XFS_DIR2_GTRACE_SIZE, KM_MAYFAIL); | ||
| 1638 | if (!xfs_dir2_trace_buf) | ||
| 1639 | goto out_free_attr_trace; | ||
| 1640 | #endif | ||
| 1641 | |||
| 1642 | return 0; | ||
| 1643 | |||
| 1644 | #ifdef XFS_DIR2_TRACE | ||
| 1645 | out_free_attr_trace: | ||
| 1646 | #endif | ||
| 1647 | #ifdef XFS_ATTR_TRACE | ||
| 1648 | ktrace_free(xfs_attr_trace_buf); | ||
| 1649 | out_free_bmbt_trace: | ||
| 1650 | #endif | ||
| 1651 | #ifdef XFS_BTREE_TRACE | ||
| 1652 | ktrace_free(xfs_bmbt_trace_buf); | ||
| 1653 | out_free_inobt_trace: | ||
| 1654 | ktrace_free(xfs_inobt_trace_buf); | ||
| 1655 | out_free_allocbt_trace: | ||
| 1656 | ktrace_free(xfs_allocbt_trace_buf); | ||
| 1657 | out_free_bmap_trace: | ||
| 1658 | #endif | ||
| 1659 | #ifdef XFS_BMAP_TRACE | ||
| 1660 | ktrace_free(xfs_bmap_trace_buf); | ||
| 1661 | out_free_alloc_trace: | ||
| 1662 | #endif | ||
| 1663 | #ifdef XFS_ALLOC_TRACE | ||
| 1664 | ktrace_free(xfs_alloc_trace_buf); | ||
| 1665 | out: | ||
| 1666 | #endif | ||
| 1667 | return -ENOMEM; | ||
| 1668 | } | ||
| 1669 | |||
| 1670 | STATIC void | ||
| 1671 | xfs_free_trace_bufs(void) | ||
| 1672 | { | ||
| 1673 | #ifdef XFS_DIR2_TRACE | ||
| 1674 | ktrace_free(xfs_dir2_trace_buf); | ||
| 1675 | #endif | ||
| 1676 | #ifdef XFS_ATTR_TRACE | ||
| 1677 | ktrace_free(xfs_attr_trace_buf); | ||
| 1678 | #endif | ||
| 1679 | #ifdef XFS_BTREE_TRACE | ||
| 1680 | ktrace_free(xfs_bmbt_trace_buf); | ||
| 1681 | ktrace_free(xfs_inobt_trace_buf); | ||
| 1682 | ktrace_free(xfs_allocbt_trace_buf); | ||
| 1683 | #endif | ||
| 1684 | #ifdef XFS_BMAP_TRACE | ||
| 1685 | ktrace_free(xfs_bmap_trace_buf); | ||
| 1686 | #endif | ||
| 1687 | #ifdef XFS_ALLOC_TRACE | ||
| 1688 | ktrace_free(xfs_alloc_trace_buf); | ||
| 1689 | #endif | ||
| 1690 | } | ||
| 1691 | |||
| 1692 | STATIC int __init | ||
| 1693 | xfs_init_zones(void) | 1604 | xfs_init_zones(void) |
| 1694 | { | 1605 | { |
| 1695 | 1606 | ||
| @@ -1830,7 +1741,6 @@ init_xfs_fs(void) | |||
| 1830 | printk(KERN_INFO XFS_VERSION_STRING " with " | 1741 | printk(KERN_INFO XFS_VERSION_STRING " with " |
| 1831 | XFS_BUILD_OPTIONS " enabled\n"); | 1742 | XFS_BUILD_OPTIONS " enabled\n"); |
| 1832 | 1743 | ||
| 1833 | ktrace_init(64); | ||
| 1834 | xfs_ioend_init(); | 1744 | xfs_ioend_init(); |
| 1835 | xfs_dir_startup(); | 1745 | xfs_dir_startup(); |
| 1836 | 1746 | ||
| @@ -1838,13 +1748,9 @@ init_xfs_fs(void) | |||
| 1838 | if (error) | 1748 | if (error) |
| 1839 | goto out; | 1749 | goto out; |
| 1840 | 1750 | ||
| 1841 | error = xfs_alloc_trace_bufs(); | ||
| 1842 | if (error) | ||
| 1843 | goto out_destroy_zones; | ||
| 1844 | |||
| 1845 | error = xfs_mru_cache_init(); | 1751 | error = xfs_mru_cache_init(); |
| 1846 | if (error) | 1752 | if (error) |
| 1847 | goto out_free_trace_buffers; | 1753 | goto out_destroy_zones; |
| 1848 | 1754 | ||
| 1849 | error = xfs_filestream_init(); | 1755 | error = xfs_filestream_init(); |
| 1850 | if (error) | 1756 | if (error) |
| @@ -1879,8 +1785,6 @@ init_xfs_fs(void) | |||
| 1879 | xfs_filestream_uninit(); | 1785 | xfs_filestream_uninit(); |
| 1880 | out_mru_cache_uninit: | 1786 | out_mru_cache_uninit: |
| 1881 | xfs_mru_cache_uninit(); | 1787 | xfs_mru_cache_uninit(); |
| 1882 | out_free_trace_buffers: | ||
| 1883 | xfs_free_trace_bufs(); | ||
| 1884 | out_destroy_zones: | 1788 | out_destroy_zones: |
| 1885 | xfs_destroy_zones(); | 1789 | xfs_destroy_zones(); |
| 1886 | out: | 1790 | out: |
| @@ -1897,9 +1801,7 @@ exit_xfs_fs(void) | |||
| 1897 | xfs_buf_terminate(); | 1801 | xfs_buf_terminate(); |
| 1898 | xfs_filestream_uninit(); | 1802 | xfs_filestream_uninit(); |
| 1899 | xfs_mru_cache_uninit(); | 1803 | xfs_mru_cache_uninit(); |
| 1900 | xfs_free_trace_bufs(); | ||
| 1901 | xfs_destroy_zones(); | 1804 | xfs_destroy_zones(); |
| 1902 | ktrace_uninit(); | ||
| 1903 | } | 1805 | } |
| 1904 | 1806 | ||
| 1905 | module_init(init_xfs_fs); | 1807 | module_init(init_xfs_fs); |
diff --git a/fs/xfs/linux-2.6/xfs_super.h b/fs/xfs/linux-2.6/xfs_super.h index 18175ebd58ed..233d4b9881b1 100644 --- a/fs/xfs/linux-2.6/xfs_super.h +++ b/fs/xfs/linux-2.6/xfs_super.h | |||
| @@ -56,12 +56,6 @@ extern void xfs_qm_exit(void); | |||
| 56 | # define XFS_BIGFS_STRING | 56 | # define XFS_BIGFS_STRING |
| 57 | #endif | 57 | #endif |
| 58 | 58 | ||
| 59 | #ifdef CONFIG_XFS_TRACE | ||
| 60 | # define XFS_TRACE_STRING "tracing, " | ||
| 61 | #else | ||
| 62 | # define XFS_TRACE_STRING | ||
| 63 | #endif | ||
| 64 | |||
| 65 | #ifdef CONFIG_XFS_DMAPI | 59 | #ifdef CONFIG_XFS_DMAPI |
| 66 | # define XFS_DMAPI_STRING "dmapi support, " | 60 | # define XFS_DMAPI_STRING "dmapi support, " |
| 67 | #else | 61 | #else |
| @@ -78,7 +72,6 @@ extern void xfs_qm_exit(void); | |||
| 78 | XFS_SECURITY_STRING \ | 72 | XFS_SECURITY_STRING \ |
| 79 | XFS_REALTIME_STRING \ | 73 | XFS_REALTIME_STRING \ |
| 80 | XFS_BIGFS_STRING \ | 74 | XFS_BIGFS_STRING \ |
| 81 | XFS_TRACE_STRING \ | ||
| 82 | XFS_DMAPI_STRING \ | 75 | XFS_DMAPI_STRING \ |
| 83 | XFS_DBG_STRING /* DBG must be last */ | 76 | XFS_DBG_STRING /* DBG must be last */ |
| 84 | 77 | ||
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c index d895a3a960f5..6fed97a8cd3e 100644 --- a/fs/xfs/linux-2.6/xfs_sync.c +++ b/fs/xfs/linux-2.6/xfs_sync.c | |||
| @@ -44,6 +44,7 @@ | |||
| 44 | #include "xfs_inode_item.h" | 44 | #include "xfs_inode_item.h" |
| 45 | #include "xfs_rw.h" | 45 | #include "xfs_rw.h" |
| 46 | #include "xfs_quota.h" | 46 | #include "xfs_quota.h" |
| 47 | #include "xfs_trace.h" | ||
| 47 | 48 | ||
| 48 | #include <linux/kthread.h> | 49 | #include <linux/kthread.h> |
| 49 | #include <linux/freezer.h> | 50 | #include <linux/freezer.h> |
diff --git a/fs/xfs/linux-2.6/xfs_trace.c b/fs/xfs/linux-2.6/xfs_trace.c new file mode 100644 index 000000000000..856eb3c8d605 --- /dev/null +++ b/fs/xfs/linux-2.6/xfs_trace.c | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2009, Christoph Hellwig | ||
| 3 | * All Rights Reserved. | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU General Public License as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it would be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program; if not, write the Free Software Foundation, | ||
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | #include "xfs.h" | ||
| 19 | #include "xfs_fs.h" | ||
| 20 | #include "xfs_types.h" | ||
| 21 | #include "xfs_bit.h" | ||
| 22 | #include "xfs_log.h" | ||
| 23 | #include "xfs_inum.h" | ||
| 24 | #include "xfs_trans.h" | ||
| 25 | #include "xfs_sb.h" | ||
| 26 | #include "xfs_ag.h" | ||
| 27 | #include "xfs_dir2.h" | ||
| 28 | #include "xfs_da_btree.h" | ||
| 29 | #include "xfs_bmap_btree.h" | ||
| 30 | #include "xfs_alloc_btree.h" | ||
| 31 | #include "xfs_ialloc_btree.h" | ||
| 32 | #include "xfs_dir2_sf.h" | ||
| 33 | #include "xfs_attr_sf.h" | ||
| 34 | #include "xfs_dinode.h" | ||
| 35 | #include "xfs_inode.h" | ||
| 36 | #include "xfs_btree.h" | ||
| 37 | #include "xfs_dmapi.h" | ||
| 38 | #include "xfs_mount.h" | ||
| 39 | #include "xfs_ialloc.h" | ||
| 40 | #include "xfs_itable.h" | ||
| 41 | #include "xfs_alloc.h" | ||
| 42 | #include "xfs_bmap.h" | ||
| 43 | #include "xfs_attr.h" | ||
| 44 | #include "xfs_attr_sf.h" | ||
| 45 | #include "xfs_attr_leaf.h" | ||
| 46 | #include "xfs_log_priv.h" | ||
| 47 | #include "xfs_buf_item.h" | ||
| 48 | #include "xfs_quota.h" | ||
| 49 | #include "xfs_iomap.h" | ||
| 50 | #include "xfs_aops.h" | ||
| 51 | #include "quota/xfs_dquot_item.h" | ||
| 52 | #include "quota/xfs_dquot.h" | ||
| 53 | |||
| 54 | /* | ||
| 55 | * Format fsblock number into a static buffer & return it. | ||
| 56 | */ | ||
| 57 | STATIC char *xfs_fmtfsblock(xfs_fsblock_t bno) | ||
| 58 | { | ||
| 59 | static char rval[50]; | ||
| 60 | |||
| 61 | if (bno == NULLFSBLOCK) | ||
| 62 | sprintf(rval, "NULLFSBLOCK"); | ||
| 63 | else if (isnullstartblock(bno)) | ||
| 64 | sprintf(rval, "NULLSTARTBLOCK(%lld)", startblockval(bno)); | ||
| 65 | else | ||
| 66 | sprintf(rval, "%lld", (xfs_dfsbno_t)bno); | ||
| 67 | return rval; | ||
| 68 | } | ||
| 69 | |||
| 70 | /* | ||
| 71 | * We include this last to have the helpers above available for the trace | ||
| 72 | * event implementations. | ||
| 73 | */ | ||
| 74 | #define CREATE_TRACE_POINTS | ||
| 75 | #include "xfs_trace.h" | ||
diff --git a/fs/xfs/linux-2.6/xfs_trace.h b/fs/xfs/linux-2.6/xfs_trace.h new file mode 100644 index 000000000000..c40834bdee58 --- /dev/null +++ b/fs/xfs/linux-2.6/xfs_trace.h | |||
| @@ -0,0 +1,1369 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2009, Christoph Hellwig | ||
| 3 | * All Rights Reserved. | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU General Public License as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it would be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program; if not, write the Free Software Foundation, | ||
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | #undef TRACE_SYSTEM | ||
| 19 | #define TRACE_SYSTEM xfs | ||
| 20 | |||
| 21 | #if !defined(_TRACE_XFS_H) || defined(TRACE_HEADER_MULTI_READ) | ||
| 22 | #define _TRACE_XFS_H | ||
| 23 | |||
| 24 | #include <linux/tracepoint.h> | ||
| 25 | |||
| 26 | struct xfs_agf; | ||
| 27 | struct xfs_alloc_arg; | ||
| 28 | struct xfs_attr_list_context; | ||
| 29 | struct xfs_buf_log_item; | ||
| 30 | struct xfs_da_args; | ||
| 31 | struct xfs_da_node_entry; | ||
| 32 | struct xfs_dquot; | ||
| 33 | struct xlog_ticket; | ||
| 34 | struct log; | ||
| 35 | |||
| 36 | #define DEFINE_ATTR_LIST_EVENT(name) \ | ||
| 37 | TRACE_EVENT(name, \ | ||
| 38 | TP_PROTO(struct xfs_attr_list_context *ctx), \ | ||
| 39 | TP_ARGS(ctx), \ | ||
| 40 | TP_STRUCT__entry( \ | ||
| 41 | __field(dev_t, dev) \ | ||
| 42 | __field(xfs_ino_t, ino) \ | ||
| 43 | __field(u32, hashval) \ | ||
| 44 | __field(u32, blkno) \ | ||
| 45 | __field(u32, offset) \ | ||
| 46 | __field(void *, alist) \ | ||
| 47 | __field(int, bufsize) \ | ||
| 48 | __field(int, count) \ | ||
| 49 | __field(int, firstu) \ | ||
| 50 | __field(int, dupcnt) \ | ||
| 51 | __field(int, flags) \ | ||
| 52 | ), \ | ||
| 53 | TP_fast_assign( \ | ||
| 54 | __entry->dev = VFS_I(ctx->dp)->i_sb->s_dev; \ | ||
| 55 | __entry->ino = ctx->dp->i_ino; \ | ||
| 56 | __entry->hashval = ctx->cursor->hashval; \ | ||
| 57 | __entry->blkno = ctx->cursor->blkno; \ | ||
| 58 | __entry->offset = ctx->cursor->offset; \ | ||
| 59 | __entry->alist = ctx->alist; \ | ||
| 60 | __entry->bufsize = ctx->bufsize; \ | ||
| 61 | __entry->count = ctx->count; \ | ||
| 62 | __entry->firstu = ctx->firstu; \ | ||
| 63 | __entry->flags = ctx->flags; \ | ||
| 64 | ), \ | ||
| 65 | TP_printk("dev %d:%d ino 0x%llx cursor h/b/o 0x%x/0x%x/%u dupcnt %u " \ | ||
| 66 | "alist 0x%p size %u count %u firstu %u flags %d %s", \ | ||
| 67 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 68 | __entry->ino, \ | ||
| 69 | __entry->hashval, \ | ||
| 70 | __entry->blkno, \ | ||
| 71 | __entry->offset, \ | ||
| 72 | __entry->dupcnt, \ | ||
| 73 | __entry->alist, \ | ||
| 74 | __entry->bufsize, \ | ||
| 75 | __entry->count, \ | ||
| 76 | __entry->firstu, \ | ||
| 77 | __entry->flags, \ | ||
| 78 | __print_flags(__entry->flags, "|", XFS_ATTR_FLAGS) \ | ||
| 79 | ) \ | ||
| 80 | ) | ||
| 81 | DEFINE_ATTR_LIST_EVENT(xfs_attr_list_sf); | ||
| 82 | DEFINE_ATTR_LIST_EVENT(xfs_attr_list_sf_all); | ||
| 83 | DEFINE_ATTR_LIST_EVENT(xfs_attr_list_leaf); | ||
| 84 | DEFINE_ATTR_LIST_EVENT(xfs_attr_list_leaf_end); | ||
| 85 | DEFINE_ATTR_LIST_EVENT(xfs_attr_list_full); | ||
| 86 | DEFINE_ATTR_LIST_EVENT(xfs_attr_list_add); | ||
| 87 | DEFINE_ATTR_LIST_EVENT(xfs_attr_list_wrong_blk); | ||
| 88 | DEFINE_ATTR_LIST_EVENT(xfs_attr_list_notfound); | ||
| 89 | |||
| 90 | TRACE_EVENT(xfs_attr_list_node_descend, | ||
| 91 | TP_PROTO(struct xfs_attr_list_context *ctx, | ||
| 92 | struct xfs_da_node_entry *btree), | ||
| 93 | TP_ARGS(ctx, btree), | ||
| 94 | TP_STRUCT__entry( | ||
| 95 | __field(dev_t, dev) | ||
| 96 | __field(xfs_ino_t, ino) | ||
| 97 | __field(u32, hashval) | ||
| 98 | __field(u32, blkno) | ||
| 99 | __field(u32, offset) | ||
| 100 | __field(void *, alist) | ||
| 101 | __field(int, bufsize) | ||
| 102 | __field(int, count) | ||
| 103 | __field(int, firstu) | ||
| 104 | __field(int, dupcnt) | ||
| 105 | __field(int, flags) | ||
| 106 | __field(u32, bt_hashval) | ||
| 107 | __field(u32, bt_before) | ||
| 108 | ), | ||
| 109 | TP_fast_assign( | ||
| 110 | __entry->dev = VFS_I(ctx->dp)->i_sb->s_dev; | ||
| 111 | __entry->ino = ctx->dp->i_ino; | ||
| 112 | __entry->hashval = ctx->cursor->hashval; | ||
| 113 | __entry->blkno = ctx->cursor->blkno; | ||
| 114 | __entry->offset = ctx->cursor->offset; | ||
| 115 | __entry->alist = ctx->alist; | ||
| 116 | __entry->bufsize = ctx->bufsize; | ||
| 117 | __entry->count = ctx->count; | ||
| 118 | __entry->firstu = ctx->firstu; | ||
| 119 | __entry->flags = ctx->flags; | ||
| 120 | __entry->bt_hashval = be32_to_cpu(btree->hashval); | ||
| 121 | __entry->bt_before = be32_to_cpu(btree->before); | ||
| 122 | ), | ||
| 123 | TP_printk("dev %d:%d ino 0x%llx cursor h/b/o 0x%x/0x%x/%u dupcnt %u " | ||
| 124 | "alist 0x%p size %u count %u firstu %u flags %d %s " | ||
| 125 | "node hashval %u, node before %u", | ||
| 126 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
| 127 | __entry->ino, | ||
| 128 | __entry->hashval, | ||
| 129 | __entry->blkno, | ||
| 130 | __entry->offset, | ||
| 131 | __entry->dupcnt, | ||
| 132 | __entry->alist, | ||
| 133 | __entry->bufsize, | ||
| 134 | __entry->count, | ||
| 135 | __entry->firstu, | ||
| 136 | __entry->flags, | ||
| 137 | __print_flags(__entry->flags, "|", XFS_ATTR_FLAGS), | ||
| 138 | __entry->bt_hashval, | ||
| 139 | __entry->bt_before) | ||
| 140 | ); | ||
| 141 | |||
| 142 | TRACE_EVENT(xfs_iext_insert, | ||
| 143 | TP_PROTO(struct xfs_inode *ip, xfs_extnum_t idx, | ||
| 144 | struct xfs_bmbt_irec *r, int state, unsigned long caller_ip), | ||
| 145 | TP_ARGS(ip, idx, r, state, caller_ip), | ||
| 146 | TP_STRUCT__entry( | ||
| 147 | __field(dev_t, dev) | ||
| 148 | __field(xfs_ino_t, ino) | ||
| 149 | __field(xfs_extnum_t, idx) | ||
| 150 | __field(xfs_fileoff_t, startoff) | ||
| 151 | __field(xfs_fsblock_t, startblock) | ||
| 152 | __field(xfs_filblks_t, blockcount) | ||
| 153 | __field(xfs_exntst_t, state) | ||
| 154 | __field(int, bmap_state) | ||
| 155 | __field(unsigned long, caller_ip) | ||
| 156 | ), | ||
| 157 | TP_fast_assign( | ||
| 158 | __entry->dev = VFS_I(ip)->i_sb->s_dev; | ||
| 159 | __entry->ino = ip->i_ino; | ||
| 160 | __entry->idx = idx; | ||
| 161 | __entry->startoff = r->br_startoff; | ||
| 162 | __entry->startblock = r->br_startblock; | ||
| 163 | __entry->blockcount = r->br_blockcount; | ||
| 164 | __entry->state = r->br_state; | ||
| 165 | __entry->bmap_state = state; | ||
| 166 | __entry->caller_ip = caller_ip; | ||
| 167 | ), | ||
| 168 | TP_printk("dev %d:%d ino 0x%llx state %s idx %ld " | ||
| 169 | "offset %lld block %s count %lld flag %d caller %pf", | ||
| 170 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
| 171 | __entry->ino, | ||
| 172 | __print_flags(__entry->bmap_state, "|", XFS_BMAP_EXT_FLAGS), | ||
| 173 | (long)__entry->idx, | ||
| 174 | __entry->startoff, | ||
| 175 | xfs_fmtfsblock(__entry->startblock), | ||
| 176 | __entry->blockcount, | ||
| 177 | __entry->state, | ||
| 178 | (char *)__entry->caller_ip) | ||
| 179 | ); | ||
| 180 | |||
| 181 | #define DEFINE_BMAP_EVENT(name) \ | ||
| 182 | TRACE_EVENT(name, \ | ||
| 183 | TP_PROTO(struct xfs_inode *ip, xfs_extnum_t idx, int state, \ | ||
| 184 | unsigned long caller_ip), \ | ||
| 185 | TP_ARGS(ip, idx, state, caller_ip), \ | ||
| 186 | TP_STRUCT__entry( \ | ||
| 187 | __field(dev_t, dev) \ | ||
| 188 | __field(xfs_ino_t, ino) \ | ||
| 189 | __field(xfs_extnum_t, idx) \ | ||
| 190 | __field(xfs_fileoff_t, startoff) \ | ||
| 191 | __field(xfs_fsblock_t, startblock) \ | ||
| 192 | __field(xfs_filblks_t, blockcount) \ | ||
| 193 | __field(xfs_exntst_t, state) \ | ||
| 194 | __field(int, bmap_state) \ | ||
| 195 | __field(unsigned long, caller_ip) \ | ||
| 196 | ), \ | ||
| 197 | TP_fast_assign( \ | ||
| 198 | struct xfs_ifork *ifp = (state & BMAP_ATTRFORK) ? \ | ||
| 199 | ip->i_afp : &ip->i_df; \ | ||
| 200 | struct xfs_bmbt_irec r; \ | ||
| 201 | \ | ||
| 202 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx), &r); \ | ||
| 203 | __entry->dev = VFS_I(ip)->i_sb->s_dev; \ | ||
| 204 | __entry->ino = ip->i_ino; \ | ||
| 205 | __entry->idx = idx; \ | ||
| 206 | __entry->startoff = r.br_startoff; \ | ||
| 207 | __entry->startblock = r.br_startblock; \ | ||
| 208 | __entry->blockcount = r.br_blockcount; \ | ||
| 209 | __entry->state = r.br_state; \ | ||
| 210 | __entry->bmap_state = state; \ | ||
| 211 | __entry->caller_ip = caller_ip; \ | ||
| 212 | ), \ | ||
| 213 | TP_printk("dev %d:%d ino 0x%llx state %s idx %ld " \ | ||
| 214 | "offset %lld block %s count %lld flag %d caller %pf", \ | ||
| 215 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 216 | __entry->ino, \ | ||
| 217 | __print_flags(__entry->bmap_state, "|", XFS_BMAP_EXT_FLAGS), \ | ||
| 218 | (long)__entry->idx, \ | ||
| 219 | __entry->startoff, \ | ||
| 220 | xfs_fmtfsblock(__entry->startblock), \ | ||
| 221 | __entry->blockcount, \ | ||
| 222 | __entry->state, \ | ||
| 223 | (char *)__entry->caller_ip) \ | ||
| 224 | ) | ||
| 225 | |||
| 226 | DEFINE_BMAP_EVENT(xfs_iext_remove); | ||
| 227 | DEFINE_BMAP_EVENT(xfs_bmap_pre_update); | ||
| 228 | DEFINE_BMAP_EVENT(xfs_bmap_post_update); | ||
| 229 | DEFINE_BMAP_EVENT(xfs_extlist); | ||
| 230 | |||
| 231 | #define DEFINE_BUF_EVENT(tname) \ | ||
| 232 | TRACE_EVENT(tname, \ | ||
| 233 | TP_PROTO(struct xfs_buf *bp, unsigned long caller_ip), \ | ||
| 234 | TP_ARGS(bp, caller_ip), \ | ||
| 235 | TP_STRUCT__entry( \ | ||
| 236 | __field(dev_t, dev) \ | ||
| 237 | __field(xfs_daddr_t, bno) \ | ||
| 238 | __field(size_t, buffer_length) \ | ||
| 239 | __field(int, hold) \ | ||
| 240 | __field(int, pincount) \ | ||
| 241 | __field(unsigned, lockval) \ | ||
| 242 | __field(unsigned, flags) \ | ||
| 243 | __field(unsigned long, caller_ip) \ | ||
| 244 | ), \ | ||
| 245 | TP_fast_assign( \ | ||
| 246 | __entry->dev = bp->b_target->bt_dev; \ | ||
| 247 | __entry->bno = bp->b_bn; \ | ||
| 248 | __entry->buffer_length = bp->b_buffer_length; \ | ||
| 249 | __entry->hold = atomic_read(&bp->b_hold); \ | ||
| 250 | __entry->pincount = atomic_read(&bp->b_pin_count); \ | ||
| 251 | __entry->lockval = xfs_buf_lock_value(bp); \ | ||
| 252 | __entry->flags = bp->b_flags; \ | ||
| 253 | __entry->caller_ip = caller_ip; \ | ||
| 254 | ), \ | ||
| 255 | TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d " \ | ||
| 256 | "lock %d flags %s caller %pf", \ | ||
| 257 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 258 | (unsigned long long)__entry->bno, \ | ||
| 259 | __entry->buffer_length, \ | ||
| 260 | __entry->hold, \ | ||
| 261 | __entry->pincount, \ | ||
| 262 | __entry->lockval, \ | ||
| 263 | __print_flags(__entry->flags, "|", XFS_BUF_FLAGS), \ | ||
| 264 | (void *)__entry->caller_ip) \ | ||
| 265 | ) | ||
| 266 | DEFINE_BUF_EVENT(xfs_buf_init); | ||
| 267 | DEFINE_BUF_EVENT(xfs_buf_free); | ||
| 268 | DEFINE_BUF_EVENT(xfs_buf_hold); | ||
| 269 | DEFINE_BUF_EVENT(xfs_buf_rele); | ||
| 270 | DEFINE_BUF_EVENT(xfs_buf_pin); | ||
| 271 | DEFINE_BUF_EVENT(xfs_buf_unpin); | ||
| 272 | DEFINE_BUF_EVENT(xfs_buf_iodone); | ||
| 273 | DEFINE_BUF_EVENT(xfs_buf_iorequest); | ||
| 274 | DEFINE_BUF_EVENT(xfs_buf_bawrite); | ||
| 275 | DEFINE_BUF_EVENT(xfs_buf_bdwrite); | ||
| 276 | DEFINE_BUF_EVENT(xfs_buf_lock); | ||
| 277 | DEFINE_BUF_EVENT(xfs_buf_lock_done); | ||
| 278 | DEFINE_BUF_EVENT(xfs_buf_cond_lock); | ||
| 279 | DEFINE_BUF_EVENT(xfs_buf_unlock); | ||
| 280 | DEFINE_BUF_EVENT(xfs_buf_ordered_retry); | ||
| 281 | DEFINE_BUF_EVENT(xfs_buf_iowait); | ||
| 282 | DEFINE_BUF_EVENT(xfs_buf_iowait_done); | ||
| 283 | DEFINE_BUF_EVENT(xfs_buf_delwri_queue); | ||
| 284 | DEFINE_BUF_EVENT(xfs_buf_delwri_dequeue); | ||
| 285 | DEFINE_BUF_EVENT(xfs_buf_delwri_split); | ||
| 286 | DEFINE_BUF_EVENT(xfs_buf_get_noaddr); | ||
| 287 | DEFINE_BUF_EVENT(xfs_bdstrat_shut); | ||
| 288 | DEFINE_BUF_EVENT(xfs_buf_item_relse); | ||
| 289 | DEFINE_BUF_EVENT(xfs_buf_item_iodone); | ||
| 290 | DEFINE_BUF_EVENT(xfs_buf_item_iodone_async); | ||
| 291 | DEFINE_BUF_EVENT(xfs_buf_error_relse); | ||
| 292 | DEFINE_BUF_EVENT(xfs_trans_read_buf_io); | ||
| 293 | DEFINE_BUF_EVENT(xfs_trans_read_buf_shut); | ||
| 294 | |||
| 295 | /* not really buffer traces, but the buf provides useful information */ | ||
| 296 | DEFINE_BUF_EVENT(xfs_btree_corrupt); | ||
| 297 | DEFINE_BUF_EVENT(xfs_da_btree_corrupt); | ||
| 298 | DEFINE_BUF_EVENT(xfs_reset_dqcounts); | ||
| 299 | DEFINE_BUF_EVENT(xfs_inode_item_push); | ||
| 300 | |||
| 301 | /* pass flags explicitly */ | ||
| 302 | #define DEFINE_BUF_FLAGS_EVENT(tname) \ | ||
| 303 | TRACE_EVENT(tname, \ | ||
| 304 | TP_PROTO(struct xfs_buf *bp, unsigned flags, unsigned long caller_ip), \ | ||
| 305 | TP_ARGS(bp, flags, caller_ip), \ | ||
| 306 | TP_STRUCT__entry( \ | ||
| 307 | __field(dev_t, dev) \ | ||
| 308 | __field(xfs_daddr_t, bno) \ | ||
| 309 | __field(size_t, buffer_length) \ | ||
| 310 | __field(int, hold) \ | ||
| 311 | __field(int, pincount) \ | ||
| 312 | __field(unsigned, lockval) \ | ||
| 313 | __field(unsigned, flags) \ | ||
| 314 | __field(unsigned long, caller_ip) \ | ||
| 315 | ), \ | ||
| 316 | TP_fast_assign( \ | ||
| 317 | __entry->dev = bp->b_target->bt_dev; \ | ||
| 318 | __entry->bno = bp->b_bn; \ | ||
| 319 | __entry->buffer_length = bp->b_buffer_length; \ | ||
| 320 | __entry->flags = flags; \ | ||
| 321 | __entry->hold = atomic_read(&bp->b_hold); \ | ||
| 322 | __entry->pincount = atomic_read(&bp->b_pin_count); \ | ||
| 323 | __entry->lockval = xfs_buf_lock_value(bp); \ | ||
| 324 | __entry->caller_ip = caller_ip; \ | ||
| 325 | ), \ | ||
| 326 | TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d " \ | ||
| 327 | "lock %d flags %s caller %pf", \ | ||
| 328 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 329 | (unsigned long long)__entry->bno, \ | ||
| 330 | __entry->buffer_length, \ | ||
| 331 | __entry->hold, \ | ||
| 332 | __entry->pincount, \ | ||
| 333 | __entry->lockval, \ | ||
| 334 | __print_flags(__entry->flags, "|", XFS_BUF_FLAGS), \ | ||
| 335 | (void *)__entry->caller_ip) \ | ||
| 336 | ) | ||
| 337 | DEFINE_BUF_FLAGS_EVENT(xfs_buf_find); | ||
| 338 | DEFINE_BUF_FLAGS_EVENT(xfs_buf_get); | ||
| 339 | DEFINE_BUF_FLAGS_EVENT(xfs_buf_read); | ||
| 340 | |||
| 341 | TRACE_EVENT(xfs_buf_ioerror, | ||
| 342 | TP_PROTO(struct xfs_buf *bp, int error, unsigned long caller_ip), | ||
| 343 | TP_ARGS(bp, error, caller_ip), | ||
| 344 | TP_STRUCT__entry( | ||
| 345 | __field(dev_t, dev) | ||
| 346 | __field(xfs_daddr_t, bno) | ||
| 347 | __field(size_t, buffer_length) | ||
| 348 | __field(unsigned, flags) | ||
| 349 | __field(int, hold) | ||
| 350 | __field(int, pincount) | ||
| 351 | __field(unsigned, lockval) | ||
| 352 | __field(int, error) | ||
| 353 | __field(unsigned long, caller_ip) | ||
| 354 | ), | ||
| 355 | TP_fast_assign( | ||
| 356 | __entry->dev = bp->b_target->bt_dev; | ||
| 357 | __entry->bno = bp->b_bn; | ||
| 358 | __entry->buffer_length = bp->b_buffer_length; | ||
| 359 | __entry->hold = atomic_read(&bp->b_hold); | ||
| 360 | __entry->pincount = atomic_read(&bp->b_pin_count); | ||
| 361 | __entry->lockval = xfs_buf_lock_value(bp); | ||
| 362 | __entry->error = error; | ||
| 363 | __entry->flags = bp->b_flags; | ||
| 364 | __entry->caller_ip = caller_ip; | ||
| 365 | ), | ||
| 366 | TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d " | ||
| 367 | "lock %d error %d flags %s caller %pf", | ||
| 368 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
| 369 | (unsigned long long)__entry->bno, | ||
| 370 | __entry->buffer_length, | ||
| 371 | __entry->hold, | ||
| 372 | __entry->pincount, | ||
| 373 | __entry->lockval, | ||
| 374 | __entry->error, | ||
| 375 | __print_flags(__entry->flags, "|", XFS_BUF_FLAGS), | ||
| 376 | (void *)__entry->caller_ip) | ||
| 377 | ); | ||
| 378 | |||
| 379 | #define DEFINE_BUF_ITEM_EVENT(tname) \ | ||
| 380 | TRACE_EVENT(tname, \ | ||
| 381 | TP_PROTO(struct xfs_buf_log_item *bip), \ | ||
| 382 | TP_ARGS(bip), \ | ||
| 383 | TP_STRUCT__entry( \ | ||
| 384 | __field(dev_t, dev) \ | ||
| 385 | __field(xfs_daddr_t, buf_bno) \ | ||
| 386 | __field(size_t, buf_len) \ | ||
| 387 | __field(int, buf_hold) \ | ||
| 388 | __field(int, buf_pincount) \ | ||
| 389 | __field(int, buf_lockval) \ | ||
| 390 | __field(unsigned, buf_flags) \ | ||
| 391 | __field(unsigned, bli_recur) \ | ||
| 392 | __field(int, bli_refcount) \ | ||
| 393 | __field(unsigned, bli_flags) \ | ||
| 394 | __field(void *, li_desc) \ | ||
| 395 | __field(unsigned, li_flags) \ | ||
| 396 | ), \ | ||
| 397 | TP_fast_assign( \ | ||
| 398 | __entry->dev = bip->bli_buf->b_target->bt_dev; \ | ||
| 399 | __entry->bli_flags = bip->bli_flags; \ | ||
| 400 | __entry->bli_recur = bip->bli_recur; \ | ||
| 401 | __entry->bli_refcount = atomic_read(&bip->bli_refcount); \ | ||
| 402 | __entry->buf_bno = bip->bli_buf->b_bn; \ | ||
| 403 | __entry->buf_len = bip->bli_buf->b_buffer_length; \ | ||
| 404 | __entry->buf_flags = bip->bli_buf->b_flags; \ | ||
| 405 | __entry->buf_hold = atomic_read(&bip->bli_buf->b_hold); \ | ||
| 406 | __entry->buf_pincount = \ | ||
| 407 | atomic_read(&bip->bli_buf->b_pin_count); \ | ||
| 408 | __entry->buf_lockval = xfs_buf_lock_value(bip->bli_buf); \ | ||
| 409 | __entry->li_desc = bip->bli_item.li_desc; \ | ||
| 410 | __entry->li_flags = bip->bli_item.li_flags; \ | ||
| 411 | ), \ | ||
| 412 | TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d " \ | ||
| 413 | "lock %d flags %s recur %d refcount %d bliflags %s " \ | ||
| 414 | "lidesc 0x%p liflags %s", \ | ||
| 415 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 416 | (unsigned long long)__entry->buf_bno, \ | ||
| 417 | __entry->buf_len, \ | ||
| 418 | __entry->buf_hold, \ | ||
| 419 | __entry->buf_pincount, \ | ||
| 420 | __entry->buf_lockval, \ | ||
| 421 | __print_flags(__entry->buf_flags, "|", XFS_BUF_FLAGS), \ | ||
| 422 | __entry->bli_recur, \ | ||
| 423 | __entry->bli_refcount, \ | ||
| 424 | __print_flags(__entry->bli_flags, "|", XFS_BLI_FLAGS), \ | ||
| 425 | __entry->li_desc, \ | ||
| 426 | __print_flags(__entry->li_flags, "|", XFS_LI_FLAGS)) \ | ||
| 427 | ) | ||
| 428 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size); | ||
| 429 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_size_stale); | ||
| 430 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format); | ||
| 431 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_format_stale); | ||
| 432 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_pin); | ||
| 433 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin); | ||
| 434 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unpin_stale); | ||
| 435 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_trylock); | ||
| 436 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unlock); | ||
| 437 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_unlock_stale); | ||
| 438 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_committed); | ||
| 439 | DEFINE_BUF_ITEM_EVENT(xfs_buf_item_push); | ||
| 440 | DEFINE_BUF_ITEM_EVENT(xfs_trans_get_buf); | ||
| 441 | DEFINE_BUF_ITEM_EVENT(xfs_trans_get_buf_recur); | ||
| 442 | DEFINE_BUF_ITEM_EVENT(xfs_trans_getsb); | ||
| 443 | DEFINE_BUF_ITEM_EVENT(xfs_trans_getsb_recur); | ||
| 444 | DEFINE_BUF_ITEM_EVENT(xfs_trans_read_buf); | ||
| 445 | DEFINE_BUF_ITEM_EVENT(xfs_trans_read_buf_recur); | ||
| 446 | DEFINE_BUF_ITEM_EVENT(xfs_trans_log_buf); | ||
| 447 | DEFINE_BUF_ITEM_EVENT(xfs_trans_brelse); | ||
| 448 | DEFINE_BUF_ITEM_EVENT(xfs_trans_bjoin); | ||
| 449 | DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold); | ||
| 450 | DEFINE_BUF_ITEM_EVENT(xfs_trans_bhold_release); | ||
| 451 | DEFINE_BUF_ITEM_EVENT(xfs_trans_binval); | ||
| 452 | |||
| 453 | #define DEFINE_LOCK_EVENT(name) \ | ||
| 454 | TRACE_EVENT(name, \ | ||
| 455 | TP_PROTO(struct xfs_inode *ip, unsigned lock_flags, \ | ||
| 456 | unsigned long caller_ip), \ | ||
| 457 | TP_ARGS(ip, lock_flags, caller_ip), \ | ||
| 458 | TP_STRUCT__entry( \ | ||
| 459 | __field(dev_t, dev) \ | ||
| 460 | __field(xfs_ino_t, ino) \ | ||
| 461 | __field(int, lock_flags) \ | ||
| 462 | __field(unsigned long, caller_ip) \ | ||
| 463 | ), \ | ||
| 464 | TP_fast_assign( \ | ||
| 465 | __entry->dev = VFS_I(ip)->i_sb->s_dev; \ | ||
| 466 | __entry->ino = ip->i_ino; \ | ||
| 467 | __entry->lock_flags = lock_flags; \ | ||
| 468 | __entry->caller_ip = caller_ip; \ | ||
| 469 | ), \ | ||
| 470 | TP_printk("dev %d:%d ino 0x%llx flags %s caller %pf", \ | ||
| 471 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 472 | __entry->ino, \ | ||
| 473 | __print_flags(__entry->lock_flags, "|", XFS_LOCK_FLAGS), \ | ||
| 474 | (void *)__entry->caller_ip) \ | ||
| 475 | ) | ||
| 476 | |||
| 477 | DEFINE_LOCK_EVENT(xfs_ilock); | ||
| 478 | DEFINE_LOCK_EVENT(xfs_ilock_nowait); | ||
| 479 | DEFINE_LOCK_EVENT(xfs_ilock_demote); | ||
| 480 | DEFINE_LOCK_EVENT(xfs_iunlock); | ||
| 481 | |||
| 482 | #define DEFINE_IGET_EVENT(name) \ | ||
| 483 | TRACE_EVENT(name, \ | ||
| 484 | TP_PROTO(struct xfs_inode *ip), \ | ||
| 485 | TP_ARGS(ip), \ | ||
| 486 | TP_STRUCT__entry( \ | ||
| 487 | __field(dev_t, dev) \ | ||
| 488 | __field(xfs_ino_t, ino) \ | ||
| 489 | ), \ | ||
| 490 | TP_fast_assign( \ | ||
| 491 | __entry->dev = VFS_I(ip)->i_sb->s_dev; \ | ||
| 492 | __entry->ino = ip->i_ino; \ | ||
| 493 | ), \ | ||
| 494 | TP_printk("dev %d:%d ino 0x%llx", \ | ||
| 495 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 496 | __entry->ino) \ | ||
| 497 | ) | ||
| 498 | DEFINE_IGET_EVENT(xfs_iget_skip); | ||
| 499 | DEFINE_IGET_EVENT(xfs_iget_reclaim); | ||
| 500 | DEFINE_IGET_EVENT(xfs_iget_found); | ||
| 501 | DEFINE_IGET_EVENT(xfs_iget_alloc); | ||
| 502 | |||
| 503 | #define DEFINE_INODE_EVENT(name) \ | ||
| 504 | TRACE_EVENT(name, \ | ||
| 505 | TP_PROTO(struct xfs_inode *ip, unsigned long caller_ip), \ | ||
| 506 | TP_ARGS(ip, caller_ip), \ | ||
| 507 | TP_STRUCT__entry( \ | ||
| 508 | __field(dev_t, dev) \ | ||
| 509 | __field(xfs_ino_t, ino) \ | ||
| 510 | __field(int, count) \ | ||
| 511 | __field(unsigned long, caller_ip) \ | ||
| 512 | ), \ | ||
| 513 | TP_fast_assign( \ | ||
| 514 | __entry->dev = VFS_I(ip)->i_sb->s_dev; \ | ||
| 515 | __entry->ino = ip->i_ino; \ | ||
| 516 | __entry->count = atomic_read(&VFS_I(ip)->i_count); \ | ||
| 517 | __entry->caller_ip = caller_ip; \ | ||
| 518 | ), \ | ||
| 519 | TP_printk("dev %d:%d ino 0x%llx count %d caller %pf", \ | ||
| 520 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 521 | __entry->ino, \ | ||
| 522 | __entry->count, \ | ||
| 523 | (char *)__entry->caller_ip) \ | ||
| 524 | ) | ||
| 525 | DEFINE_INODE_EVENT(xfs_ihold); | ||
| 526 | DEFINE_INODE_EVENT(xfs_irele); | ||
| 527 | /* the old xfs_itrace_entry tracer - to be replaced by s.th. in the VFS */ | ||
| 528 | DEFINE_INODE_EVENT(xfs_inode); | ||
| 529 | #define xfs_itrace_entry(ip) \ | ||
| 530 | trace_xfs_inode(ip, _THIS_IP_) | ||
| 531 | |||
| 532 | #define DEFINE_DQUOT_EVENT(tname) \ | ||
| 533 | TRACE_EVENT(tname, \ | ||
| 534 | TP_PROTO(struct xfs_dquot *dqp), \ | ||
| 535 | TP_ARGS(dqp), \ | ||
| 536 | TP_STRUCT__entry( \ | ||
| 537 | __field(dev_t, dev) \ | ||
| 538 | __field(__be32, id) \ | ||
| 539 | __field(unsigned, flags) \ | ||
| 540 | __field(unsigned, nrefs) \ | ||
| 541 | __field(unsigned long long, res_bcount) \ | ||
| 542 | __field(unsigned long long, bcount) \ | ||
| 543 | __field(unsigned long long, icount) \ | ||
| 544 | __field(unsigned long long, blk_hardlimit) \ | ||
| 545 | __field(unsigned long long, blk_softlimit) \ | ||
| 546 | __field(unsigned long long, ino_hardlimit) \ | ||
| 547 | __field(unsigned long long, ino_softlimit) \ | ||
| 548 | ), \ | ||
| 549 | TP_fast_assign( \ | ||
| 550 | __entry->dev = dqp->q_mount->m_super->s_dev; \ | ||
| 551 | __entry->id = dqp->q_core.d_id; \ | ||
| 552 | __entry->flags = dqp->dq_flags; \ | ||
| 553 | __entry->nrefs = dqp->q_nrefs; \ | ||
| 554 | __entry->res_bcount = dqp->q_res_bcount; \ | ||
| 555 | __entry->bcount = be64_to_cpu(dqp->q_core.d_bcount); \ | ||
| 556 | __entry->icount = be64_to_cpu(dqp->q_core.d_icount); \ | ||
| 557 | __entry->blk_hardlimit = \ | ||
| 558 | be64_to_cpu(dqp->q_core.d_blk_hardlimit); \ | ||
| 559 | __entry->blk_softlimit = \ | ||
| 560 | be64_to_cpu(dqp->q_core.d_blk_softlimit); \ | ||
| 561 | __entry->ino_hardlimit = \ | ||
| 562 | be64_to_cpu(dqp->q_core.d_ino_hardlimit); \ | ||
| 563 | __entry->ino_softlimit = \ | ||
| 564 | be64_to_cpu(dqp->q_core.d_ino_softlimit); \ | ||
| 565 | ), \ | ||
| 566 | TP_printk("dev %d:%d id 0x%x flags %s nrefs %u res_bc 0x%llx " \ | ||
| 567 | "bcnt 0x%llx [hard 0x%llx | soft 0x%llx] " \ | ||
| 568 | "icnt 0x%llx [hard 0x%llx | soft 0x%llx]", \ | ||
| 569 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 570 | be32_to_cpu(__entry->id), \ | ||
| 571 | __print_flags(__entry->flags, "|", XFS_DQ_FLAGS), \ | ||
| 572 | __entry->nrefs, \ | ||
| 573 | __entry->res_bcount, \ | ||
| 574 | __entry->bcount, \ | ||
| 575 | __entry->blk_hardlimit, \ | ||
| 576 | __entry->blk_softlimit, \ | ||
| 577 | __entry->icount, \ | ||
| 578 | __entry->ino_hardlimit, \ | ||
| 579 | __entry->ino_softlimit) \ | ||
| 580 | ) | ||
| 581 | DEFINE_DQUOT_EVENT(xfs_dqadjust); | ||
| 582 | DEFINE_DQUOT_EVENT(xfs_dqshake_dirty); | ||
| 583 | DEFINE_DQUOT_EVENT(xfs_dqshake_unlink); | ||
| 584 | DEFINE_DQUOT_EVENT(xfs_dqreclaim_want); | ||
| 585 | DEFINE_DQUOT_EVENT(xfs_dqreclaim_dirty); | ||
| 586 | DEFINE_DQUOT_EVENT(xfs_dqreclaim_unlink); | ||
| 587 | DEFINE_DQUOT_EVENT(xfs_dqattach_found); | ||
| 588 | DEFINE_DQUOT_EVENT(xfs_dqattach_get); | ||
| 589 | DEFINE_DQUOT_EVENT(xfs_dqinit); | ||
| 590 | DEFINE_DQUOT_EVENT(xfs_dqreuse); | ||
| 591 | DEFINE_DQUOT_EVENT(xfs_dqalloc); | ||
| 592 | DEFINE_DQUOT_EVENT(xfs_dqtobp_read); | ||
| 593 | DEFINE_DQUOT_EVENT(xfs_dqread); | ||
| 594 | DEFINE_DQUOT_EVENT(xfs_dqread_fail); | ||
| 595 | DEFINE_DQUOT_EVENT(xfs_dqlookup_found); | ||
| 596 | DEFINE_DQUOT_EVENT(xfs_dqlookup_want); | ||
| 597 | DEFINE_DQUOT_EVENT(xfs_dqlookup_freelist); | ||
| 598 | DEFINE_DQUOT_EVENT(xfs_dqlookup_move); | ||
| 599 | DEFINE_DQUOT_EVENT(xfs_dqlookup_done); | ||
| 600 | DEFINE_DQUOT_EVENT(xfs_dqget_hit); | ||
| 601 | DEFINE_DQUOT_EVENT(xfs_dqget_miss); | ||
| 602 | DEFINE_DQUOT_EVENT(xfs_dqput); | ||
| 603 | DEFINE_DQUOT_EVENT(xfs_dqput_wait); | ||
| 604 | DEFINE_DQUOT_EVENT(xfs_dqput_free); | ||
| 605 | DEFINE_DQUOT_EVENT(xfs_dqrele); | ||
| 606 | DEFINE_DQUOT_EVENT(xfs_dqflush); | ||
| 607 | DEFINE_DQUOT_EVENT(xfs_dqflush_force); | ||
| 608 | DEFINE_DQUOT_EVENT(xfs_dqflush_done); | ||
| 609 | /* not really iget events, but we re-use the format */ | ||
| 610 | DEFINE_IGET_EVENT(xfs_dquot_dqalloc); | ||
| 611 | DEFINE_IGET_EVENT(xfs_dquot_dqdetach); | ||
| 612 | |||
| 613 | |||
| 614 | #define DEFINE_LOGGRANT_EVENT(tname) \ | ||
| 615 | TRACE_EVENT(tname, \ | ||
| 616 | TP_PROTO(struct log *log, struct xlog_ticket *tic), \ | ||
| 617 | TP_ARGS(log, tic), \ | ||
| 618 | TP_STRUCT__entry( \ | ||
| 619 | __field(dev_t, dev) \ | ||
| 620 | __field(unsigned, trans_type) \ | ||
| 621 | __field(char, ocnt) \ | ||
| 622 | __field(char, cnt) \ | ||
| 623 | __field(int, curr_res) \ | ||
| 624 | __field(int, unit_res) \ | ||
| 625 | __field(unsigned int, flags) \ | ||
| 626 | __field(void *, reserve_headq) \ | ||
| 627 | __field(void *, write_headq) \ | ||
| 628 | __field(int, grant_reserve_cycle) \ | ||
| 629 | __field(int, grant_reserve_bytes) \ | ||
| 630 | __field(int, grant_write_cycle) \ | ||
| 631 | __field(int, grant_write_bytes) \ | ||
| 632 | __field(int, curr_cycle) \ | ||
| 633 | __field(int, curr_block) \ | ||
| 634 | __field(xfs_lsn_t, tail_lsn) \ | ||
| 635 | ), \ | ||
| 636 | TP_fast_assign( \ | ||
| 637 | __entry->dev = log->l_mp->m_super->s_dev; \ | ||
| 638 | __entry->trans_type = tic->t_trans_type; \ | ||
| 639 | __entry->ocnt = tic->t_ocnt; \ | ||
| 640 | __entry->cnt = tic->t_cnt; \ | ||
| 641 | __entry->curr_res = tic->t_curr_res; \ | ||
| 642 | __entry->unit_res = tic->t_unit_res; \ | ||
| 643 | __entry->flags = tic->t_flags; \ | ||
| 644 | __entry->reserve_headq = log->l_reserve_headq; \ | ||
| 645 | __entry->write_headq = log->l_write_headq; \ | ||
| 646 | __entry->grant_reserve_cycle = log->l_grant_reserve_cycle; \ | ||
| 647 | __entry->grant_reserve_bytes = log->l_grant_reserve_bytes; \ | ||
| 648 | __entry->grant_write_cycle = log->l_grant_write_cycle; \ | ||
| 649 | __entry->grant_write_bytes = log->l_grant_write_bytes; \ | ||
| 650 | __entry->curr_cycle = log->l_curr_cycle; \ | ||
| 651 | __entry->curr_block = log->l_curr_block; \ | ||
| 652 | __entry->tail_lsn = log->l_tail_lsn; \ | ||
| 653 | ), \ | ||
| 654 | TP_printk("dev %d:%d type %s t_ocnt %u t_cnt %u t_curr_res %u " \ | ||
| 655 | "t_unit_res %u t_flags %s reserve_headq 0x%p " \ | ||
| 656 | "write_headq 0x%p grant_reserve_cycle %d " \ | ||
| 657 | "grant_reserve_bytes %d grant_write_cycle %d " \ | ||
| 658 | "grant_write_bytes %d curr_cycle %d curr_block %d " \ | ||
| 659 | "tail_cycle %d tail_block %d", \ | ||
| 660 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 661 | __print_symbolic(__entry->trans_type, XFS_TRANS_TYPES), \ | ||
| 662 | __entry->ocnt, \ | ||
| 663 | __entry->cnt, \ | ||
| 664 | __entry->curr_res, \ | ||
| 665 | __entry->unit_res, \ | ||
| 666 | __print_flags(__entry->flags, "|", XLOG_TIC_FLAGS), \ | ||
| 667 | __entry->reserve_headq, \ | ||
| 668 | __entry->write_headq, \ | ||
| 669 | __entry->grant_reserve_cycle, \ | ||
| 670 | __entry->grant_reserve_bytes, \ | ||
| 671 | __entry->grant_write_cycle, \ | ||
| 672 | __entry->grant_write_bytes, \ | ||
| 673 | __entry->curr_cycle, \ | ||
| 674 | __entry->curr_block, \ | ||
| 675 | CYCLE_LSN(__entry->tail_lsn), \ | ||
| 676 | BLOCK_LSN(__entry->tail_lsn) \ | ||
| 677 | ) \ | ||
| 678 | ) | ||
| 679 | DEFINE_LOGGRANT_EVENT(xfs_log_done_nonperm); | ||
| 680 | DEFINE_LOGGRANT_EVENT(xfs_log_done_perm); | ||
| 681 | DEFINE_LOGGRANT_EVENT(xfs_log_reserve); | ||
| 682 | DEFINE_LOGGRANT_EVENT(xfs_log_umount_write); | ||
| 683 | DEFINE_LOGGRANT_EVENT(xfs_log_grant_enter); | ||
| 684 | DEFINE_LOGGRANT_EVENT(xfs_log_grant_exit); | ||
| 685 | DEFINE_LOGGRANT_EVENT(xfs_log_grant_error); | ||
| 686 | DEFINE_LOGGRANT_EVENT(xfs_log_grant_sleep1); | ||
| 687 | DEFINE_LOGGRANT_EVENT(xfs_log_grant_wake1); | ||
| 688 | DEFINE_LOGGRANT_EVENT(xfs_log_grant_sleep2); | ||
| 689 | DEFINE_LOGGRANT_EVENT(xfs_log_grant_wake2); | ||
| 690 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_enter); | ||
| 691 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_exit); | ||
| 692 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_error); | ||
| 693 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_sleep1); | ||
| 694 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_wake1); | ||
| 695 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_sleep2); | ||
| 696 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_wake2); | ||
| 697 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_enter); | ||
| 698 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_exit); | ||
| 699 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_sub); | ||
| 700 | DEFINE_LOGGRANT_EVENT(xfs_log_ungrant_enter); | ||
| 701 | DEFINE_LOGGRANT_EVENT(xfs_log_ungrant_exit); | ||
| 702 | DEFINE_LOGGRANT_EVENT(xfs_log_ungrant_sub); | ||
| 703 | |||
| 704 | #define DEFINE_RW_EVENT(name) \ | ||
| 705 | TRACE_EVENT(name, \ | ||
| 706 | TP_PROTO(struct xfs_inode *ip, size_t count, loff_t offset, int flags), \ | ||
| 707 | TP_ARGS(ip, count, offset, flags), \ | ||
| 708 | TP_STRUCT__entry( \ | ||
| 709 | __field(dev_t, dev) \ | ||
| 710 | __field(xfs_ino_t, ino) \ | ||
| 711 | __field(xfs_fsize_t, size) \ | ||
| 712 | __field(xfs_fsize_t, new_size) \ | ||
| 713 | __field(loff_t, offset) \ | ||
| 714 | __field(size_t, count) \ | ||
| 715 | __field(int, flags) \ | ||
| 716 | ), \ | ||
| 717 | TP_fast_assign( \ | ||
| 718 | __entry->dev = VFS_I(ip)->i_sb->s_dev; \ | ||
| 719 | __entry->ino = ip->i_ino; \ | ||
| 720 | __entry->size = ip->i_d.di_size; \ | ||
| 721 | __entry->new_size = ip->i_new_size; \ | ||
| 722 | __entry->offset = offset; \ | ||
| 723 | __entry->count = count; \ | ||
| 724 | __entry->flags = flags; \ | ||
| 725 | ), \ | ||
| 726 | TP_printk("dev %d:%d ino 0x%llx size 0x%llx new_size 0x%llx " \ | ||
| 727 | "offset 0x%llx count 0x%zx ioflags %s", \ | ||
| 728 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 729 | __entry->ino, \ | ||
| 730 | __entry->size, \ | ||
| 731 | __entry->new_size, \ | ||
| 732 | __entry->offset, \ | ||
| 733 | __entry->count, \ | ||
| 734 | __print_flags(__entry->flags, "|", XFS_IO_FLAGS)) \ | ||
| 735 | ) | ||
| 736 | DEFINE_RW_EVENT(xfs_file_read); | ||
| 737 | DEFINE_RW_EVENT(xfs_file_buffered_write); | ||
| 738 | DEFINE_RW_EVENT(xfs_file_direct_write); | ||
| 739 | DEFINE_RW_EVENT(xfs_file_splice_read); | ||
| 740 | DEFINE_RW_EVENT(xfs_file_splice_write); | ||
| 741 | |||
| 742 | |||
| 743 | #define DEFINE_PAGE_EVENT(name) \ | ||
| 744 | TRACE_EVENT(name, \ | ||
| 745 | TP_PROTO(struct inode *inode, struct page *page, unsigned long off), \ | ||
| 746 | TP_ARGS(inode, page, off), \ | ||
| 747 | TP_STRUCT__entry( \ | ||
| 748 | __field(dev_t, dev) \ | ||
| 749 | __field(xfs_ino_t, ino) \ | ||
| 750 | __field(pgoff_t, pgoff) \ | ||
| 751 | __field(loff_t, size) \ | ||
| 752 | __field(unsigned long, offset) \ | ||
| 753 | __field(int, delalloc) \ | ||
| 754 | __field(int, unmapped) \ | ||
| 755 | __field(int, unwritten) \ | ||
| 756 | ), \ | ||
| 757 | TP_fast_assign( \ | ||
| 758 | int delalloc = -1, unmapped = -1, unwritten = -1; \ | ||
| 759 | \ | ||
| 760 | if (page_has_buffers(page)) \ | ||
| 761 | xfs_count_page_state(page, &delalloc, \ | ||
| 762 | &unmapped, &unwritten); \ | ||
| 763 | __entry->dev = inode->i_sb->s_dev; \ | ||
| 764 | __entry->ino = XFS_I(inode)->i_ino; \ | ||
| 765 | __entry->pgoff = page_offset(page); \ | ||
| 766 | __entry->size = i_size_read(inode); \ | ||
| 767 | __entry->offset = off; \ | ||
| 768 | __entry->delalloc = delalloc; \ | ||
| 769 | __entry->unmapped = unmapped; \ | ||
| 770 | __entry->unwritten = unwritten; \ | ||
| 771 | ), \ | ||
| 772 | TP_printk("dev %d:%d ino 0x%llx pgoff 0x%lx size 0x%llx offset %lx " \ | ||
| 773 | "delalloc %d unmapped %d unwritten %d", \ | ||
| 774 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 775 | __entry->ino, \ | ||
| 776 | __entry->pgoff, \ | ||
| 777 | __entry->size, \ | ||
| 778 | __entry->offset, \ | ||
| 779 | __entry->delalloc, \ | ||
| 780 | __entry->unmapped, \ | ||
| 781 | __entry->unwritten) \ | ||
| 782 | ) | ||
| 783 | DEFINE_PAGE_EVENT(xfs_writepage); | ||
| 784 | DEFINE_PAGE_EVENT(xfs_releasepage); | ||
| 785 | DEFINE_PAGE_EVENT(xfs_invalidatepage); | ||
| 786 | |||
| 787 | #define DEFINE_IOMAP_EVENT(name) \ | ||
| 788 | TRACE_EVENT(name, \ | ||
| 789 | TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count, \ | ||
| 790 | int flags, struct xfs_bmbt_irec *irec), \ | ||
| 791 | TP_ARGS(ip, offset, count, flags, irec), \ | ||
| 792 | TP_STRUCT__entry( \ | ||
| 793 | __field(dev_t, dev) \ | ||
| 794 | __field(xfs_ino_t, ino) \ | ||
| 795 | __field(loff_t, size) \ | ||
| 796 | __field(loff_t, new_size) \ | ||
| 797 | __field(loff_t, offset) \ | ||
| 798 | __field(size_t, count) \ | ||
| 799 | __field(int, flags) \ | ||
| 800 | __field(xfs_fileoff_t, startoff) \ | ||
| 801 | __field(xfs_fsblock_t, startblock) \ | ||
| 802 | __field(xfs_filblks_t, blockcount) \ | ||
| 803 | ), \ | ||
| 804 | TP_fast_assign( \ | ||
| 805 | __entry->dev = VFS_I(ip)->i_sb->s_dev; \ | ||
| 806 | __entry->ino = ip->i_ino; \ | ||
| 807 | __entry->size = ip->i_d.di_size; \ | ||
| 808 | __entry->new_size = ip->i_new_size; \ | ||
| 809 | __entry->offset = offset; \ | ||
| 810 | __entry->count = count; \ | ||
| 811 | __entry->flags = flags; \ | ||
| 812 | __entry->startoff = irec ? irec->br_startoff : 0; \ | ||
| 813 | __entry->startblock = irec ? irec->br_startblock : 0; \ | ||
| 814 | __entry->blockcount = irec ? irec->br_blockcount : 0; \ | ||
| 815 | ), \ | ||
| 816 | TP_printk("dev %d:%d ino 0x%llx size 0x%llx new_size 0x%llx " \ | ||
| 817 | "offset 0x%llx count %zd flags %s " \ | ||
| 818 | "startoff 0x%llx startblock 0x%llx blockcount 0x%llx", \ | ||
| 819 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 820 | __entry->ino, \ | ||
| 821 | __entry->size, \ | ||
| 822 | __entry->new_size, \ | ||
| 823 | __entry->offset, \ | ||
| 824 | __entry->count, \ | ||
| 825 | __print_flags(__entry->flags, "|", BMAPI_FLAGS), \ | ||
| 826 | __entry->startoff, \ | ||
| 827 | __entry->startblock, \ | ||
| 828 | __entry->blockcount) \ | ||
| 829 | ) | ||
| 830 | DEFINE_IOMAP_EVENT(xfs_iomap_enter); | ||
| 831 | DEFINE_IOMAP_EVENT(xfs_iomap_found); | ||
| 832 | DEFINE_IOMAP_EVENT(xfs_iomap_alloc); | ||
| 833 | |||
| 834 | #define DEFINE_SIMPLE_IO_EVENT(name) \ | ||
| 835 | TRACE_EVENT(name, \ | ||
| 836 | TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count), \ | ||
| 837 | TP_ARGS(ip, offset, count), \ | ||
| 838 | TP_STRUCT__entry( \ | ||
| 839 | __field(dev_t, dev) \ | ||
| 840 | __field(xfs_ino_t, ino) \ | ||
| 841 | __field(loff_t, size) \ | ||
| 842 | __field(loff_t, new_size) \ | ||
| 843 | __field(loff_t, offset) \ | ||
| 844 | __field(size_t, count) \ | ||
| 845 | ), \ | ||
| 846 | TP_fast_assign( \ | ||
| 847 | __entry->dev = VFS_I(ip)->i_sb->s_dev; \ | ||
| 848 | __entry->ino = ip->i_ino; \ | ||
| 849 | __entry->size = ip->i_d.di_size; \ | ||
| 850 | __entry->new_size = ip->i_new_size; \ | ||
| 851 | __entry->offset = offset; \ | ||
| 852 | __entry->count = count; \ | ||
| 853 | ), \ | ||
| 854 | TP_printk("dev %d:%d ino 0x%llx size 0x%llx new_size 0x%llx " \ | ||
| 855 | "offset 0x%llx count %zd", \ | ||
| 856 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 857 | __entry->ino, \ | ||
| 858 | __entry->size, \ | ||
| 859 | __entry->new_size, \ | ||
| 860 | __entry->offset, \ | ||
| 861 | __entry->count) \ | ||
| 862 | ); | ||
| 863 | DEFINE_SIMPLE_IO_EVENT(xfs_delalloc_enospc); | ||
| 864 | DEFINE_SIMPLE_IO_EVENT(xfs_unwritten_convert); | ||
| 865 | |||
| 866 | |||
| 867 | TRACE_EVENT(xfs_itruncate_start, | ||
| 868 | TP_PROTO(struct xfs_inode *ip, xfs_fsize_t new_size, int flag, | ||
| 869 | xfs_off_t toss_start, xfs_off_t toss_finish), | ||
| 870 | TP_ARGS(ip, new_size, flag, toss_start, toss_finish), | ||
| 871 | TP_STRUCT__entry( | ||
| 872 | __field(dev_t, dev) | ||
| 873 | __field(xfs_ino_t, ino) | ||
| 874 | __field(xfs_fsize_t, size) | ||
| 875 | __field(xfs_fsize_t, new_size) | ||
| 876 | __field(xfs_off_t, toss_start) | ||
| 877 | __field(xfs_off_t, toss_finish) | ||
| 878 | __field(int, flag) | ||
| 879 | ), | ||
| 880 | TP_fast_assign( | ||
| 881 | __entry->dev = VFS_I(ip)->i_sb->s_dev; | ||
| 882 | __entry->ino = ip->i_ino; | ||
| 883 | __entry->size = ip->i_d.di_size; | ||
| 884 | __entry->new_size = new_size; | ||
| 885 | __entry->toss_start = toss_start; | ||
| 886 | __entry->toss_finish = toss_finish; | ||
| 887 | __entry->flag = flag; | ||
| 888 | ), | ||
| 889 | TP_printk("dev %d:%d ino 0x%llx %s size 0x%llx new_size 0x%llx " | ||
| 890 | "toss start 0x%llx toss finish 0x%llx", | ||
| 891 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
| 892 | __entry->ino, | ||
| 893 | __print_flags(__entry->flag, "|", XFS_ITRUNC_FLAGS), | ||
| 894 | __entry->size, | ||
| 895 | __entry->new_size, | ||
| 896 | __entry->toss_start, | ||
| 897 | __entry->toss_finish) | ||
| 898 | ); | ||
| 899 | |||
| 900 | #define DEFINE_ITRUNC_EVENT(name) \ | ||
| 901 | TRACE_EVENT(name, \ | ||
| 902 | TP_PROTO(struct xfs_inode *ip, xfs_fsize_t new_size), \ | ||
| 903 | TP_ARGS(ip, new_size), \ | ||
| 904 | TP_STRUCT__entry( \ | ||
| 905 | __field(dev_t, dev) \ | ||
| 906 | __field(xfs_ino_t, ino) \ | ||
| 907 | __field(xfs_fsize_t, size) \ | ||
| 908 | __field(xfs_fsize_t, new_size) \ | ||
| 909 | ), \ | ||
| 910 | TP_fast_assign( \ | ||
| 911 | __entry->dev = VFS_I(ip)->i_sb->s_dev; \ | ||
| 912 | __entry->ino = ip->i_ino; \ | ||
| 913 | __entry->size = ip->i_d.di_size; \ | ||
| 914 | __entry->new_size = new_size; \ | ||
| 915 | ), \ | ||
| 916 | TP_printk("dev %d:%d ino 0x%llx size 0x%llx new_size 0x%llx", \ | ||
| 917 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 918 | __entry->ino, \ | ||
| 919 | __entry->size, \ | ||
| 920 | __entry->new_size) \ | ||
| 921 | ) | ||
| 922 | DEFINE_ITRUNC_EVENT(xfs_itruncate_finish_start); | ||
| 923 | DEFINE_ITRUNC_EVENT(xfs_itruncate_finish_end); | ||
| 924 | |||
| 925 | TRACE_EVENT(xfs_pagecache_inval, | ||
| 926 | TP_PROTO(struct xfs_inode *ip, xfs_off_t start, xfs_off_t finish), | ||
| 927 | TP_ARGS(ip, start, finish), | ||
| 928 | TP_STRUCT__entry( | ||
| 929 | __field(dev_t, dev) | ||
| 930 | __field(xfs_ino_t, ino) | ||
| 931 | __field(xfs_fsize_t, size) | ||
| 932 | __field(xfs_off_t, start) | ||
| 933 | __field(xfs_off_t, finish) | ||
| 934 | ), | ||
| 935 | TP_fast_assign( | ||
| 936 | __entry->dev = VFS_I(ip)->i_sb->s_dev; | ||
| 937 | __entry->ino = ip->i_ino; | ||
| 938 | __entry->size = ip->i_d.di_size; | ||
| 939 | __entry->start = start; | ||
| 940 | __entry->finish = finish; | ||
| 941 | ), | ||
| 942 | TP_printk("dev %d:%d ino 0x%llx size 0x%llx start 0x%llx finish 0x%llx", | ||
| 943 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
| 944 | __entry->ino, | ||
| 945 | __entry->size, | ||
| 946 | __entry->start, | ||
| 947 | __entry->finish) | ||
| 948 | ); | ||
| 949 | |||
| 950 | TRACE_EVENT(xfs_bunmap, | ||
| 951 | TP_PROTO(struct xfs_inode *ip, xfs_fileoff_t bno, xfs_filblks_t len, | ||
| 952 | int flags, unsigned long caller_ip), | ||
| 953 | TP_ARGS(ip, bno, len, flags, caller_ip), | ||
| 954 | TP_STRUCT__entry( | ||
| 955 | __field(dev_t, dev) | ||
| 956 | __field(xfs_ino_t, ino) | ||
| 957 | __field(xfs_fsize_t, size) | ||
| 958 | __field(xfs_fileoff_t, bno) | ||
| 959 | __field(xfs_filblks_t, len) | ||
| 960 | __field(unsigned long, caller_ip) | ||
| 961 | __field(int, flags) | ||
| 962 | ), | ||
| 963 | TP_fast_assign( | ||
| 964 | __entry->dev = VFS_I(ip)->i_sb->s_dev; | ||
| 965 | __entry->ino = ip->i_ino; | ||
| 966 | __entry->size = ip->i_d.di_size; | ||
| 967 | __entry->bno = bno; | ||
| 968 | __entry->len = len; | ||
| 969 | __entry->caller_ip = caller_ip; | ||
| 970 | __entry->flags = flags; | ||
| 971 | ), | ||
| 972 | TP_printk("dev %d:%d ino 0x%llx size 0x%llx bno 0x%llx len 0x%llx" | ||
| 973 | "flags %s caller %pf", | ||
| 974 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
| 975 | __entry->ino, | ||
| 976 | __entry->size, | ||
| 977 | __entry->bno, | ||
| 978 | __entry->len, | ||
| 979 | __print_flags(__entry->flags, "|", XFS_BMAPI_FLAGS), | ||
| 980 | (void *)__entry->caller_ip) | ||
| 981 | |||
| 982 | ); | ||
| 983 | |||
| 984 | TRACE_EVENT(xfs_alloc_busy, | ||
| 985 | TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno, | ||
| 986 | xfs_extlen_t len, int slot), | ||
| 987 | TP_ARGS(mp, agno, agbno, len, slot), | ||
| 988 | TP_STRUCT__entry( | ||
| 989 | __field(dev_t, dev) | ||
| 990 | __field(xfs_agnumber_t, agno) | ||
| 991 | __field(xfs_agblock_t, agbno) | ||
| 992 | __field(xfs_extlen_t, len) | ||
| 993 | __field(int, slot) | ||
| 994 | ), | ||
| 995 | TP_fast_assign( | ||
| 996 | __entry->dev = mp->m_super->s_dev; | ||
| 997 | __entry->agno = agno; | ||
| 998 | __entry->agbno = agbno; | ||
| 999 | __entry->len = len; | ||
| 1000 | __entry->slot = slot; | ||
| 1001 | ), | ||
| 1002 | TP_printk("dev %d:%d agno %u agbno %u len %u slot %d", | ||
| 1003 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
| 1004 | __entry->agno, | ||
| 1005 | __entry->agbno, | ||
| 1006 | __entry->len, | ||
| 1007 | __entry->slot) | ||
| 1008 | |||
| 1009 | ); | ||
| 1010 | |||
| 1011 | #define XFS_BUSY_STATES \ | ||
| 1012 | { 0, "found" }, \ | ||
| 1013 | { 1, "missing" } | ||
| 1014 | |||
| 1015 | TRACE_EVENT(xfs_alloc_unbusy, | ||
| 1016 | TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, | ||
| 1017 | int slot, int found), | ||
| 1018 | TP_ARGS(mp, agno, slot, found), | ||
| 1019 | TP_STRUCT__entry( | ||
| 1020 | __field(dev_t, dev) | ||
| 1021 | __field(xfs_agnumber_t, agno) | ||
| 1022 | __field(int, slot) | ||
| 1023 | __field(int, found) | ||
| 1024 | ), | ||
| 1025 | TP_fast_assign( | ||
| 1026 | __entry->dev = mp->m_super->s_dev; | ||
| 1027 | __entry->agno = agno; | ||
| 1028 | __entry->slot = slot; | ||
| 1029 | __entry->found = found; | ||
| 1030 | ), | ||
| 1031 | TP_printk("dev %d:%d agno %u slot %d %s", | ||
| 1032 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
| 1033 | __entry->agno, | ||
| 1034 | __entry->slot, | ||
| 1035 | __print_symbolic(__entry->found, XFS_BUSY_STATES)) | ||
| 1036 | ); | ||
| 1037 | |||
| 1038 | TRACE_EVENT(xfs_alloc_busysearch, | ||
| 1039 | TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno, | ||
| 1040 | xfs_extlen_t len, int found), | ||
| 1041 | TP_ARGS(mp, agno, agbno, len, found), | ||
| 1042 | TP_STRUCT__entry( | ||
| 1043 | __field(dev_t, dev) | ||
| 1044 | __field(xfs_agnumber_t, agno) | ||
| 1045 | __field(xfs_agblock_t, agbno) | ||
| 1046 | __field(xfs_extlen_t, len) | ||
| 1047 | __field(int, found) | ||
| 1048 | ), | ||
| 1049 | TP_fast_assign( | ||
| 1050 | __entry->dev = mp->m_super->s_dev; | ||
| 1051 | __entry->agno = agno; | ||
| 1052 | __entry->agbno = agbno; | ||
| 1053 | __entry->len = len; | ||
| 1054 | __entry->found = found; | ||
| 1055 | ), | ||
| 1056 | TP_printk("dev %d:%d agno %u agbno %u len %u %s", | ||
| 1057 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
| 1058 | __entry->agno, | ||
| 1059 | __entry->agbno, | ||
| 1060 | __entry->len, | ||
| 1061 | __print_symbolic(__entry->found, XFS_BUSY_STATES)) | ||
| 1062 | ); | ||
| 1063 | |||
| 1064 | TRACE_EVENT(xfs_agf, | ||
| 1065 | TP_PROTO(struct xfs_mount *mp, struct xfs_agf *agf, int flags, | ||
| 1066 | unsigned long caller_ip), | ||
| 1067 | TP_ARGS(mp, agf, flags, caller_ip), | ||
| 1068 | TP_STRUCT__entry( | ||
| 1069 | __field(dev_t, dev) | ||
| 1070 | __field(xfs_agnumber_t, agno) | ||
| 1071 | __field(int, flags) | ||
| 1072 | __field(__u32, length) | ||
| 1073 | __field(__u32, bno_root) | ||
| 1074 | __field(__u32, cnt_root) | ||
| 1075 | __field(__u32, bno_level) | ||
| 1076 | __field(__u32, cnt_level) | ||
| 1077 | __field(__u32, flfirst) | ||
| 1078 | __field(__u32, fllast) | ||
| 1079 | __field(__u32, flcount) | ||
| 1080 | __field(__u32, freeblks) | ||
| 1081 | __field(__u32, longest) | ||
| 1082 | __field(unsigned long, caller_ip) | ||
| 1083 | ), | ||
| 1084 | TP_fast_assign( | ||
| 1085 | __entry->dev = mp->m_super->s_dev; | ||
| 1086 | __entry->agno = be32_to_cpu(agf->agf_seqno), | ||
| 1087 | __entry->flags = flags; | ||
| 1088 | __entry->length = be32_to_cpu(agf->agf_length), | ||
| 1089 | __entry->bno_root = be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]), | ||
| 1090 | __entry->cnt_root = be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]), | ||
| 1091 | __entry->bno_level = | ||
| 1092 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]), | ||
| 1093 | __entry->cnt_level = | ||
| 1094 | be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]), | ||
| 1095 | __entry->flfirst = be32_to_cpu(agf->agf_flfirst), | ||
| 1096 | __entry->fllast = be32_to_cpu(agf->agf_fllast), | ||
| 1097 | __entry->flcount = be32_to_cpu(agf->agf_flcount), | ||
| 1098 | __entry->freeblks = be32_to_cpu(agf->agf_freeblks), | ||
| 1099 | __entry->longest = be32_to_cpu(agf->agf_longest); | ||
| 1100 | __entry->caller_ip = caller_ip; | ||
| 1101 | ), | ||
| 1102 | TP_printk("dev %d:%d agno %u flags %s length %u roots b %u c %u " | ||
| 1103 | "levels b %u c %u flfirst %u fllast %u flcount %u " | ||
| 1104 | "freeblks %u longest %u caller %pf", | ||
| 1105 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
| 1106 | __entry->agno, | ||
| 1107 | __print_flags(__entry->flags, "|", XFS_AGF_FLAGS), | ||
| 1108 | __entry->length, | ||
| 1109 | __entry->bno_root, | ||
| 1110 | __entry->cnt_root, | ||
| 1111 | __entry->bno_level, | ||
| 1112 | __entry->cnt_level, | ||
| 1113 | __entry->flfirst, | ||
| 1114 | __entry->fllast, | ||
| 1115 | __entry->flcount, | ||
| 1116 | __entry->freeblks, | ||
| 1117 | __entry->longest, | ||
| 1118 | (void *)__entry->caller_ip) | ||
| 1119 | ); | ||
| 1120 | |||
| 1121 | TRACE_EVENT(xfs_free_extent, | ||
| 1122 | TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_agblock_t agbno, | ||
| 1123 | xfs_extlen_t len, bool isfl, int haveleft, int haveright), | ||
| 1124 | TP_ARGS(mp, agno, agbno, len, isfl, haveleft, haveright), | ||
| 1125 | TP_STRUCT__entry( | ||
| 1126 | __field(dev_t, dev) | ||
| 1127 | __field(xfs_agnumber_t, agno) | ||
| 1128 | __field(xfs_agblock_t, agbno) | ||
| 1129 | __field(xfs_extlen_t, len) | ||
| 1130 | __field(int, isfl) | ||
| 1131 | __field(int, haveleft) | ||
| 1132 | __field(int, haveright) | ||
| 1133 | ), | ||
| 1134 | TP_fast_assign( | ||
| 1135 | __entry->dev = mp->m_super->s_dev; | ||
| 1136 | __entry->agno = agno; | ||
| 1137 | __entry->agbno = agbno; | ||
| 1138 | __entry->len = len; | ||
| 1139 | __entry->isfl = isfl; | ||
| 1140 | __entry->haveleft = haveleft; | ||
| 1141 | __entry->haveright = haveright; | ||
| 1142 | ), | ||
| 1143 | TP_printk("dev %d:%d agno %u agbno %u len %u isfl %d %s", | ||
| 1144 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
| 1145 | __entry->agno, | ||
| 1146 | __entry->agbno, | ||
| 1147 | __entry->len, | ||
| 1148 | __entry->isfl, | ||
| 1149 | __entry->haveleft ? | ||
| 1150 | (__entry->haveright ? "both" : "left") : | ||
| 1151 | (__entry->haveright ? "right" : "none")) | ||
| 1152 | |||
| 1153 | ); | ||
| 1154 | |||
| 1155 | #define DEFINE_ALLOC_EVENT(name) \ | ||
| 1156 | TRACE_EVENT(name, \ | ||
| 1157 | TP_PROTO(struct xfs_alloc_arg *args), \ | ||
| 1158 | TP_ARGS(args), \ | ||
| 1159 | TP_STRUCT__entry( \ | ||
| 1160 | __field(dev_t, dev) \ | ||
| 1161 | __field(xfs_agnumber_t, agno) \ | ||
| 1162 | __field(xfs_agblock_t, agbno) \ | ||
| 1163 | __field(xfs_extlen_t, minlen) \ | ||
| 1164 | __field(xfs_extlen_t, maxlen) \ | ||
| 1165 | __field(xfs_extlen_t, mod) \ | ||
| 1166 | __field(xfs_extlen_t, prod) \ | ||
| 1167 | __field(xfs_extlen_t, minleft) \ | ||
| 1168 | __field(xfs_extlen_t, total) \ | ||
| 1169 | __field(xfs_extlen_t, alignment) \ | ||
| 1170 | __field(xfs_extlen_t, minalignslop) \ | ||
| 1171 | __field(xfs_extlen_t, len) \ | ||
| 1172 | __field(short, type) \ | ||
| 1173 | __field(short, otype) \ | ||
| 1174 | __field(char, wasdel) \ | ||
| 1175 | __field(char, wasfromfl) \ | ||
| 1176 | __field(char, isfl) \ | ||
| 1177 | __field(char, userdata) \ | ||
| 1178 | __field(xfs_fsblock_t, firstblock) \ | ||
| 1179 | ), \ | ||
| 1180 | TP_fast_assign( \ | ||
| 1181 | __entry->dev = args->mp->m_super->s_dev; \ | ||
| 1182 | __entry->agno = args->agno; \ | ||
| 1183 | __entry->agbno = args->agbno; \ | ||
| 1184 | __entry->minlen = args->minlen; \ | ||
| 1185 | __entry->maxlen = args->maxlen; \ | ||
| 1186 | __entry->mod = args->mod; \ | ||
| 1187 | __entry->prod = args->prod; \ | ||
| 1188 | __entry->minleft = args->minleft; \ | ||
| 1189 | __entry->total = args->total; \ | ||
| 1190 | __entry->alignment = args->alignment; \ | ||
| 1191 | __entry->minalignslop = args->minalignslop; \ | ||
| 1192 | __entry->len = args->len; \ | ||
| 1193 | __entry->type = args->type; \ | ||
| 1194 | __entry->otype = args->otype; \ | ||
| 1195 | __entry->wasdel = args->wasdel; \ | ||
| 1196 | __entry->wasfromfl = args->wasfromfl; \ | ||
| 1197 | __entry->isfl = args->isfl; \ | ||
| 1198 | __entry->userdata = args->userdata; \ | ||
| 1199 | __entry->firstblock = args->firstblock; \ | ||
| 1200 | ), \ | ||
| 1201 | TP_printk("dev %d:%d agno %u agbno %u minlen %u maxlen %u mod %u " \ | ||
| 1202 | "prod %u minleft %u total %u alignment %u minalignslop %u " \ | ||
| 1203 | "len %u type %s otype %s wasdel %d wasfromfl %d isfl %d " \ | ||
| 1204 | "userdata %d firstblock 0x%llx", \ | ||
| 1205 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 1206 | __entry->agno, \ | ||
| 1207 | __entry->agbno, \ | ||
| 1208 | __entry->minlen, \ | ||
| 1209 | __entry->maxlen, \ | ||
| 1210 | __entry->mod, \ | ||
| 1211 | __entry->prod, \ | ||
| 1212 | __entry->minleft, \ | ||
| 1213 | __entry->total, \ | ||
| 1214 | __entry->alignment, \ | ||
| 1215 | __entry->minalignslop, \ | ||
| 1216 | __entry->len, \ | ||
| 1217 | __print_symbolic(__entry->type, XFS_ALLOC_TYPES), \ | ||
| 1218 | __print_symbolic(__entry->otype, XFS_ALLOC_TYPES), \ | ||
| 1219 | __entry->wasdel, \ | ||
| 1220 | __entry->wasfromfl, \ | ||
| 1221 | __entry->isfl, \ | ||
| 1222 | __entry->userdata, \ | ||
| 1223 | __entry->firstblock) \ | ||
| 1224 | ) | ||
| 1225 | |||
| 1226 | DEFINE_ALLOC_EVENT(xfs_alloc_exact_done); | ||
| 1227 | DEFINE_ALLOC_EVENT(xfs_alloc_exact_error); | ||
| 1228 | DEFINE_ALLOC_EVENT(xfs_alloc_near_nominleft); | ||
| 1229 | DEFINE_ALLOC_EVENT(xfs_alloc_near_first); | ||
| 1230 | DEFINE_ALLOC_EVENT(xfs_alloc_near_greater); | ||
| 1231 | DEFINE_ALLOC_EVENT(xfs_alloc_near_lesser); | ||
| 1232 | DEFINE_ALLOC_EVENT(xfs_alloc_near_error); | ||
| 1233 | DEFINE_ALLOC_EVENT(xfs_alloc_size_neither); | ||
| 1234 | DEFINE_ALLOC_EVENT(xfs_alloc_size_noentry); | ||
| 1235 | DEFINE_ALLOC_EVENT(xfs_alloc_size_nominleft); | ||
| 1236 | DEFINE_ALLOC_EVENT(xfs_alloc_size_done); | ||
| 1237 | DEFINE_ALLOC_EVENT(xfs_alloc_size_error); | ||
| 1238 | DEFINE_ALLOC_EVENT(xfs_alloc_small_freelist); | ||
| 1239 | DEFINE_ALLOC_EVENT(xfs_alloc_small_notenough); | ||
| 1240 | DEFINE_ALLOC_EVENT(xfs_alloc_small_done); | ||
| 1241 | DEFINE_ALLOC_EVENT(xfs_alloc_small_error); | ||
| 1242 | DEFINE_ALLOC_EVENT(xfs_alloc_vextent_badargs); | ||
| 1243 | DEFINE_ALLOC_EVENT(xfs_alloc_vextent_nofix); | ||
| 1244 | DEFINE_ALLOC_EVENT(xfs_alloc_vextent_noagbp); | ||
| 1245 | DEFINE_ALLOC_EVENT(xfs_alloc_vextent_loopfailed); | ||
| 1246 | DEFINE_ALLOC_EVENT(xfs_alloc_vextent_allfailed); | ||
| 1247 | |||
| 1248 | #define DEFINE_DIR2_TRACE(tname) \ | ||
| 1249 | TRACE_EVENT(tname, \ | ||
| 1250 | TP_PROTO(struct xfs_da_args *args), \ | ||
| 1251 | TP_ARGS(args), \ | ||
| 1252 | TP_STRUCT__entry( \ | ||
| 1253 | __field(dev_t, dev) \ | ||
| 1254 | __field(xfs_ino_t, ino) \ | ||
| 1255 | __dynamic_array(char, name, args->namelen) \ | ||
| 1256 | __field(int, namelen) \ | ||
| 1257 | __field(xfs_dahash_t, hashval) \ | ||
| 1258 | __field(xfs_ino_t, inumber) \ | ||
| 1259 | __field(int, op_flags) \ | ||
| 1260 | ), \ | ||
| 1261 | TP_fast_assign( \ | ||
| 1262 | __entry->dev = VFS_I(args->dp)->i_sb->s_dev; \ | ||
| 1263 | __entry->ino = args->dp->i_ino; \ | ||
| 1264 | if (args->namelen) \ | ||
| 1265 | memcpy(__get_str(name), args->name, args->namelen); \ | ||
| 1266 | __entry->namelen = args->namelen; \ | ||
| 1267 | __entry->hashval = args->hashval; \ | ||
| 1268 | __entry->inumber = args->inumber; \ | ||
| 1269 | __entry->op_flags = args->op_flags; \ | ||
| 1270 | ), \ | ||
| 1271 | TP_printk("dev %d:%d ino 0x%llx name %.*s namelen %d hashval 0x%x " \ | ||
| 1272 | "inumber 0x%llx op_flags %s", \ | ||
| 1273 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 1274 | __entry->ino, \ | ||
| 1275 | __entry->namelen, \ | ||
| 1276 | __entry->namelen ? __get_str(name) : NULL, \ | ||
| 1277 | __entry->namelen, \ | ||
| 1278 | __entry->hashval, \ | ||
| 1279 | __entry->inumber, \ | ||
| 1280 | __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS)) \ | ||
| 1281 | ) | ||
| 1282 | DEFINE_DIR2_TRACE(xfs_dir2_sf_addname); | ||
| 1283 | DEFINE_DIR2_TRACE(xfs_dir2_sf_create); | ||
| 1284 | DEFINE_DIR2_TRACE(xfs_dir2_sf_lookup); | ||
| 1285 | DEFINE_DIR2_TRACE(xfs_dir2_sf_replace); | ||
| 1286 | DEFINE_DIR2_TRACE(xfs_dir2_sf_removename); | ||
| 1287 | DEFINE_DIR2_TRACE(xfs_dir2_sf_toino4); | ||
| 1288 | DEFINE_DIR2_TRACE(xfs_dir2_sf_toino8); | ||
| 1289 | DEFINE_DIR2_TRACE(xfs_dir2_sf_to_block); | ||
| 1290 | DEFINE_DIR2_TRACE(xfs_dir2_block_addname); | ||
| 1291 | DEFINE_DIR2_TRACE(xfs_dir2_block_lookup); | ||
| 1292 | DEFINE_DIR2_TRACE(xfs_dir2_block_replace); | ||
| 1293 | DEFINE_DIR2_TRACE(xfs_dir2_block_removename); | ||
| 1294 | DEFINE_DIR2_TRACE(xfs_dir2_block_to_sf); | ||
| 1295 | DEFINE_DIR2_TRACE(xfs_dir2_block_to_leaf); | ||
| 1296 | DEFINE_DIR2_TRACE(xfs_dir2_leaf_addname); | ||
| 1297 | DEFINE_DIR2_TRACE(xfs_dir2_leaf_lookup); | ||
| 1298 | DEFINE_DIR2_TRACE(xfs_dir2_leaf_replace); | ||
| 1299 | DEFINE_DIR2_TRACE(xfs_dir2_leaf_removename); | ||
| 1300 | DEFINE_DIR2_TRACE(xfs_dir2_leaf_to_block); | ||
| 1301 | DEFINE_DIR2_TRACE(xfs_dir2_leaf_to_node); | ||
| 1302 | DEFINE_DIR2_TRACE(xfs_dir2_node_addname); | ||
| 1303 | DEFINE_DIR2_TRACE(xfs_dir2_node_lookup); | ||
| 1304 | DEFINE_DIR2_TRACE(xfs_dir2_node_replace); | ||
| 1305 | DEFINE_DIR2_TRACE(xfs_dir2_node_removename); | ||
| 1306 | DEFINE_DIR2_TRACE(xfs_dir2_node_to_leaf); | ||
| 1307 | |||
| 1308 | #define DEFINE_DIR2_SPACE_TRACE(tname) \ | ||
| 1309 | TRACE_EVENT(tname, \ | ||
| 1310 | TP_PROTO(struct xfs_da_args *args, int idx), \ | ||
| 1311 | TP_ARGS(args, idx), \ | ||
| 1312 | TP_STRUCT__entry( \ | ||
| 1313 | __field(dev_t, dev) \ | ||
| 1314 | __field(xfs_ino_t, ino) \ | ||
| 1315 | __field(int, op_flags) \ | ||
| 1316 | __field(int, idx) \ | ||
| 1317 | ), \ | ||
| 1318 | TP_fast_assign( \ | ||
| 1319 | __entry->dev = VFS_I(args->dp)->i_sb->s_dev; \ | ||
| 1320 | __entry->ino = args->dp->i_ino; \ | ||
| 1321 | __entry->op_flags = args->op_flags; \ | ||
| 1322 | __entry->idx = idx; \ | ||
| 1323 | ), \ | ||
| 1324 | TP_printk("dev %d:%d ino 0x%llx op_flags %s index %d", \ | ||
| 1325 | MAJOR(__entry->dev), MINOR(__entry->dev), \ | ||
| 1326 | __entry->ino, \ | ||
| 1327 | __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS), \ | ||
| 1328 | __entry->idx) \ | ||
| 1329 | ) | ||
| 1330 | DEFINE_DIR2_SPACE_TRACE(xfs_dir2_leafn_add); | ||
| 1331 | DEFINE_DIR2_SPACE_TRACE(xfs_dir2_leafn_remove); | ||
| 1332 | DEFINE_DIR2_SPACE_TRACE(xfs_dir2_grow_inode); | ||
| 1333 | DEFINE_DIR2_SPACE_TRACE(xfs_dir2_shrink_inode); | ||
| 1334 | |||
| 1335 | TRACE_EVENT(xfs_dir2_leafn_moveents, | ||
| 1336 | TP_PROTO(struct xfs_da_args *args, int src_idx, int dst_idx, int count), | ||
| 1337 | TP_ARGS(args, src_idx, dst_idx, count), | ||
| 1338 | TP_STRUCT__entry( | ||
| 1339 | __field(dev_t, dev) | ||
| 1340 | __field(xfs_ino_t, ino) | ||
| 1341 | __field(int, op_flags) | ||
| 1342 | __field(int, src_idx) | ||
| 1343 | __field(int, dst_idx) | ||
| 1344 | __field(int, count) | ||
| 1345 | ), | ||
| 1346 | TP_fast_assign( | ||
| 1347 | __entry->dev = VFS_I(args->dp)->i_sb->s_dev; | ||
| 1348 | __entry->ino = args->dp->i_ino; | ||
| 1349 | __entry->op_flags = args->op_flags; | ||
| 1350 | __entry->src_idx = src_idx; | ||
| 1351 | __entry->dst_idx = dst_idx; | ||
| 1352 | __entry->count = count; | ||
| 1353 | ), | ||
| 1354 | TP_printk("dev %d:%d ino 0x%llx op_flags %s " | ||
| 1355 | "src_idx %d dst_idx %d count %d", | ||
| 1356 | MAJOR(__entry->dev), MINOR(__entry->dev), | ||
| 1357 | __entry->ino, | ||
| 1358 | __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS), | ||
| 1359 | __entry->src_idx, | ||
| 1360 | __entry->dst_idx, | ||
| 1361 | __entry->count) | ||
| 1362 | ); | ||
| 1363 | |||
| 1364 | #endif /* _TRACE_XFS_H */ | ||
| 1365 | |||
| 1366 | #undef TRACE_INCLUDE_PATH | ||
| 1367 | #define TRACE_INCLUDE_PATH . | ||
| 1368 | #define TRACE_INCLUDE_FILE xfs_trace | ||
| 1369 | #include <trace/define_trace.h> | ||
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h index 00cabf5354d2..7c220b4227bc 100644 --- a/fs/xfs/linux-2.6/xfs_vnode.h +++ b/fs/xfs/linux-2.6/xfs_vnode.h | |||
| @@ -39,6 +39,10 @@ struct attrlist_cursor_kern; | |||
| 39 | #define IO_ISDIRECT 0x00004 /* bypass page cache */ | 39 | #define IO_ISDIRECT 0x00004 /* bypass page cache */ |
| 40 | #define IO_INVIS 0x00020 /* don't update inode timestamps */ | 40 | #define IO_INVIS 0x00020 /* don't update inode timestamps */ |
| 41 | 41 | ||
| 42 | #define XFS_IO_FLAGS \ | ||
| 43 | { IO_ISDIRECT, "DIRECT" }, \ | ||
| 44 | { IO_INVIS, "INVIS"} | ||
| 45 | |||
| 42 | /* | 46 | /* |
| 43 | * Flush/Invalidate options for vop_toss/flush/flushinval_pages. | 47 | * Flush/Invalidate options for vop_toss/flush/flushinval_pages. |
| 44 | */ | 48 | */ |
diff --git a/fs/xfs/linux-2.6/xfs_xattr.c b/fs/xfs/linux-2.6/xfs_xattr.c index 497c7fb75cc1..0b1878857fc3 100644 --- a/fs/xfs/linux-2.6/xfs_xattr.c +++ b/fs/xfs/linux-2.6/xfs_xattr.c | |||
| @@ -30,10 +30,10 @@ | |||
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | static int | 32 | static int |
| 33 | __xfs_xattr_get(struct inode *inode, const char *name, | 33 | xfs_xattr_get(struct dentry *dentry, const char *name, |
| 34 | void *value, size_t size, int xflags) | 34 | void *value, size_t size, int xflags) |
| 35 | { | 35 | { |
| 36 | struct xfs_inode *ip = XFS_I(inode); | 36 | struct xfs_inode *ip = XFS_I(dentry->d_inode); |
| 37 | int error, asize = size; | 37 | int error, asize = size; |
| 38 | 38 | ||
| 39 | if (strcmp(name, "") == 0) | 39 | if (strcmp(name, "") == 0) |
| @@ -52,10 +52,10 @@ __xfs_xattr_get(struct inode *inode, const char *name, | |||
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | static int | 54 | static int |
| 55 | __xfs_xattr_set(struct inode *inode, const char *name, const void *value, | 55 | xfs_xattr_set(struct dentry *dentry, const char *name, const void *value, |
| 56 | size_t size, int flags, int xflags) | 56 | size_t size, int flags, int xflags) |
| 57 | { | 57 | { |
| 58 | struct xfs_inode *ip = XFS_I(inode); | 58 | struct xfs_inode *ip = XFS_I(dentry->d_inode); |
| 59 | 59 | ||
| 60 | if (strcmp(name, "") == 0) | 60 | if (strcmp(name, "") == 0) |
| 61 | return -EINVAL; | 61 | return -EINVAL; |
| @@ -71,75 +71,34 @@ __xfs_xattr_set(struct inode *inode, const char *name, const void *value, | |||
| 71 | return -xfs_attr_set(ip, name, (void *)value, size, xflags); | 71 | return -xfs_attr_set(ip, name, (void *)value, size, xflags); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | static int | ||
| 75 | xfs_xattr_user_get(struct inode *inode, const char *name, | ||
| 76 | void *value, size_t size) | ||
| 77 | { | ||
| 78 | return __xfs_xattr_get(inode, name, value, size, 0); | ||
| 79 | } | ||
| 80 | |||
| 81 | static int | ||
| 82 | xfs_xattr_user_set(struct inode *inode, const char *name, | ||
| 83 | const void *value, size_t size, int flags) | ||
| 84 | { | ||
| 85 | return __xfs_xattr_set(inode, name, value, size, flags, 0); | ||
| 86 | } | ||
| 87 | |||
| 88 | static struct xattr_handler xfs_xattr_user_handler = { | 74 | static struct xattr_handler xfs_xattr_user_handler = { |
| 89 | .prefix = XATTR_USER_PREFIX, | 75 | .prefix = XATTR_USER_PREFIX, |
| 90 | .get = xfs_xattr_user_get, | 76 | .flags = 0, /* no flags implies user namespace */ |
| 91 | .set = xfs_xattr_user_set, | 77 | .get = xfs_xattr_get, |
| 78 | .set = xfs_xattr_set, | ||
| 92 | }; | 79 | }; |
| 93 | 80 | ||
| 94 | |||
| 95 | static int | ||
| 96 | xfs_xattr_trusted_get(struct inode *inode, const char *name, | ||
| 97 | void *value, size_t size) | ||
| 98 | { | ||
| 99 | return __xfs_xattr_get(inode, name, value, size, ATTR_ROOT); | ||
| 100 | } | ||
| 101 | |||
| 102 | static int | ||
| 103 | xfs_xattr_trusted_set(struct inode *inode, const char *name, | ||
| 104 | const void *value, size_t size, int flags) | ||
| 105 | { | ||
| 106 | return __xfs_xattr_set(inode, name, value, size, flags, ATTR_ROOT); | ||
| 107 | } | ||
| 108 | |||
| 109 | static struct xattr_handler xfs_xattr_trusted_handler = { | 81 | static struct xattr_handler xfs_xattr_trusted_handler = { |
| 110 | .prefix = XATTR_TRUSTED_PREFIX, | 82 | .prefix = XATTR_TRUSTED_PREFIX, |
| 111 | .get = xfs_xattr_trusted_get, | 83 | .flags = ATTR_ROOT, |
| 112 | .set = xfs_xattr_trusted_set, | 84 | .get = xfs_xattr_get, |
| 85 | .set = xfs_xattr_set, | ||
| 113 | }; | 86 | }; |
| 114 | 87 | ||
| 115 | |||
| 116 | static int | ||
| 117 | xfs_xattr_secure_get(struct inode *inode, const char *name, | ||
| 118 | void *value, size_t size) | ||
| 119 | { | ||
| 120 | return __xfs_xattr_get(inode, name, value, size, ATTR_SECURE); | ||
| 121 | } | ||
| 122 | |||
| 123 | static int | ||
| 124 | xfs_xattr_secure_set(struct inode *inode, const char *name, | ||
| 125 | const void *value, size_t size, int flags) | ||
| 126 | { | ||
| 127 | return __xfs_xattr_set(inode, name, value, size, flags, ATTR_SECURE); | ||
| 128 | } | ||
| 129 | |||
| 130 | static struct xattr_handler xfs_xattr_security_handler = { | 88 | static struct xattr_handler xfs_xattr_security_handler = { |
| 131 | .prefix = XATTR_SECURITY_PREFIX, | 89 | .prefix = XATTR_SECURITY_PREFIX, |
| 132 | .get = xfs_xattr_secure_get, | 90 | .flags = ATTR_SECURE, |
| 133 | .set = xfs_xattr_secure_set, | 91 | .get = xfs_xattr_get, |
| 92 | .set = xfs_xattr_set, | ||
| 134 | }; | 93 | }; |
| 135 | 94 | ||
| 136 | |||
| 137 | struct xattr_handler *xfs_xattr_handlers[] = { | 95 | struct xattr_handler *xfs_xattr_handlers[] = { |
| 138 | &xfs_xattr_user_handler, | 96 | &xfs_xattr_user_handler, |
| 139 | &xfs_xattr_trusted_handler, | 97 | &xfs_xattr_trusted_handler, |
| 140 | &xfs_xattr_security_handler, | 98 | &xfs_xattr_security_handler, |
| 141 | #ifdef CONFIG_XFS_POSIX_ACL | 99 | #ifdef CONFIG_XFS_POSIX_ACL |
| 142 | &xfs_xattr_system_handler, | 100 | &xfs_xattr_acl_access_handler, |
| 101 | &xfs_xattr_acl_default_handler, | ||
| 143 | #endif | 102 | #endif |
| 144 | NULL | 103 | NULL |
| 145 | }; | 104 | }; |
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c index 2f3f2229eaaf..d7c7eea09fc2 100644 --- a/fs/xfs/quota/xfs_dquot.c +++ b/fs/xfs/quota/xfs_dquot.c | |||
| @@ -47,6 +47,7 @@ | |||
| 47 | #include "xfs_trans_space.h" | 47 | #include "xfs_trans_space.h" |
| 48 | #include "xfs_trans_priv.h" | 48 | #include "xfs_trans_priv.h" |
| 49 | #include "xfs_qm.h" | 49 | #include "xfs_qm.h" |
| 50 | #include "xfs_trace.h" | ||
| 50 | 51 | ||
| 51 | 52 | ||
| 52 | /* | 53 | /* |
| @@ -112,10 +113,7 @@ xfs_qm_dqinit( | |||
| 112 | init_completion(&dqp->q_flush); | 113 | init_completion(&dqp->q_flush); |
| 113 | complete(&dqp->q_flush); | 114 | complete(&dqp->q_flush); |
| 114 | 115 | ||
| 115 | #ifdef XFS_DQUOT_TRACE | 116 | trace_xfs_dqinit(dqp); |
| 116 | dqp->q_trace = ktrace_alloc(DQUOT_TRACE_SIZE, KM_NOFS); | ||
| 117 | xfs_dqtrace_entry(dqp, "DQINIT"); | ||
| 118 | #endif | ||
| 119 | } else { | 117 | } else { |
| 120 | /* | 118 | /* |
| 121 | * Only the q_core portion was zeroed in dqreclaim_one(). | 119 | * Only the q_core portion was zeroed in dqreclaim_one(). |
| @@ -136,10 +134,7 @@ xfs_qm_dqinit( | |||
| 136 | dqp->q_hash = NULL; | 134 | dqp->q_hash = NULL; |
| 137 | ASSERT(dqp->dq_flnext == dqp->dq_flprev); | 135 | ASSERT(dqp->dq_flnext == dqp->dq_flprev); |
| 138 | 136 | ||
| 139 | #ifdef XFS_DQUOT_TRACE | 137 | trace_xfs_dqreuse(dqp); |
| 140 | ASSERT(dqp->q_trace); | ||
| 141 | xfs_dqtrace_entry(dqp, "DQRECLAIMED_INIT"); | ||
| 142 | #endif | ||
| 143 | } | 138 | } |
| 144 | 139 | ||
| 145 | /* | 140 | /* |
| @@ -167,13 +162,8 @@ xfs_qm_dqdestroy( | |||
| 167 | 162 | ||
| 168 | mutex_destroy(&dqp->q_qlock); | 163 | mutex_destroy(&dqp->q_qlock); |
| 169 | sv_destroy(&dqp->q_pinwait); | 164 | sv_destroy(&dqp->q_pinwait); |
| 170 | |||
| 171 | #ifdef XFS_DQUOT_TRACE | ||
| 172 | if (dqp->q_trace) | ||
| 173 | ktrace_free(dqp->q_trace); | ||
| 174 | dqp->q_trace = NULL; | ||
| 175 | #endif | ||
| 176 | kmem_zone_free(xfs_Gqm->qm_dqzone, dqp); | 165 | kmem_zone_free(xfs_Gqm->qm_dqzone, dqp); |
| 166 | |||
| 177 | atomic_dec(&xfs_Gqm->qm_totaldquots); | 167 | atomic_dec(&xfs_Gqm->qm_totaldquots); |
| 178 | } | 168 | } |
| 179 | 169 | ||
| @@ -195,49 +185,6 @@ xfs_qm_dqinit_core( | |||
| 195 | d->dd_diskdq.d_flags = type; | 185 | d->dd_diskdq.d_flags = type; |
| 196 | } | 186 | } |
| 197 | 187 | ||
| 198 | |||
| 199 | #ifdef XFS_DQUOT_TRACE | ||
| 200 | /* | ||
| 201 | * Dquot tracing for debugging. | ||
| 202 | */ | ||
| 203 | /* ARGSUSED */ | ||
| 204 | void | ||
| 205 | __xfs_dqtrace_entry( | ||
| 206 | xfs_dquot_t *dqp, | ||
| 207 | char *func, | ||
| 208 | void *retaddr, | ||
| 209 | xfs_inode_t *ip) | ||
| 210 | { | ||
| 211 | xfs_dquot_t *udqp = NULL; | ||
| 212 | xfs_ino_t ino = 0; | ||
| 213 | |||
| 214 | ASSERT(dqp->q_trace); | ||
| 215 | if (ip) { | ||
| 216 | ino = ip->i_ino; | ||
| 217 | udqp = ip->i_udquot; | ||
| 218 | } | ||
| 219 | ktrace_enter(dqp->q_trace, | ||
| 220 | (void *)(__psint_t)DQUOT_KTRACE_ENTRY, | ||
| 221 | (void *)func, | ||
| 222 | (void *)(__psint_t)dqp->q_nrefs, | ||
| 223 | (void *)(__psint_t)dqp->dq_flags, | ||
| 224 | (void *)(__psint_t)dqp->q_res_bcount, | ||
| 225 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_bcount), | ||
| 226 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_icount), | ||
| 227 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_blk_hardlimit), | ||
| 228 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_blk_softlimit), | ||
| 229 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_ino_hardlimit), | ||
| 230 | (void *)(__psint_t)be64_to_cpu(dqp->q_core.d_ino_softlimit), | ||
| 231 | (void *)(__psint_t)be32_to_cpu(dqp->q_core.d_id), | ||
| 232 | (void *)(__psint_t)current_pid(), | ||
| 233 | (void *)(__psint_t)ino, | ||
| 234 | (void *)(__psint_t)retaddr, | ||
| 235 | (void *)(__psint_t)udqp); | ||
| 236 | return; | ||
| 237 | } | ||
| 238 | #endif | ||
| 239 | |||
| 240 | |||
| 241 | /* | 188 | /* |
| 242 | * If default limits are in force, push them into the dquot now. | 189 | * If default limits are in force, push them into the dquot now. |
| 243 | * We overwrite the dquot limits only if they are zero and this | 190 | * We overwrite the dquot limits only if they are zero and this |
| @@ -425,7 +372,8 @@ xfs_qm_dqalloc( | |||
| 425 | xfs_trans_t *tp = *tpp; | 372 | xfs_trans_t *tp = *tpp; |
| 426 | 373 | ||
| 427 | ASSERT(tp != NULL); | 374 | ASSERT(tp != NULL); |
| 428 | xfs_dqtrace_entry(dqp, "DQALLOC"); | 375 | |
| 376 | trace_xfs_dqalloc(dqp); | ||
| 429 | 377 | ||
| 430 | /* | 378 | /* |
| 431 | * Initialize the bmap freelist prior to calling bmapi code. | 379 | * Initialize the bmap freelist prior to calling bmapi code. |
| @@ -612,7 +560,8 @@ xfs_qm_dqtobp( | |||
| 612 | * (in which case we already have the buf). | 560 | * (in which case we already have the buf). |
| 613 | */ | 561 | */ |
| 614 | if (! newdquot) { | 562 | if (! newdquot) { |
| 615 | xfs_dqtrace_entry(dqp, "DQTOBP READBUF"); | 563 | trace_xfs_dqtobp_read(dqp); |
| 564 | |||
| 616 | if ((error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, | 565 | if ((error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, |
| 617 | dqp->q_blkno, | 566 | dqp->q_blkno, |
| 618 | XFS_QI_DQCHUNKLEN(mp), | 567 | XFS_QI_DQCHUNKLEN(mp), |
| @@ -670,11 +619,12 @@ xfs_qm_dqread( | |||
| 670 | 619 | ||
| 671 | ASSERT(tpp); | 620 | ASSERT(tpp); |
| 672 | 621 | ||
| 622 | trace_xfs_dqread(dqp); | ||
| 623 | |||
| 673 | /* | 624 | /* |
| 674 | * get a pointer to the on-disk dquot and the buffer containing it | 625 | * get a pointer to the on-disk dquot and the buffer containing it |
| 675 | * dqp already knows its own type (GROUP/USER). | 626 | * dqp already knows its own type (GROUP/USER). |
| 676 | */ | 627 | */ |
| 677 | xfs_dqtrace_entry(dqp, "DQREAD"); | ||
| 678 | if ((error = xfs_qm_dqtobp(tpp, dqp, &ddqp, &bp, flags))) { | 628 | if ((error = xfs_qm_dqtobp(tpp, dqp, &ddqp, &bp, flags))) { |
| 679 | return (error); | 629 | return (error); |
| 680 | } | 630 | } |
| @@ -763,7 +713,7 @@ xfs_qm_idtodq( | |||
| 763 | * or if the dquot didn't exist on disk and we ask to | 713 | * or if the dquot didn't exist on disk and we ask to |
| 764 | * allocate (ENOENT). | 714 | * allocate (ENOENT). |
| 765 | */ | 715 | */ |
| 766 | xfs_dqtrace_entry(dqp, "DQREAD FAIL"); | 716 | trace_xfs_dqread_fail(dqp); |
| 767 | cancelflags |= XFS_TRANS_ABORT; | 717 | cancelflags |= XFS_TRANS_ABORT; |
| 768 | goto error0; | 718 | goto error0; |
| 769 | } | 719 | } |
| @@ -817,7 +767,8 @@ xfs_qm_dqlookup( | |||
| 817 | * id can't be modified without the hashlock anyway. | 767 | * id can't be modified without the hashlock anyway. |
| 818 | */ | 768 | */ |
| 819 | if (be32_to_cpu(dqp->q_core.d_id) == id && dqp->q_mount == mp) { | 769 | if (be32_to_cpu(dqp->q_core.d_id) == id && dqp->q_mount == mp) { |
| 820 | xfs_dqtrace_entry(dqp, "DQFOUND BY LOOKUP"); | 770 | trace_xfs_dqlookup_found(dqp); |
| 771 | |||
| 821 | /* | 772 | /* |
| 822 | * All in core dquots must be on the dqlist of mp | 773 | * All in core dquots must be on the dqlist of mp |
| 823 | */ | 774 | */ |
| @@ -827,7 +778,7 @@ xfs_qm_dqlookup( | |||
| 827 | if (dqp->q_nrefs == 0) { | 778 | if (dqp->q_nrefs == 0) { |
| 828 | ASSERT (XFS_DQ_IS_ON_FREELIST(dqp)); | 779 | ASSERT (XFS_DQ_IS_ON_FREELIST(dqp)); |
| 829 | if (! xfs_qm_freelist_lock_nowait(xfs_Gqm)) { | 780 | if (! xfs_qm_freelist_lock_nowait(xfs_Gqm)) { |
| 830 | xfs_dqtrace_entry(dqp, "DQLOOKUP: WANT"); | 781 | trace_xfs_dqlookup_want(dqp); |
| 831 | 782 | ||
| 832 | /* | 783 | /* |
| 833 | * We may have raced with dqreclaim_one() | 784 | * We may have raced with dqreclaim_one() |
| @@ -857,8 +808,7 @@ xfs_qm_dqlookup( | |||
| 857 | /* | 808 | /* |
| 858 | * take it off the freelist | 809 | * take it off the freelist |
| 859 | */ | 810 | */ |
| 860 | xfs_dqtrace_entry(dqp, | 811 | trace_xfs_dqlookup_freelist(dqp); |
| 861 | "DQLOOKUP: TAKEOFF FL"); | ||
| 862 | XQM_FREELIST_REMOVE(dqp); | 812 | XQM_FREELIST_REMOVE(dqp); |
| 863 | /* xfs_qm_freelist_print(&(xfs_Gqm-> | 813 | /* xfs_qm_freelist_print(&(xfs_Gqm-> |
| 864 | qm_dqfreelist), | 814 | qm_dqfreelist), |
| @@ -878,8 +828,7 @@ xfs_qm_dqlookup( | |||
| 878 | */ | 828 | */ |
| 879 | ASSERT(mutex_is_locked(&qh->qh_lock)); | 829 | ASSERT(mutex_is_locked(&qh->qh_lock)); |
| 880 | if (dqp->HL_PREVP != &qh->qh_next) { | 830 | if (dqp->HL_PREVP != &qh->qh_next) { |
| 881 | xfs_dqtrace_entry(dqp, | 831 | trace_xfs_dqlookup_move(dqp); |
| 882 | "DQLOOKUP: HASH MOVETOFRONT"); | ||
| 883 | if ((d = dqp->HL_NEXT)) | 832 | if ((d = dqp->HL_NEXT)) |
| 884 | d->HL_PREVP = dqp->HL_PREVP; | 833 | d->HL_PREVP = dqp->HL_PREVP; |
| 885 | *(dqp->HL_PREVP) = d; | 834 | *(dqp->HL_PREVP) = d; |
| @@ -889,7 +838,7 @@ xfs_qm_dqlookup( | |||
| 889 | dqp->HL_PREVP = &qh->qh_next; | 838 | dqp->HL_PREVP = &qh->qh_next; |
| 890 | qh->qh_next = dqp; | 839 | qh->qh_next = dqp; |
| 891 | } | 840 | } |
| 892 | xfs_dqtrace_entry(dqp, "LOOKUP END"); | 841 | trace_xfs_dqlookup_done(dqp); |
| 893 | *O_dqpp = dqp; | 842 | *O_dqpp = dqp; |
| 894 | ASSERT(mutex_is_locked(&qh->qh_lock)); | 843 | ASSERT(mutex_is_locked(&qh->qh_lock)); |
| 895 | return (0); | 844 | return (0); |
| @@ -971,7 +920,7 @@ xfs_qm_dqget( | |||
| 971 | ASSERT(*O_dqpp); | 920 | ASSERT(*O_dqpp); |
| 972 | ASSERT(XFS_DQ_IS_LOCKED(*O_dqpp)); | 921 | ASSERT(XFS_DQ_IS_LOCKED(*O_dqpp)); |
| 973 | mutex_unlock(&h->qh_lock); | 922 | mutex_unlock(&h->qh_lock); |
| 974 | xfs_dqtrace_entry(*O_dqpp, "DQGET DONE (FROM CACHE)"); | 923 | trace_xfs_dqget_hit(*O_dqpp); |
| 975 | return (0); /* success */ | 924 | return (0); /* success */ |
| 976 | } | 925 | } |
| 977 | XQM_STATS_INC(xqmstats.xs_qm_dqcachemisses); | 926 | XQM_STATS_INC(xqmstats.xs_qm_dqcachemisses); |
| @@ -1104,7 +1053,7 @@ xfs_qm_dqget( | |||
| 1104 | mutex_unlock(&h->qh_lock); | 1053 | mutex_unlock(&h->qh_lock); |
| 1105 | dqret: | 1054 | dqret: |
| 1106 | ASSERT((ip == NULL) || xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 1055 | ASSERT((ip == NULL) || xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
| 1107 | xfs_dqtrace_entry(dqp, "DQGET DONE"); | 1056 | trace_xfs_dqget_miss(dqp); |
| 1108 | *O_dqpp = dqp; | 1057 | *O_dqpp = dqp; |
| 1109 | return (0); | 1058 | return (0); |
| 1110 | } | 1059 | } |
| @@ -1124,7 +1073,8 @@ xfs_qm_dqput( | |||
| 1124 | 1073 | ||
| 1125 | ASSERT(dqp->q_nrefs > 0); | 1074 | ASSERT(dqp->q_nrefs > 0); |
| 1126 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); | 1075 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); |
| 1127 | xfs_dqtrace_entry(dqp, "DQPUT"); | 1076 | |
| 1077 | trace_xfs_dqput(dqp); | ||
| 1128 | 1078 | ||
| 1129 | if (dqp->q_nrefs != 1) { | 1079 | if (dqp->q_nrefs != 1) { |
| 1130 | dqp->q_nrefs--; | 1080 | dqp->q_nrefs--; |
| @@ -1137,7 +1087,7 @@ xfs_qm_dqput( | |||
| 1137 | * in the right order; but try to get it out-of-order first | 1087 | * in the right order; but try to get it out-of-order first |
| 1138 | */ | 1088 | */ |
| 1139 | if (! xfs_qm_freelist_lock_nowait(xfs_Gqm)) { | 1089 | if (! xfs_qm_freelist_lock_nowait(xfs_Gqm)) { |
| 1140 | xfs_dqtrace_entry(dqp, "DQPUT: FLLOCK-WAIT"); | 1090 | trace_xfs_dqput_wait(dqp); |
| 1141 | xfs_dqunlock(dqp); | 1091 | xfs_dqunlock(dqp); |
| 1142 | xfs_qm_freelist_lock(xfs_Gqm); | 1092 | xfs_qm_freelist_lock(xfs_Gqm); |
| 1143 | xfs_dqlock(dqp); | 1093 | xfs_dqlock(dqp); |
| @@ -1148,7 +1098,8 @@ xfs_qm_dqput( | |||
| 1148 | 1098 | ||
| 1149 | /* We can't depend on nrefs being == 1 here */ | 1099 | /* We can't depend on nrefs being == 1 here */ |
| 1150 | if (--dqp->q_nrefs == 0) { | 1100 | if (--dqp->q_nrefs == 0) { |
| 1151 | xfs_dqtrace_entry(dqp, "DQPUT: ON FREELIST"); | 1101 | trace_xfs_dqput_free(dqp); |
| 1102 | |||
| 1152 | /* | 1103 | /* |
| 1153 | * insert at end of the freelist. | 1104 | * insert at end of the freelist. |
| 1154 | */ | 1105 | */ |
| @@ -1196,7 +1147,7 @@ xfs_qm_dqrele( | |||
| 1196 | if (!dqp) | 1147 | if (!dqp) |
| 1197 | return; | 1148 | return; |
| 1198 | 1149 | ||
| 1199 | xfs_dqtrace_entry(dqp, "DQRELE"); | 1150 | trace_xfs_dqrele(dqp); |
| 1200 | 1151 | ||
| 1201 | xfs_dqlock(dqp); | 1152 | xfs_dqlock(dqp); |
| 1202 | /* | 1153 | /* |
| @@ -1229,7 +1180,7 @@ xfs_qm_dqflush( | |||
| 1229 | 1180 | ||
| 1230 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); | 1181 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); |
| 1231 | ASSERT(!completion_done(&dqp->q_flush)); | 1182 | ASSERT(!completion_done(&dqp->q_flush)); |
| 1232 | xfs_dqtrace_entry(dqp, "DQFLUSH"); | 1183 | trace_xfs_dqflush(dqp); |
| 1233 | 1184 | ||
| 1234 | /* | 1185 | /* |
| 1235 | * If not dirty, or it's pinned and we are not supposed to | 1186 | * If not dirty, or it's pinned and we are not supposed to |
| @@ -1259,7 +1210,6 @@ xfs_qm_dqflush( | |||
| 1259 | * the ondisk-dquot has already been allocated for. | 1210 | * the ondisk-dquot has already been allocated for. |
| 1260 | */ | 1211 | */ |
| 1261 | if ((error = xfs_qm_dqtobp(NULL, dqp, &ddqp, &bp, XFS_QMOPT_DOWARN))) { | 1212 | if ((error = xfs_qm_dqtobp(NULL, dqp, &ddqp, &bp, XFS_QMOPT_DOWARN))) { |
| 1262 | xfs_dqtrace_entry(dqp, "DQTOBP FAIL"); | ||
| 1263 | ASSERT(error != ENOENT); | 1213 | ASSERT(error != ENOENT); |
| 1264 | /* | 1214 | /* |
| 1265 | * Quotas could have gotten turned off (ESRCH) | 1215 | * Quotas could have gotten turned off (ESRCH) |
| @@ -1297,7 +1247,7 @@ xfs_qm_dqflush( | |||
| 1297 | * get stuck waiting in the write for too long. | 1247 | * get stuck waiting in the write for too long. |
| 1298 | */ | 1248 | */ |
| 1299 | if (XFS_BUF_ISPINNED(bp)) { | 1249 | if (XFS_BUF_ISPINNED(bp)) { |
| 1300 | xfs_dqtrace_entry(dqp, "DQFLUSH LOG FORCE"); | 1250 | trace_xfs_dqflush_force(dqp); |
| 1301 | xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE); | 1251 | xfs_log_force(mp, (xfs_lsn_t)0, XFS_LOG_FORCE); |
| 1302 | } | 1252 | } |
| 1303 | 1253 | ||
| @@ -1308,7 +1258,9 @@ xfs_qm_dqflush( | |||
| 1308 | } else { | 1258 | } else { |
| 1309 | error = xfs_bwrite(mp, bp); | 1259 | error = xfs_bwrite(mp, bp); |
| 1310 | } | 1260 | } |
| 1311 | xfs_dqtrace_entry(dqp, "DQFLUSH END"); | 1261 | |
| 1262 | trace_xfs_dqflush_done(dqp); | ||
| 1263 | |||
| 1312 | /* | 1264 | /* |
| 1313 | * dqp is still locked, but caller is free to unlock it now. | 1265 | * dqp is still locked, but caller is free to unlock it now. |
| 1314 | */ | 1266 | */ |
| @@ -1483,7 +1435,7 @@ xfs_qm_dqpurge( | |||
| 1483 | */ | 1435 | */ |
| 1484 | if (XFS_DQ_IS_DIRTY(dqp)) { | 1436 | if (XFS_DQ_IS_DIRTY(dqp)) { |
| 1485 | int error; | 1437 | int error; |
| 1486 | xfs_dqtrace_entry(dqp, "DQPURGE ->DQFLUSH: DQDIRTY"); | 1438 | |
| 1487 | /* dqflush unlocks dqflock */ | 1439 | /* dqflush unlocks dqflock */ |
| 1488 | /* | 1440 | /* |
| 1489 | * Given that dqpurge is a very rare occurrence, it is OK | 1441 | * Given that dqpurge is a very rare occurrence, it is OK |
diff --git a/fs/xfs/quota/xfs_dquot.h b/fs/xfs/quota/xfs_dquot.h index a2c16bcee90b..a0f7da586d1b 100644 --- a/fs/xfs/quota/xfs_dquot.h +++ b/fs/xfs/quota/xfs_dquot.h | |||
| @@ -85,9 +85,6 @@ typedef struct xfs_dquot { | |||
| 85 | struct completion q_flush; /* flush completion queue */ | 85 | struct completion q_flush; /* flush completion queue */ |
| 86 | atomic_t q_pincount; /* dquot pin count */ | 86 | atomic_t q_pincount; /* dquot pin count */ |
| 87 | wait_queue_head_t q_pinwait; /* dquot pinning wait queue */ | 87 | wait_queue_head_t q_pinwait; /* dquot pinning wait queue */ |
| 88 | #ifdef XFS_DQUOT_TRACE | ||
| 89 | struct ktrace *q_trace; /* trace header structure */ | ||
| 90 | #endif | ||
| 91 | } xfs_dquot_t; | 88 | } xfs_dquot_t; |
| 92 | 89 | ||
| 93 | 90 | ||
| @@ -144,24 +141,6 @@ static inline void xfs_dqfunlock(xfs_dquot_t *dqp) | |||
| 144 | (XFS_IS_UQUOTA_ON((d)->q_mount)) : \ | 141 | (XFS_IS_UQUOTA_ON((d)->q_mount)) : \ |
| 145 | (XFS_IS_OQUOTA_ON((d)->q_mount)))) | 142 | (XFS_IS_OQUOTA_ON((d)->q_mount)))) |
| 146 | 143 | ||
| 147 | #ifdef XFS_DQUOT_TRACE | ||
| 148 | /* | ||
| 149 | * Dquot Tracing stuff. | ||
| 150 | */ | ||
| 151 | #define DQUOT_TRACE_SIZE 64 | ||
| 152 | #define DQUOT_KTRACE_ENTRY 1 | ||
| 153 | |||
| 154 | extern void __xfs_dqtrace_entry(xfs_dquot_t *dqp, char *func, | ||
| 155 | void *, xfs_inode_t *); | ||
| 156 | #define xfs_dqtrace_entry_ino(a,b,ip) \ | ||
| 157 | __xfs_dqtrace_entry((a), (b), (void*)__return_address, (ip)) | ||
| 158 | #define xfs_dqtrace_entry(a,b) \ | ||
| 159 | __xfs_dqtrace_entry((a), (b), (void*)__return_address, NULL) | ||
| 160 | #else | ||
| 161 | #define xfs_dqtrace_entry(a,b) | ||
| 162 | #define xfs_dqtrace_entry_ino(a,b,ip) | ||
| 163 | #endif | ||
| 164 | |||
| 165 | #ifdef QUOTADEBUG | 144 | #ifdef QUOTADEBUG |
| 166 | extern void xfs_qm_dqprint(xfs_dquot_t *); | 145 | extern void xfs_qm_dqprint(xfs_dquot_t *); |
| 167 | #else | 146 | #else |
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c index 45b1bfef7388..9e627a8b5b0e 100644 --- a/fs/xfs/quota/xfs_qm.c +++ b/fs/xfs/quota/xfs_qm.c | |||
| @@ -47,6 +47,7 @@ | |||
| 47 | #include "xfs_trans_space.h" | 47 | #include "xfs_trans_space.h" |
| 48 | #include "xfs_utils.h" | 48 | #include "xfs_utils.h" |
| 49 | #include "xfs_qm.h" | 49 | #include "xfs_qm.h" |
| 50 | #include "xfs_trace.h" | ||
| 50 | 51 | ||
| 51 | /* | 52 | /* |
| 52 | * The global quota manager. There is only one of these for the entire | 53 | * The global quota manager. There is only one of these for the entire |
| @@ -453,7 +454,7 @@ again: | |||
| 453 | xfs_dqunlock(dqp); | 454 | xfs_dqunlock(dqp); |
| 454 | continue; | 455 | continue; |
| 455 | } | 456 | } |
| 456 | xfs_dqtrace_entry(dqp, "FLUSHALL: DQDIRTY"); | 457 | |
| 457 | /* XXX a sentinel would be better */ | 458 | /* XXX a sentinel would be better */ |
| 458 | recl = XFS_QI_MPLRECLAIMS(mp); | 459 | recl = XFS_QI_MPLRECLAIMS(mp); |
| 459 | if (!xfs_dqflock_nowait(dqp)) { | 460 | if (!xfs_dqflock_nowait(dqp)) { |
| @@ -651,7 +652,7 @@ xfs_qm_dqattach_one( | |||
| 651 | */ | 652 | */ |
| 652 | dqp = *IO_idqpp; | 653 | dqp = *IO_idqpp; |
| 653 | if (dqp) { | 654 | if (dqp) { |
| 654 | xfs_dqtrace_entry(dqp, "DQATTACH: found in ip"); | 655 | trace_xfs_dqattach_found(dqp); |
| 655 | return 0; | 656 | return 0; |
| 656 | } | 657 | } |
| 657 | 658 | ||
| @@ -704,7 +705,7 @@ xfs_qm_dqattach_one( | |||
| 704 | if (error) | 705 | if (error) |
| 705 | return error; | 706 | return error; |
| 706 | 707 | ||
| 707 | xfs_dqtrace_entry(dqp, "DQATTACH: found by dqget"); | 708 | trace_xfs_dqattach_get(dqp); |
| 708 | 709 | ||
| 709 | /* | 710 | /* |
| 710 | * dqget may have dropped and re-acquired the ilock, but it guarantees | 711 | * dqget may have dropped and re-acquired the ilock, but it guarantees |
| @@ -890,15 +891,15 @@ xfs_qm_dqdetach( | |||
| 890 | if (!(ip->i_udquot || ip->i_gdquot)) | 891 | if (!(ip->i_udquot || ip->i_gdquot)) |
| 891 | return; | 892 | return; |
| 892 | 893 | ||
| 894 | trace_xfs_dquot_dqdetach(ip); | ||
| 895 | |||
| 893 | ASSERT(ip->i_ino != ip->i_mount->m_sb.sb_uquotino); | 896 | ASSERT(ip->i_ino != ip->i_mount->m_sb.sb_uquotino); |
| 894 | ASSERT(ip->i_ino != ip->i_mount->m_sb.sb_gquotino); | 897 | ASSERT(ip->i_ino != ip->i_mount->m_sb.sb_gquotino); |
| 895 | if (ip->i_udquot) { | 898 | if (ip->i_udquot) { |
| 896 | xfs_dqtrace_entry_ino(ip->i_udquot, "DQDETTACH", ip); | ||
| 897 | xfs_qm_dqrele(ip->i_udquot); | 899 | xfs_qm_dqrele(ip->i_udquot); |
| 898 | ip->i_udquot = NULL; | 900 | ip->i_udquot = NULL; |
| 899 | } | 901 | } |
| 900 | if (ip->i_gdquot) { | 902 | if (ip->i_gdquot) { |
| 901 | xfs_dqtrace_entry_ino(ip->i_gdquot, "DQDETTACH", ip); | ||
| 902 | xfs_qm_dqrele(ip->i_gdquot); | 903 | xfs_qm_dqrele(ip->i_gdquot); |
| 903 | ip->i_gdquot = NULL; | 904 | ip->i_gdquot = NULL; |
| 904 | } | 905 | } |
| @@ -977,7 +978,6 @@ xfs_qm_sync( | |||
| 977 | * across a disk write | 978 | * across a disk write |
| 978 | */ | 979 | */ |
| 979 | xfs_qm_mplist_unlock(mp); | 980 | xfs_qm_mplist_unlock(mp); |
| 980 | xfs_dqtrace_entry(dqp, "XQM_SYNC: DQFLUSH"); | ||
| 981 | error = xfs_qm_dqflush(dqp, flush_flags); | 981 | error = xfs_qm_dqflush(dqp, flush_flags); |
| 982 | xfs_dqunlock(dqp); | 982 | xfs_dqunlock(dqp); |
| 983 | if (error && XFS_FORCED_SHUTDOWN(mp)) | 983 | if (error && XFS_FORCED_SHUTDOWN(mp)) |
| @@ -1350,7 +1350,8 @@ xfs_qm_reset_dqcounts( | |||
| 1350 | xfs_disk_dquot_t *ddq; | 1350 | xfs_disk_dquot_t *ddq; |
| 1351 | int j; | 1351 | int j; |
| 1352 | 1352 | ||
| 1353 | xfs_buftrace("RESET DQUOTS", bp); | 1353 | trace_xfs_reset_dqcounts(bp, _RET_IP_); |
| 1354 | |||
| 1354 | /* | 1355 | /* |
| 1355 | * Reset all counters and timers. They'll be | 1356 | * Reset all counters and timers. They'll be |
| 1356 | * started afresh by xfs_qm_quotacheck. | 1357 | * started afresh by xfs_qm_quotacheck. |
| @@ -1543,7 +1544,9 @@ xfs_qm_quotacheck_dqadjust( | |||
| 1543 | xfs_qcnt_t rtblks) | 1544 | xfs_qcnt_t rtblks) |
| 1544 | { | 1545 | { |
| 1545 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); | 1546 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); |
| 1546 | xfs_dqtrace_entry(dqp, "QCHECK DQADJUST"); | 1547 | |
| 1548 | trace_xfs_dqadjust(dqp); | ||
| 1549 | |||
| 1547 | /* | 1550 | /* |
| 1548 | * Adjust the inode count and the block count to reflect this inode's | 1551 | * Adjust the inode count and the block count to reflect this inode's |
| 1549 | * resource usage. | 1552 | * resource usage. |
| @@ -1994,7 +1997,9 @@ xfs_qm_shake_freelist( | |||
| 1994 | */ | 1997 | */ |
| 1995 | if (XFS_DQ_IS_DIRTY(dqp)) { | 1998 | if (XFS_DQ_IS_DIRTY(dqp)) { |
| 1996 | int error; | 1999 | int error; |
| 1997 | xfs_dqtrace_entry(dqp, "DQSHAKE: DQDIRTY"); | 2000 | |
| 2001 | trace_xfs_dqshake_dirty(dqp); | ||
| 2002 | |||
| 1998 | /* | 2003 | /* |
| 1999 | * We flush it delayed write, so don't bother | 2004 | * We flush it delayed write, so don't bother |
| 2000 | * releasing the mplock. | 2005 | * releasing the mplock. |
| @@ -2038,7 +2043,9 @@ xfs_qm_shake_freelist( | |||
| 2038 | return nreclaimed; | 2043 | return nreclaimed; |
| 2039 | goto tryagain; | 2044 | goto tryagain; |
| 2040 | } | 2045 | } |
| 2041 | xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING"); | 2046 | |
| 2047 | trace_xfs_dqshake_unlink(dqp); | ||
| 2048 | |||
| 2042 | #ifdef QUOTADEBUG | 2049 | #ifdef QUOTADEBUG |
| 2043 | cmn_err(CE_DEBUG, "Shake 0x%p, ID 0x%x\n", | 2050 | cmn_err(CE_DEBUG, "Shake 0x%p, ID 0x%x\n", |
| 2044 | dqp, be32_to_cpu(dqp->q_core.d_id)); | 2051 | dqp, be32_to_cpu(dqp->q_core.d_id)); |
| @@ -2125,7 +2132,9 @@ xfs_qm_dqreclaim_one(void) | |||
| 2125 | */ | 2132 | */ |
| 2126 | if (dqp->dq_flags & XFS_DQ_WANT) { | 2133 | if (dqp->dq_flags & XFS_DQ_WANT) { |
| 2127 | ASSERT(! (dqp->dq_flags & XFS_DQ_INACTIVE)); | 2134 | ASSERT(! (dqp->dq_flags & XFS_DQ_INACTIVE)); |
| 2128 | xfs_dqtrace_entry(dqp, "DQRECLAIM: DQWANT"); | 2135 | |
| 2136 | trace_xfs_dqreclaim_want(dqp); | ||
| 2137 | |||
| 2129 | xfs_dqunlock(dqp); | 2138 | xfs_dqunlock(dqp); |
| 2130 | xfs_qm_freelist_unlock(xfs_Gqm); | 2139 | xfs_qm_freelist_unlock(xfs_Gqm); |
| 2131 | if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS) | 2140 | if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS) |
| @@ -2171,7 +2180,9 @@ xfs_qm_dqreclaim_one(void) | |||
| 2171 | */ | 2180 | */ |
| 2172 | if (XFS_DQ_IS_DIRTY(dqp)) { | 2181 | if (XFS_DQ_IS_DIRTY(dqp)) { |
| 2173 | int error; | 2182 | int error; |
| 2174 | xfs_dqtrace_entry(dqp, "DQRECLAIM: DQDIRTY"); | 2183 | |
| 2184 | trace_xfs_dqreclaim_dirty(dqp); | ||
| 2185 | |||
| 2175 | /* | 2186 | /* |
| 2176 | * We flush it delayed write, so don't bother | 2187 | * We flush it delayed write, so don't bother |
| 2177 | * releasing the freelist lock. | 2188 | * releasing the freelist lock. |
| @@ -2194,8 +2205,9 @@ xfs_qm_dqreclaim_one(void) | |||
| 2194 | if (!mutex_trylock(&dqp->q_hash->qh_lock)) | 2205 | if (!mutex_trylock(&dqp->q_hash->qh_lock)) |
| 2195 | goto mplistunlock; | 2206 | goto mplistunlock; |
| 2196 | 2207 | ||
| 2208 | trace_xfs_dqreclaim_unlink(dqp); | ||
| 2209 | |||
| 2197 | ASSERT(dqp->q_nrefs == 0); | 2210 | ASSERT(dqp->q_nrefs == 0); |
| 2198 | xfs_dqtrace_entry(dqp, "DQRECLAIM: UNLINKING"); | ||
| 2199 | XQM_MPLIST_REMOVE(&(XFS_QI_MPL_LIST(dqp->q_mount)), dqp); | 2211 | XQM_MPLIST_REMOVE(&(XFS_QI_MPL_LIST(dqp->q_mount)), dqp); |
| 2200 | XQM_HASHLIST_REMOVE(dqp->q_hash, dqp); | 2212 | XQM_HASHLIST_REMOVE(dqp->q_hash, dqp); |
| 2201 | XQM_FREELIST_REMOVE(dqp); | 2213 | XQM_FREELIST_REMOVE(dqp); |
| @@ -2430,7 +2442,7 @@ xfs_qm_vop_dqalloc( | |||
| 2430 | } | 2442 | } |
| 2431 | } | 2443 | } |
| 2432 | if (uq) | 2444 | if (uq) |
| 2433 | xfs_dqtrace_entry_ino(uq, "DQALLOC", ip); | 2445 | trace_xfs_dquot_dqalloc(ip); |
| 2434 | 2446 | ||
| 2435 | xfs_iunlock(ip, lockflags); | 2447 | xfs_iunlock(ip, lockflags); |
| 2436 | if (O_udqpp) | 2448 | if (O_udqpp) |
diff --git a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/quota/xfs_qm_syscalls.c index 5d1a3b98a6e6..71af76fe8a23 100644 --- a/fs/xfs/quota/xfs_qm_syscalls.c +++ b/fs/xfs/quota/xfs_qm_syscalls.c | |||
| @@ -49,6 +49,7 @@ | |||
| 49 | #include "xfs_buf_item.h" | 49 | #include "xfs_buf_item.h" |
| 50 | #include "xfs_utils.h" | 50 | #include "xfs_utils.h" |
| 51 | #include "xfs_qm.h" | 51 | #include "xfs_qm.h" |
| 52 | #include "xfs_trace.h" | ||
| 52 | 53 | ||
| 53 | #ifdef DEBUG | 54 | #ifdef DEBUG |
| 54 | # define qdprintk(s, args...) cmn_err(CE_DEBUG, s, ## args) | 55 | # define qdprintk(s, args...) cmn_err(CE_DEBUG, s, ## args) |
| @@ -496,7 +497,6 @@ xfs_qm_scall_setqlim( | |||
| 496 | ASSERT(error != ENOENT); | 497 | ASSERT(error != ENOENT); |
| 497 | return (error); | 498 | return (error); |
| 498 | } | 499 | } |
| 499 | xfs_dqtrace_entry(dqp, "Q_SETQLIM: AFT DQGET"); | ||
| 500 | xfs_trans_dqjoin(tp, dqp); | 500 | xfs_trans_dqjoin(tp, dqp); |
| 501 | ddq = &dqp->q_core; | 501 | ddq = &dqp->q_core; |
| 502 | 502 | ||
| @@ -602,7 +602,6 @@ xfs_qm_scall_setqlim( | |||
| 602 | dqp->dq_flags |= XFS_DQ_DIRTY; | 602 | dqp->dq_flags |= XFS_DQ_DIRTY; |
| 603 | xfs_trans_log_dquot(tp, dqp); | 603 | xfs_trans_log_dquot(tp, dqp); |
| 604 | 604 | ||
| 605 | xfs_dqtrace_entry(dqp, "Q_SETQLIM: COMMIT"); | ||
| 606 | error = xfs_trans_commit(tp, 0); | 605 | error = xfs_trans_commit(tp, 0); |
| 607 | xfs_qm_dqprint(dqp); | 606 | xfs_qm_dqprint(dqp); |
| 608 | xfs_qm_dqrele(dqp); | 607 | xfs_qm_dqrele(dqp); |
| @@ -630,7 +629,6 @@ xfs_qm_scall_getquota( | |||
| 630 | return (error); | 629 | return (error); |
| 631 | } | 630 | } |
| 632 | 631 | ||
| 633 | xfs_dqtrace_entry(dqp, "Q_GETQUOTA SUCCESS"); | ||
| 634 | /* | 632 | /* |
| 635 | * If everything's NULL, this dquot doesn't quite exist as far as | 633 | * If everything's NULL, this dquot doesn't quite exist as far as |
| 636 | * our utility programs are concerned. | 634 | * our utility programs are concerned. |
diff --git a/fs/xfs/support/ktrace.c b/fs/xfs/support/ktrace.c deleted file mode 100644 index 2d494c26717f..000000000000 --- a/fs/xfs/support/ktrace.c +++ /dev/null | |||
| @@ -1,323 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. | ||
| 3 | * All Rights Reserved. | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU General Public License as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it would be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program; if not, write the Free Software Foundation, | ||
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | #include <xfs.h> | ||
| 19 | |||
| 20 | static kmem_zone_t *ktrace_hdr_zone; | ||
| 21 | static kmem_zone_t *ktrace_ent_zone; | ||
| 22 | static int ktrace_zentries; | ||
| 23 | |||
| 24 | void __init | ||
| 25 | ktrace_init(int zentries) | ||
| 26 | { | ||
| 27 | ktrace_zentries = roundup_pow_of_two(zentries); | ||
| 28 | |||
| 29 | ktrace_hdr_zone = kmem_zone_init(sizeof(ktrace_t), | ||
| 30 | "ktrace_hdr"); | ||
| 31 | ASSERT(ktrace_hdr_zone); | ||
| 32 | |||
| 33 | ktrace_ent_zone = kmem_zone_init(ktrace_zentries | ||
| 34 | * sizeof(ktrace_entry_t), | ||
| 35 | "ktrace_ent"); | ||
| 36 | ASSERT(ktrace_ent_zone); | ||
| 37 | } | ||
| 38 | |||
| 39 | void __exit | ||
| 40 | ktrace_uninit(void) | ||
| 41 | { | ||
| 42 | kmem_zone_destroy(ktrace_hdr_zone); | ||
| 43 | kmem_zone_destroy(ktrace_ent_zone); | ||
| 44 | } | ||
| 45 | |||
| 46 | /* | ||
| 47 | * ktrace_alloc() | ||
| 48 | * | ||
| 49 | * Allocate a ktrace header and enough buffering for the given | ||
| 50 | * number of entries. Round the number of entries up to a | ||
| 51 | * power of 2 so we can do fast masking to get the index from | ||
| 52 | * the atomic index counter. | ||
| 53 | */ | ||
| 54 | ktrace_t * | ||
| 55 | ktrace_alloc(int nentries, unsigned int __nocast sleep) | ||
| 56 | { | ||
| 57 | ktrace_t *ktp; | ||
| 58 | ktrace_entry_t *ktep; | ||
| 59 | int entries; | ||
| 60 | |||
| 61 | ktp = (ktrace_t*)kmem_zone_alloc(ktrace_hdr_zone, sleep); | ||
| 62 | |||
| 63 | if (ktp == (ktrace_t*)NULL) { | ||
| 64 | /* | ||
| 65 | * KM_SLEEP callers don't expect failure. | ||
| 66 | */ | ||
| 67 | if (sleep & KM_SLEEP) | ||
| 68 | panic("ktrace_alloc: NULL memory on KM_SLEEP request!"); | ||
| 69 | |||
| 70 | return NULL; | ||
| 71 | } | ||
| 72 | |||
| 73 | /* | ||
| 74 | * Special treatment for buffers with the ktrace_zentries entries | ||
| 75 | */ | ||
| 76 | entries = roundup_pow_of_two(nentries); | ||
| 77 | if (entries == ktrace_zentries) { | ||
| 78 | ktep = (ktrace_entry_t*)kmem_zone_zalloc(ktrace_ent_zone, | ||
| 79 | sleep); | ||
| 80 | } else { | ||
| 81 | ktep = (ktrace_entry_t*)kmem_zalloc((entries * sizeof(*ktep)), | ||
| 82 | sleep | KM_LARGE); | ||
| 83 | } | ||
| 84 | |||
| 85 | if (ktep == NULL) { | ||
| 86 | /* | ||
| 87 | * KM_SLEEP callers don't expect failure. | ||
| 88 | */ | ||
| 89 | if (sleep & KM_SLEEP) | ||
| 90 | panic("ktrace_alloc: NULL memory on KM_SLEEP request!"); | ||
| 91 | |||
| 92 | kmem_free(ktp); | ||
| 93 | |||
| 94 | return NULL; | ||
| 95 | } | ||
| 96 | |||
| 97 | ktp->kt_entries = ktep; | ||
| 98 | ktp->kt_nentries = entries; | ||
| 99 | ASSERT(is_power_of_2(entries)); | ||
| 100 | ktp->kt_index_mask = entries - 1; | ||
| 101 | atomic_set(&ktp->kt_index, 0); | ||
| 102 | ktp->kt_rollover = 0; | ||
| 103 | return ktp; | ||
| 104 | } | ||
| 105 | |||
| 106 | |||
| 107 | /* | ||
| 108 | * ktrace_free() | ||
| 109 | * | ||
| 110 | * Free up the ktrace header and buffer. It is up to the caller | ||
| 111 | * to ensure that no-one is referencing it. | ||
| 112 | */ | ||
| 113 | void | ||
| 114 | ktrace_free(ktrace_t *ktp) | ||
| 115 | { | ||
| 116 | if (ktp == (ktrace_t *)NULL) | ||
| 117 | return; | ||
| 118 | |||
| 119 | /* | ||
| 120 | * Special treatment for the Vnode trace buffer. | ||
| 121 | */ | ||
| 122 | if (ktp->kt_nentries == ktrace_zentries) | ||
| 123 | kmem_zone_free(ktrace_ent_zone, ktp->kt_entries); | ||
| 124 | else | ||
| 125 | kmem_free(ktp->kt_entries); | ||
| 126 | |||
| 127 | kmem_zone_free(ktrace_hdr_zone, ktp); | ||
| 128 | } | ||
| 129 | |||
| 130 | |||
| 131 | /* | ||
| 132 | * Enter the given values into the "next" entry in the trace buffer. | ||
| 133 | * kt_index is always the index of the next entry to be filled. | ||
| 134 | */ | ||
| 135 | void | ||
| 136 | ktrace_enter( | ||
| 137 | ktrace_t *ktp, | ||
| 138 | void *val0, | ||
| 139 | void *val1, | ||
| 140 | void *val2, | ||
| 141 | void *val3, | ||
| 142 | void *val4, | ||
| 143 | void *val5, | ||
| 144 | void *val6, | ||
| 145 | void *val7, | ||
| 146 | void *val8, | ||
| 147 | void *val9, | ||
| 148 | void *val10, | ||
| 149 | void *val11, | ||
| 150 | void *val12, | ||
| 151 | void *val13, | ||
| 152 | void *val14, | ||
| 153 | void *val15) | ||
| 154 | { | ||
| 155 | int index; | ||
| 156 | ktrace_entry_t *ktep; | ||
| 157 | |||
| 158 | ASSERT(ktp != NULL); | ||
| 159 | |||
| 160 | /* | ||
| 161 | * Grab an entry by pushing the index up to the next one. | ||
| 162 | */ | ||
| 163 | index = atomic_add_return(1, &ktp->kt_index); | ||
| 164 | index = (index - 1) & ktp->kt_index_mask; | ||
| 165 | if (!ktp->kt_rollover && index == ktp->kt_nentries - 1) | ||
| 166 | ktp->kt_rollover = 1; | ||
| 167 | |||
| 168 | ASSERT((index >= 0) && (index < ktp->kt_nentries)); | ||
| 169 | |||
| 170 | ktep = &(ktp->kt_entries[index]); | ||
| 171 | |||
| 172 | ktep->val[0] = val0; | ||
| 173 | ktep->val[1] = val1; | ||
| 174 | ktep->val[2] = val2; | ||
| 175 | ktep->val[3] = val3; | ||
| 176 | ktep->val[4] = val4; | ||
| 177 | ktep->val[5] = val5; | ||
| 178 | ktep->val[6] = val6; | ||
| 179 | ktep->val[7] = val7; | ||
| 180 | ktep->val[8] = val8; | ||
| 181 | ktep->val[9] = val9; | ||
| 182 | ktep->val[10] = val10; | ||
| 183 | ktep->val[11] = val11; | ||
| 184 | ktep->val[12] = val12; | ||
| 185 | ktep->val[13] = val13; | ||
| 186 | ktep->val[14] = val14; | ||
| 187 | ktep->val[15] = val15; | ||
| 188 | } | ||
| 189 | |||
| 190 | /* | ||
| 191 | * Return the number of entries in the trace buffer. | ||
| 192 | */ | ||
| 193 | int | ||
| 194 | ktrace_nentries( | ||
| 195 | ktrace_t *ktp) | ||
| 196 | { | ||
| 197 | int index; | ||
| 198 | if (ktp == NULL) | ||
| 199 | return 0; | ||
| 200 | |||
| 201 | index = atomic_read(&ktp->kt_index) & ktp->kt_index_mask; | ||
| 202 | return (ktp->kt_rollover ? ktp->kt_nentries : index); | ||
| 203 | } | ||
| 204 | |||
| 205 | /* | ||
| 206 | * ktrace_first() | ||
| 207 | * | ||
| 208 | * This is used to find the start of the trace buffer. | ||
| 209 | * In conjunction with ktrace_next() it can be used to | ||
| 210 | * iterate through the entire trace buffer. This code does | ||
| 211 | * not do any locking because it is assumed that it is called | ||
| 212 | * from the debugger. | ||
| 213 | * | ||
| 214 | * The caller must pass in a pointer to a ktrace_snap | ||
| 215 | * structure in which we will keep some state used to | ||
| 216 | * iterate through the buffer. This state must not touched | ||
| 217 | * by any code outside of this module. | ||
| 218 | */ | ||
| 219 | ktrace_entry_t * | ||
| 220 | ktrace_first(ktrace_t *ktp, ktrace_snap_t *ktsp) | ||
| 221 | { | ||
| 222 | ktrace_entry_t *ktep; | ||
| 223 | int index; | ||
| 224 | int nentries; | ||
| 225 | |||
| 226 | if (ktp->kt_rollover) | ||
| 227 | index = atomic_read(&ktp->kt_index) & ktp->kt_index_mask; | ||
| 228 | else | ||
| 229 | index = 0; | ||
| 230 | |||
| 231 | ktsp->ks_start = index; | ||
| 232 | ktep = &(ktp->kt_entries[index]); | ||
| 233 | |||
| 234 | nentries = ktrace_nentries(ktp); | ||
| 235 | index++; | ||
| 236 | if (index < nentries) { | ||
| 237 | ktsp->ks_index = index; | ||
| 238 | } else { | ||
| 239 | ktsp->ks_index = 0; | ||
| 240 | if (index > nentries) | ||
| 241 | ktep = NULL; | ||
| 242 | } | ||
| 243 | return ktep; | ||
| 244 | } | ||
| 245 | |||
| 246 | /* | ||
| 247 | * ktrace_next() | ||
| 248 | * | ||
| 249 | * This is used to iterate through the entries of the given | ||
| 250 | * trace buffer. The caller must pass in the ktrace_snap_t | ||
| 251 | * structure initialized by ktrace_first(). The return value | ||
| 252 | * will be either a pointer to the next ktrace_entry or NULL | ||
| 253 | * if all of the entries have been traversed. | ||
| 254 | */ | ||
| 255 | ktrace_entry_t * | ||
| 256 | ktrace_next( | ||
| 257 | ktrace_t *ktp, | ||
| 258 | ktrace_snap_t *ktsp) | ||
| 259 | { | ||
| 260 | int index; | ||
| 261 | ktrace_entry_t *ktep; | ||
| 262 | |||
| 263 | index = ktsp->ks_index; | ||
| 264 | if (index == ktsp->ks_start) { | ||
| 265 | ktep = NULL; | ||
| 266 | } else { | ||
| 267 | ktep = &ktp->kt_entries[index]; | ||
| 268 | } | ||
| 269 | |||
| 270 | index++; | ||
| 271 | if (index == ktrace_nentries(ktp)) { | ||
| 272 | ktsp->ks_index = 0; | ||
| 273 | } else { | ||
| 274 | ktsp->ks_index = index; | ||
| 275 | } | ||
| 276 | |||
| 277 | return ktep; | ||
| 278 | } | ||
| 279 | |||
| 280 | /* | ||
| 281 | * ktrace_skip() | ||
| 282 | * | ||
| 283 | * Skip the next "count" entries and return the entry after that. | ||
| 284 | * Return NULL if this causes us to iterate past the beginning again. | ||
| 285 | */ | ||
| 286 | ktrace_entry_t * | ||
| 287 | ktrace_skip( | ||
| 288 | ktrace_t *ktp, | ||
| 289 | int count, | ||
| 290 | ktrace_snap_t *ktsp) | ||
| 291 | { | ||
| 292 | int index; | ||
| 293 | int new_index; | ||
| 294 | ktrace_entry_t *ktep; | ||
| 295 | int nentries = ktrace_nentries(ktp); | ||
| 296 | |||
| 297 | index = ktsp->ks_index; | ||
| 298 | new_index = index + count; | ||
| 299 | while (new_index >= nentries) { | ||
| 300 | new_index -= nentries; | ||
| 301 | } | ||
| 302 | if (index == ktsp->ks_start) { | ||
| 303 | /* | ||
| 304 | * We've iterated around to the start, so we're done. | ||
| 305 | */ | ||
| 306 | ktep = NULL; | ||
| 307 | } else if ((new_index < index) && (index < ktsp->ks_index)) { | ||
| 308 | /* | ||
| 309 | * We've skipped past the start again, so we're done. | ||
| 310 | */ | ||
| 311 | ktep = NULL; | ||
| 312 | ktsp->ks_index = ktsp->ks_start; | ||
| 313 | } else { | ||
| 314 | ktep = &(ktp->kt_entries[new_index]); | ||
| 315 | new_index++; | ||
| 316 | if (new_index == nentries) { | ||
| 317 | ktsp->ks_index = 0; | ||
| 318 | } else { | ||
| 319 | ktsp->ks_index = new_index; | ||
| 320 | } | ||
| 321 | } | ||
| 322 | return ktep; | ||
| 323 | } | ||
diff --git a/fs/xfs/support/ktrace.h b/fs/xfs/support/ktrace.h deleted file mode 100644 index 741d6947ca60..000000000000 --- a/fs/xfs/support/ktrace.h +++ /dev/null | |||
| @@ -1,85 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. | ||
| 3 | * All Rights Reserved. | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU General Public License as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it would be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program; if not, write the Free Software Foundation, | ||
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | #ifndef __XFS_SUPPORT_KTRACE_H__ | ||
| 19 | #define __XFS_SUPPORT_KTRACE_H__ | ||
| 20 | |||
| 21 | /* | ||
| 22 | * Trace buffer entry structure. | ||
| 23 | */ | ||
| 24 | typedef struct ktrace_entry { | ||
| 25 | void *val[16]; | ||
| 26 | } ktrace_entry_t; | ||
| 27 | |||
| 28 | /* | ||
| 29 | * Trace buffer header structure. | ||
| 30 | */ | ||
| 31 | typedef struct ktrace { | ||
| 32 | int kt_nentries; /* number of entries in trace buf */ | ||
| 33 | atomic_t kt_index; /* current index in entries */ | ||
| 34 | unsigned int kt_index_mask; | ||
| 35 | int kt_rollover; | ||
| 36 | ktrace_entry_t *kt_entries; /* buffer of entries */ | ||
| 37 | } ktrace_t; | ||
| 38 | |||
| 39 | /* | ||
| 40 | * Trace buffer snapshot structure. | ||
| 41 | */ | ||
| 42 | typedef struct ktrace_snap { | ||
| 43 | int ks_start; /* kt_index at time of snap */ | ||
| 44 | int ks_index; /* current index */ | ||
| 45 | } ktrace_snap_t; | ||
| 46 | |||
| 47 | |||
| 48 | #ifdef CONFIG_XFS_TRACE | ||
| 49 | |||
| 50 | extern void ktrace_init(int zentries); | ||
| 51 | extern void ktrace_uninit(void); | ||
| 52 | |||
| 53 | extern ktrace_t *ktrace_alloc(int, unsigned int __nocast); | ||
| 54 | extern void ktrace_free(ktrace_t *); | ||
| 55 | |||
| 56 | extern void ktrace_enter( | ||
| 57 | ktrace_t *, | ||
| 58 | void *, | ||
| 59 | void *, | ||
| 60 | void *, | ||
| 61 | void *, | ||
| 62 | void *, | ||
| 63 | void *, | ||
| 64 | void *, | ||
| 65 | void *, | ||
| 66 | void *, | ||
| 67 | void *, | ||
| 68 | void *, | ||
| 69 | void *, | ||
| 70 | void *, | ||
| 71 | void *, | ||
| 72 | void *, | ||
| 73 | void *); | ||
| 74 | |||
| 75 | extern ktrace_entry_t *ktrace_first(ktrace_t *, ktrace_snap_t *); | ||
| 76 | extern int ktrace_nentries(ktrace_t *); | ||
| 77 | extern ktrace_entry_t *ktrace_next(ktrace_t *, ktrace_snap_t *); | ||
| 78 | extern ktrace_entry_t *ktrace_skip(ktrace_t *, int, ktrace_snap_t *); | ||
| 79 | |||
| 80 | #else | ||
| 81 | #define ktrace_init(x) do { } while (0) | ||
| 82 | #define ktrace_uninit() do { } while (0) | ||
| 83 | #endif /* CONFIG_XFS_TRACE */ | ||
| 84 | |||
| 85 | #endif /* __XFS_SUPPORT_KTRACE_H__ */ | ||
diff --git a/fs/xfs/xfs.h b/fs/xfs/xfs.h index 17254b529c54..5ad8ad3a1dcd 100644 --- a/fs/xfs/xfs.h +++ b/fs/xfs/xfs.h | |||
| @@ -25,21 +25,5 @@ | |||
| 25 | /* #define QUOTADEBUG 1 */ | 25 | /* #define QUOTADEBUG 1 */ |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| 28 | #ifdef CONFIG_XFS_TRACE | ||
| 29 | #define XFS_ALLOC_TRACE 1 | ||
| 30 | #define XFS_ATTR_TRACE 1 | ||
| 31 | #define XFS_BLI_TRACE 1 | ||
| 32 | #define XFS_BMAP_TRACE 1 | ||
| 33 | #define XFS_BTREE_TRACE 1 | ||
| 34 | #define XFS_DIR2_TRACE 1 | ||
| 35 | #define XFS_DQUOT_TRACE 1 | ||
| 36 | #define XFS_ILOCK_TRACE 1 | ||
| 37 | #define XFS_LOG_TRACE 1 | ||
| 38 | #define XFS_RW_TRACE 1 | ||
| 39 | #define XFS_BUF_TRACE 1 | ||
| 40 | #define XFS_INODE_TRACE 1 | ||
| 41 | #define XFS_FILESTREAMS_TRACE 1 | ||
| 42 | #endif | ||
| 43 | |||
| 44 | #include <linux-2.6/xfs_linux.h> | 28 | #include <linux-2.6/xfs_linux.h> |
| 45 | #endif /* __XFS_H__ */ | 29 | #endif /* __XFS_H__ */ |
diff --git a/fs/xfs/xfs_acl.h b/fs/xfs/xfs_acl.h index 947b150df8ed..00fd357c3e46 100644 --- a/fs/xfs/xfs_acl.h +++ b/fs/xfs/xfs_acl.h | |||
| @@ -49,7 +49,8 @@ extern int xfs_acl_chmod(struct inode *inode); | |||
| 49 | extern int posix_acl_access_exists(struct inode *inode); | 49 | extern int posix_acl_access_exists(struct inode *inode); |
| 50 | extern int posix_acl_default_exists(struct inode *inode); | 50 | extern int posix_acl_default_exists(struct inode *inode); |
| 51 | 51 | ||
| 52 | extern struct xattr_handler xfs_xattr_system_handler; | 52 | extern struct xattr_handler xfs_xattr_acl_access_handler; |
| 53 | extern struct xattr_handler xfs_xattr_acl_default_handler; | ||
| 53 | #else | 54 | #else |
| 54 | # define xfs_check_acl NULL | 55 | # define xfs_check_acl NULL |
| 55 | # define xfs_get_acl(inode, type) NULL | 56 | # define xfs_get_acl(inode, type) NULL |
diff --git a/fs/xfs/xfs_ag.h b/fs/xfs/xfs_ag.h index a5d54bf4931b..6702bd865811 100644 --- a/fs/xfs/xfs_ag.h +++ b/fs/xfs/xfs_ag.h | |||
| @@ -86,6 +86,20 @@ typedef struct xfs_agf { | |||
| 86 | #define XFS_AGF_NUM_BITS 12 | 86 | #define XFS_AGF_NUM_BITS 12 |
| 87 | #define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1) | 87 | #define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1) |
| 88 | 88 | ||
| 89 | #define XFS_AGF_FLAGS \ | ||
| 90 | { XFS_AGF_MAGICNUM, "MAGICNUM" }, \ | ||
| 91 | { XFS_AGF_VERSIONNUM, "VERSIONNUM" }, \ | ||
| 92 | { XFS_AGF_SEQNO, "SEQNO" }, \ | ||
| 93 | { XFS_AGF_LENGTH, "LENGTH" }, \ | ||
| 94 | { XFS_AGF_ROOTS, "ROOTS" }, \ | ||
| 95 | { XFS_AGF_LEVELS, "LEVELS" }, \ | ||
| 96 | { XFS_AGF_FLFIRST, "FLFIRST" }, \ | ||
| 97 | { XFS_AGF_FLLAST, "FLLAST" }, \ | ||
| 98 | { XFS_AGF_FLCOUNT, "FLCOUNT" }, \ | ||
| 99 | { XFS_AGF_FREEBLKS, "FREEBLKS" }, \ | ||
| 100 | { XFS_AGF_LONGEST, "LONGEST" }, \ | ||
| 101 | { XFS_AGF_BTREEBLKS, "BTREEBLKS" } | ||
| 102 | |||
| 89 | /* disk block (xfs_daddr_t) in the AG */ | 103 | /* disk block (xfs_daddr_t) in the AG */ |
| 90 | #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) | 104 | #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) |
| 91 | #define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp)) | 105 | #define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp)) |
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c index 2cf944eb796d..a1c65fc6d9c4 100644 --- a/fs/xfs/xfs_alloc.c +++ b/fs/xfs/xfs_alloc.c | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | #include "xfs_ialloc.h" | 38 | #include "xfs_ialloc.h" |
| 39 | #include "xfs_alloc.h" | 39 | #include "xfs_alloc.h" |
| 40 | #include "xfs_error.h" | 40 | #include "xfs_error.h" |
| 41 | #include "xfs_trace.h" | ||
| 41 | 42 | ||
| 42 | 43 | ||
| 43 | #define XFS_ABSDIFF(a,b) (((a) <= (b)) ? ((b) - (a)) : ((a) - (b))) | 44 | #define XFS_ABSDIFF(a,b) (((a) <= (b)) ? ((b) - (a)) : ((a) - (b))) |
| @@ -51,30 +52,6 @@ xfs_alloc_search_busy(xfs_trans_t *tp, | |||
| 51 | xfs_agblock_t bno, | 52 | xfs_agblock_t bno, |
| 52 | xfs_extlen_t len); | 53 | xfs_extlen_t len); |
| 53 | 54 | ||
| 54 | #if defined(XFS_ALLOC_TRACE) | ||
| 55 | ktrace_t *xfs_alloc_trace_buf; | ||
| 56 | |||
| 57 | #define TRACE_ALLOC(s,a) \ | ||
| 58 | xfs_alloc_trace_alloc(__func__, s, a, __LINE__) | ||
| 59 | #define TRACE_FREE(s,a,b,x,f) \ | ||
| 60 | xfs_alloc_trace_free(__func__, s, mp, a, b, x, f, __LINE__) | ||
| 61 | #define TRACE_MODAGF(s,a,f) \ | ||
| 62 | xfs_alloc_trace_modagf(__func__, s, mp, a, f, __LINE__) | ||
| 63 | #define TRACE_BUSY(__func__,s,ag,agb,l,sl,tp) \ | ||
| 64 | xfs_alloc_trace_busy(__func__, s, mp, ag, agb, l, sl, tp, XFS_ALLOC_KTRACE_BUSY, __LINE__) | ||
| 65 | #define TRACE_UNBUSY(__func__,s,ag,sl,tp) \ | ||
| 66 | xfs_alloc_trace_busy(__func__, s, mp, ag, -1, -1, sl, tp, XFS_ALLOC_KTRACE_UNBUSY, __LINE__) | ||
| 67 | #define TRACE_BUSYSEARCH(__func__,s,ag,agb,l,tp) \ | ||
| 68 | xfs_alloc_trace_busy(__func__, s, mp, ag, agb, l, 0, tp, XFS_ALLOC_KTRACE_BUSYSEARCH, __LINE__) | ||
| 69 | #else | ||
| 70 | #define TRACE_ALLOC(s,a) | ||
| 71 | #define TRACE_FREE(s,a,b,x,f) | ||
| 72 | #define TRACE_MODAGF(s,a,f) | ||
| 73 | #define TRACE_BUSY(s,a,ag,agb,l,sl,tp) | ||
| 74 | #define TRACE_UNBUSY(fname,s,ag,sl,tp) | ||
| 75 | #define TRACE_BUSYSEARCH(fname,s,ag,agb,l,tp) | ||
| 76 | #endif /* XFS_ALLOC_TRACE */ | ||
| 77 | |||
| 78 | /* | 55 | /* |
| 79 | * Prototypes for per-ag allocation routines | 56 | * Prototypes for per-ag allocation routines |
| 80 | */ | 57 | */ |
| @@ -498,124 +475,6 @@ xfs_alloc_read_agfl( | |||
| 498 | return 0; | 475 | return 0; |
| 499 | } | 476 | } |
| 500 | 477 | ||
| 501 | #if defined(XFS_ALLOC_TRACE) | ||
| 502 | /* | ||
| 503 | * Add an allocation trace entry for an alloc call. | ||
| 504 | */ | ||
| 505 | STATIC void | ||
| 506 | xfs_alloc_trace_alloc( | ||
| 507 | const char *name, /* function tag string */ | ||
| 508 | char *str, /* additional string */ | ||
| 509 | xfs_alloc_arg_t *args, /* allocation argument structure */ | ||
| 510 | int line) /* source line number */ | ||
| 511 | { | ||
| 512 | ktrace_enter(xfs_alloc_trace_buf, | ||
| 513 | (void *)(__psint_t)(XFS_ALLOC_KTRACE_ALLOC | (line << 16)), | ||
| 514 | (void *)name, | ||
| 515 | (void *)str, | ||
| 516 | (void *)args->mp, | ||
| 517 | (void *)(__psunsigned_t)args->agno, | ||
| 518 | (void *)(__psunsigned_t)args->agbno, | ||
| 519 | (void *)(__psunsigned_t)args->minlen, | ||
| 520 | (void *)(__psunsigned_t)args->maxlen, | ||
| 521 | (void *)(__psunsigned_t)args->mod, | ||
| 522 | (void *)(__psunsigned_t)args->prod, | ||
| 523 | (void *)(__psunsigned_t)args->minleft, | ||
| 524 | (void *)(__psunsigned_t)args->total, | ||
| 525 | (void *)(__psunsigned_t)args->alignment, | ||
| 526 | (void *)(__psunsigned_t)args->len, | ||
| 527 | (void *)((((__psint_t)args->type) << 16) | | ||
| 528 | (__psint_t)args->otype), | ||
| 529 | (void *)(__psint_t)((args->wasdel << 3) | | ||
| 530 | (args->wasfromfl << 2) | | ||
| 531 | (args->isfl << 1) | | ||
| 532 | (args->userdata << 0))); | ||
| 533 | } | ||
| 534 | |||
| 535 | /* | ||
| 536 | * Add an allocation trace entry for a free call. | ||
| 537 | */ | ||
| 538 | STATIC void | ||
| 539 | xfs_alloc_trace_free( | ||
| 540 | const char *name, /* function tag string */ | ||
| 541 | char *str, /* additional string */ | ||
| 542 | xfs_mount_t *mp, /* file system mount point */ | ||
| 543 | xfs_agnumber_t agno, /* allocation group number */ | ||
| 544 | xfs_agblock_t agbno, /* a.g. relative block number */ | ||
| 545 | xfs_extlen_t len, /* length of extent */ | ||
| 546 | int isfl, /* set if is freelist allocation/free */ | ||
| 547 | int line) /* source line number */ | ||
| 548 | { | ||
| 549 | ktrace_enter(xfs_alloc_trace_buf, | ||
| 550 | (void *)(__psint_t)(XFS_ALLOC_KTRACE_FREE | (line << 16)), | ||
| 551 | (void *)name, | ||
| 552 | (void *)str, | ||
| 553 | (void *)mp, | ||
| 554 | (void *)(__psunsigned_t)agno, | ||
| 555 | (void *)(__psunsigned_t)agbno, | ||
| 556 | (void *)(__psunsigned_t)len, | ||
| 557 | (void *)(__psint_t)isfl, | ||
| 558 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); | ||
| 559 | } | ||
| 560 | |||
| 561 | /* | ||
| 562 | * Add an allocation trace entry for modifying an agf. | ||
| 563 | */ | ||
| 564 | STATIC void | ||
| 565 | xfs_alloc_trace_modagf( | ||
| 566 | const char *name, /* function tag string */ | ||
| 567 | char *str, /* additional string */ | ||
| 568 | xfs_mount_t *mp, /* file system mount point */ | ||
| 569 | xfs_agf_t *agf, /* new agf value */ | ||
| 570 | int flags, /* logging flags for agf */ | ||
| 571 | int line) /* source line number */ | ||
| 572 | { | ||
| 573 | ktrace_enter(xfs_alloc_trace_buf, | ||
| 574 | (void *)(__psint_t)(XFS_ALLOC_KTRACE_MODAGF | (line << 16)), | ||
| 575 | (void *)name, | ||
| 576 | (void *)str, | ||
| 577 | (void *)mp, | ||
| 578 | (void *)(__psint_t)flags, | ||
| 579 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_seqno), | ||
| 580 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_length), | ||
| 581 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_BNO]), | ||
| 582 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_roots[XFS_BTNUM_CNT]), | ||
| 583 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]), | ||
| 584 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]), | ||
| 585 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flfirst), | ||
| 586 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_fllast), | ||
| 587 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_flcount), | ||
| 588 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_freeblks), | ||
| 589 | (void *)(__psunsigned_t)be32_to_cpu(agf->agf_longest)); | ||
| 590 | } | ||
| 591 | |||
| 592 | STATIC void | ||
| 593 | xfs_alloc_trace_busy( | ||
| 594 | const char *name, /* function tag string */ | ||
| 595 | char *str, /* additional string */ | ||
| 596 | xfs_mount_t *mp, /* file system mount point */ | ||
| 597 | xfs_agnumber_t agno, /* allocation group number */ | ||
| 598 | xfs_agblock_t agbno, /* a.g. relative block number */ | ||
| 599 | xfs_extlen_t len, /* length of extent */ | ||
| 600 | int slot, /* perag Busy slot */ | ||
| 601 | xfs_trans_t *tp, | ||
| 602 | int trtype, /* type: add, delete, search */ | ||
| 603 | int line) /* source line number */ | ||
| 604 | { | ||
| 605 | ktrace_enter(xfs_alloc_trace_buf, | ||
| 606 | (void *)(__psint_t)(trtype | (line << 16)), | ||
| 607 | (void *)name, | ||
| 608 | (void *)str, | ||
| 609 | (void *)mp, | ||
| 610 | (void *)(__psunsigned_t)agno, | ||
| 611 | (void *)(__psunsigned_t)agbno, | ||
| 612 | (void *)(__psunsigned_t)len, | ||
| 613 | (void *)(__psint_t)slot, | ||
| 614 | (void *)tp, | ||
| 615 | NULL, NULL, NULL, NULL, NULL, NULL, NULL); | ||
| 616 | } | ||
| 617 | #endif /* XFS_ALLOC_TRACE */ | ||
| 618 | |||
| 619 | /* | 478 | /* |
| 620 | * Allocation group level functions. | 479 | * Allocation group level functions. |
| 621 | */ | 480 | */ |
| @@ -665,9 +524,6 @@ xfs_alloc_ag_vextent( | |||
| 665 | */ | 524 | */ |
| 666 | if (args->agbno != NULLAGBLOCK) { | 525 | if (args->agbno != NULLAGBLOCK) { |
| 667 | xfs_agf_t *agf; /* allocation group freelist header */ | 526 | xfs_agf_t *agf; /* allocation group freelist header */ |
| 668 | #ifdef XFS_ALLOC_TRACE | ||
| 669 | xfs_mount_t *mp = args->mp; | ||
| 670 | #endif | ||
| 671 | long slen = (long)args->len; | 527 | long slen = (long)args->len; |
| 672 | 528 | ||
| 673 | ASSERT(args->len >= args->minlen && args->len <= args->maxlen); | 529 | ASSERT(args->len >= args->minlen && args->len <= args->maxlen); |
| @@ -682,7 +538,6 @@ xfs_alloc_ag_vextent( | |||
| 682 | args->pag->pagf_freeblks -= args->len; | 538 | args->pag->pagf_freeblks -= args->len; |
| 683 | ASSERT(be32_to_cpu(agf->agf_freeblks) <= | 539 | ASSERT(be32_to_cpu(agf->agf_freeblks) <= |
| 684 | be32_to_cpu(agf->agf_length)); | 540 | be32_to_cpu(agf->agf_length)); |
| 685 | TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); | ||
| 686 | xfs_alloc_log_agf(args->tp, args->agbp, | 541 | xfs_alloc_log_agf(args->tp, args->agbp, |
| 687 | XFS_AGF_FREEBLKS); | 542 | XFS_AGF_FREEBLKS); |
| 688 | /* search the busylist for these blocks */ | 543 | /* search the busylist for these blocks */ |
| @@ -792,13 +647,14 @@ xfs_alloc_ag_vextent_exact( | |||
| 792 | } | 647 | } |
| 793 | xfs_btree_del_cursor(bno_cur, XFS_BTREE_NOERROR); | 648 | xfs_btree_del_cursor(bno_cur, XFS_BTREE_NOERROR); |
| 794 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 649 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
| 795 | TRACE_ALLOC("normal", args); | 650 | |
| 651 | trace_xfs_alloc_exact_done(args); | ||
| 796 | args->wasfromfl = 0; | 652 | args->wasfromfl = 0; |
| 797 | return 0; | 653 | return 0; |
| 798 | 654 | ||
| 799 | error0: | 655 | error0: |
| 800 | xfs_btree_del_cursor(bno_cur, XFS_BTREE_ERROR); | 656 | xfs_btree_del_cursor(bno_cur, XFS_BTREE_ERROR); |
| 801 | TRACE_ALLOC("error", args); | 657 | trace_xfs_alloc_exact_error(args); |
| 802 | return error; | 658 | return error; |
| 803 | } | 659 | } |
| 804 | 660 | ||
| @@ -958,7 +814,7 @@ xfs_alloc_ag_vextent_near( | |||
| 958 | args->len = blen; | 814 | args->len = blen; |
| 959 | if (!xfs_alloc_fix_minleft(args)) { | 815 | if (!xfs_alloc_fix_minleft(args)) { |
| 960 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 816 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
| 961 | TRACE_ALLOC("nominleft", args); | 817 | trace_xfs_alloc_near_nominleft(args); |
| 962 | return 0; | 818 | return 0; |
| 963 | } | 819 | } |
| 964 | blen = args->len; | 820 | blen = args->len; |
| @@ -981,7 +837,8 @@ xfs_alloc_ag_vextent_near( | |||
| 981 | goto error0; | 837 | goto error0; |
| 982 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 838 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
| 983 | xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR); | 839 | xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR); |
| 984 | TRACE_ALLOC("first", args); | 840 | |
| 841 | trace_xfs_alloc_near_first(args); | ||
| 985 | return 0; | 842 | return 0; |
| 986 | } | 843 | } |
| 987 | /* | 844 | /* |
| @@ -1272,7 +1129,7 @@ xfs_alloc_ag_vextent_near( | |||
| 1272 | * If we couldn't get anything, give up. | 1129 | * If we couldn't get anything, give up. |
| 1273 | */ | 1130 | */ |
| 1274 | if (bno_cur_lt == NULL && bno_cur_gt == NULL) { | 1131 | if (bno_cur_lt == NULL && bno_cur_gt == NULL) { |
| 1275 | TRACE_ALLOC("neither", args); | 1132 | trace_xfs_alloc_size_neither(args); |
| 1276 | args->agbno = NULLAGBLOCK; | 1133 | args->agbno = NULLAGBLOCK; |
| 1277 | return 0; | 1134 | return 0; |
| 1278 | } | 1135 | } |
| @@ -1299,7 +1156,7 @@ xfs_alloc_ag_vextent_near( | |||
| 1299 | args->len = XFS_EXTLEN_MIN(ltlena, args->maxlen); | 1156 | args->len = XFS_EXTLEN_MIN(ltlena, args->maxlen); |
| 1300 | xfs_alloc_fix_len(args); | 1157 | xfs_alloc_fix_len(args); |
| 1301 | if (!xfs_alloc_fix_minleft(args)) { | 1158 | if (!xfs_alloc_fix_minleft(args)) { |
| 1302 | TRACE_ALLOC("nominleft", args); | 1159 | trace_xfs_alloc_near_nominleft(args); |
| 1303 | xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR); | 1160 | xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR); |
| 1304 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 1161 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
| 1305 | return 0; | 1162 | return 0; |
| @@ -1314,13 +1171,18 @@ xfs_alloc_ag_vextent_near( | |||
| 1314 | if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur_lt, ltbno, ltlen, | 1171 | if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur_lt, ltbno, ltlen, |
| 1315 | ltnew, rlen, XFSA_FIXUP_BNO_OK))) | 1172 | ltnew, rlen, XFSA_FIXUP_BNO_OK))) |
| 1316 | goto error0; | 1173 | goto error0; |
| 1317 | TRACE_ALLOC(j ? "gt" : "lt", args); | 1174 | |
| 1175 | if (j) | ||
| 1176 | trace_xfs_alloc_near_greater(args); | ||
| 1177 | else | ||
| 1178 | trace_xfs_alloc_near_lesser(args); | ||
| 1179 | |||
| 1318 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 1180 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
| 1319 | xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR); | 1181 | xfs_btree_del_cursor(bno_cur_lt, XFS_BTREE_NOERROR); |
| 1320 | return 0; | 1182 | return 0; |
| 1321 | 1183 | ||
| 1322 | error0: | 1184 | error0: |
| 1323 | TRACE_ALLOC("error", args); | 1185 | trace_xfs_alloc_near_error(args); |
| 1324 | if (cnt_cur != NULL) | 1186 | if (cnt_cur != NULL) |
| 1325 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR); | 1187 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR); |
| 1326 | if (bno_cur_lt != NULL) | 1188 | if (bno_cur_lt != NULL) |
| @@ -1371,7 +1233,7 @@ xfs_alloc_ag_vextent_size( | |||
| 1371 | goto error0; | 1233 | goto error0; |
| 1372 | if (i == 0 || flen == 0) { | 1234 | if (i == 0 || flen == 0) { |
| 1373 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 1235 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
| 1374 | TRACE_ALLOC("noentry", args); | 1236 | trace_xfs_alloc_size_noentry(args); |
| 1375 | return 0; | 1237 | return 0; |
| 1376 | } | 1238 | } |
| 1377 | ASSERT(i == 1); | 1239 | ASSERT(i == 1); |
| @@ -1448,7 +1310,7 @@ xfs_alloc_ag_vextent_size( | |||
| 1448 | xfs_alloc_fix_len(args); | 1310 | xfs_alloc_fix_len(args); |
| 1449 | if (rlen < args->minlen || !xfs_alloc_fix_minleft(args)) { | 1311 | if (rlen < args->minlen || !xfs_alloc_fix_minleft(args)) { |
| 1450 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); | 1312 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR); |
| 1451 | TRACE_ALLOC("nominleft", args); | 1313 | trace_xfs_alloc_size_nominleft(args); |
| 1452 | args->agbno = NULLAGBLOCK; | 1314 | args->agbno = NULLAGBLOCK; |
| 1453 | return 0; | 1315 | return 0; |
| 1454 | } | 1316 | } |
| @@ -1471,11 +1333,11 @@ xfs_alloc_ag_vextent_size( | |||
| 1471 | args->agbno + args->len <= | 1333 | args->agbno + args->len <= |
| 1472 | be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length), | 1334 | be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length), |
| 1473 | error0); | 1335 | error0); |
| 1474 | TRACE_ALLOC("normal", args); | 1336 | trace_xfs_alloc_size_done(args); |
| 1475 | return 0; | 1337 | return 0; |
| 1476 | 1338 | ||
| 1477 | error0: | 1339 | error0: |
| 1478 | TRACE_ALLOC("error", args); | 1340 | trace_xfs_alloc_size_error(args); |
| 1479 | if (cnt_cur) | 1341 | if (cnt_cur) |
| 1480 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR); | 1342 | xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR); |
| 1481 | if (bno_cur) | 1343 | if (bno_cur) |
| @@ -1534,7 +1396,7 @@ xfs_alloc_ag_vextent_small( | |||
| 1534 | be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length), | 1396 | be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length), |
| 1535 | error0); | 1397 | error0); |
| 1536 | args->wasfromfl = 1; | 1398 | args->wasfromfl = 1; |
| 1537 | TRACE_ALLOC("freelist", args); | 1399 | trace_xfs_alloc_small_freelist(args); |
| 1538 | *stat = 0; | 1400 | *stat = 0; |
| 1539 | return 0; | 1401 | return 0; |
| 1540 | } | 1402 | } |
| @@ -1556,17 +1418,17 @@ xfs_alloc_ag_vextent_small( | |||
| 1556 | */ | 1418 | */ |
| 1557 | if (flen < args->minlen) { | 1419 | if (flen < args->minlen) { |
| 1558 | args->agbno = NULLAGBLOCK; | 1420 | args->agbno = NULLAGBLOCK; |
| 1559 | TRACE_ALLOC("notenough", args); | 1421 | trace_xfs_alloc_small_notenough(args); |
| 1560 | flen = 0; | 1422 | flen = 0; |
| 1561 | } | 1423 | } |
| 1562 | *fbnop = fbno; | 1424 | *fbnop = fbno; |
| 1563 | *flenp = flen; | 1425 | *flenp = flen; |
| 1564 | *stat = 1; | 1426 | *stat = 1; |
| 1565 | TRACE_ALLOC("normal", args); | 1427 | trace_xfs_alloc_small_done(args); |
| 1566 | return 0; | 1428 | return 0; |
| 1567 | 1429 | ||
| 1568 | error0: | 1430 | error0: |
| 1569 | TRACE_ALLOC("error", args); | 1431 | trace_xfs_alloc_small_error(args); |
| 1570 | return error; | 1432 | return error; |
| 1571 | } | 1433 | } |
| 1572 | 1434 | ||
| @@ -1809,17 +1671,14 @@ xfs_free_ag_extent( | |||
| 1809 | be32_to_cpu(agf->agf_freeblks) <= | 1671 | be32_to_cpu(agf->agf_freeblks) <= |
| 1810 | be32_to_cpu(agf->agf_length), | 1672 | be32_to_cpu(agf->agf_length), |
| 1811 | error0); | 1673 | error0); |
| 1812 | TRACE_MODAGF(NULL, agf, XFS_AGF_FREEBLKS); | ||
| 1813 | xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS); | 1674 | xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS); |
| 1814 | if (!isfl) | 1675 | if (!isfl) |
| 1815 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, (long)len); | 1676 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, (long)len); |
| 1816 | XFS_STATS_INC(xs_freex); | 1677 | XFS_STATS_INC(xs_freex); |
| 1817 | XFS_STATS_ADD(xs_freeb, len); | 1678 | XFS_STATS_ADD(xs_freeb, len); |
| 1818 | } | 1679 | } |
| 1819 | TRACE_FREE(haveleft ? | 1680 | |
| 1820 | (haveright ? "both" : "left") : | 1681 | trace_xfs_free_extent(mp, agno, bno, len, isfl, haveleft, haveright); |
| 1821 | (haveright ? "right" : "none"), | ||
| 1822 | agno, bno, len, isfl); | ||
| 1823 | 1682 | ||
| 1824 | /* | 1683 | /* |
| 1825 | * Since blocks move to the free list without the coordination | 1684 | * Since blocks move to the free list without the coordination |
| @@ -1836,7 +1695,7 @@ xfs_free_ag_extent( | |||
| 1836 | return 0; | 1695 | return 0; |
| 1837 | 1696 | ||
| 1838 | error0: | 1697 | error0: |
| 1839 | TRACE_FREE("error", agno, bno, len, isfl); | 1698 | trace_xfs_free_extent(mp, agno, bno, len, isfl, -1, -1); |
| 1840 | if (bno_cur) | 1699 | if (bno_cur) |
| 1841 | xfs_btree_del_cursor(bno_cur, XFS_BTREE_ERROR); | 1700 | xfs_btree_del_cursor(bno_cur, XFS_BTREE_ERROR); |
| 1842 | if (cnt_cur) | 1701 | if (cnt_cur) |
| @@ -2122,7 +1981,6 @@ xfs_alloc_get_freelist( | |||
| 2122 | logflags |= XFS_AGF_BTREEBLKS; | 1981 | logflags |= XFS_AGF_BTREEBLKS; |
| 2123 | } | 1982 | } |
| 2124 | 1983 | ||
| 2125 | TRACE_MODAGF(NULL, agf, logflags); | ||
| 2126 | xfs_alloc_log_agf(tp, agbp, logflags); | 1984 | xfs_alloc_log_agf(tp, agbp, logflags); |
| 2127 | *bnop = bno; | 1985 | *bnop = bno; |
| 2128 | 1986 | ||
| @@ -2165,6 +2023,8 @@ xfs_alloc_log_agf( | |||
| 2165 | sizeof(xfs_agf_t) | 2023 | sizeof(xfs_agf_t) |
| 2166 | }; | 2024 | }; |
| 2167 | 2025 | ||
| 2026 | trace_xfs_agf(tp->t_mountp, XFS_BUF_TO_AGF(bp), fields, _RET_IP_); | ||
| 2027 | |||
| 2168 | xfs_btree_offsets(fields, offsets, XFS_AGF_NUM_BITS, &first, &last); | 2028 | xfs_btree_offsets(fields, offsets, XFS_AGF_NUM_BITS, &first, &last); |
| 2169 | xfs_trans_log_buf(tp, bp, (uint)first, (uint)last); | 2029 | xfs_trans_log_buf(tp, bp, (uint)first, (uint)last); |
| 2170 | } | 2030 | } |
| @@ -2230,13 +2090,11 @@ xfs_alloc_put_freelist( | |||
| 2230 | logflags |= XFS_AGF_BTREEBLKS; | 2090 | logflags |= XFS_AGF_BTREEBLKS; |
| 2231 | } | 2091 | } |
| 2232 | 2092 | ||
| 2233 | TRACE_MODAGF(NULL, agf, logflags); | ||
| 2234 | xfs_alloc_log_agf(tp, agbp, logflags); | 2093 | xfs_alloc_log_agf(tp, agbp, logflags); |
| 2235 | 2094 | ||
| 2236 | ASSERT(be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp)); | 2095 | ASSERT(be32_to_cpu(agf->agf_flcount) <= XFS_AGFL_SIZE(mp)); |
| 2237 | blockp = &agfl->agfl_bno[be32_to_cpu(agf->agf_fllast)]; | 2096 | blockp = &agfl->agfl_bno[be32_to_cpu(agf->agf_fllast)]; |
| 2238 | *blockp = cpu_to_be32(bno); | 2097 | *blockp = cpu_to_be32(bno); |
| 2239 | TRACE_MODAGF(NULL, agf, logflags); | ||
| 2240 | xfs_alloc_log_agf(tp, agbp, logflags); | 2098 | xfs_alloc_log_agf(tp, agbp, logflags); |
| 2241 | xfs_trans_log_buf(tp, agflbp, | 2099 | xfs_trans_log_buf(tp, agflbp, |
| 2242 | (int)((xfs_caddr_t)blockp - (xfs_caddr_t)agfl), | 2100 | (int)((xfs_caddr_t)blockp - (xfs_caddr_t)agfl), |
| @@ -2399,7 +2257,7 @@ xfs_alloc_vextent( | |||
| 2399 | args->minlen > args->maxlen || args->minlen > agsize || | 2257 | args->minlen > args->maxlen || args->minlen > agsize || |
| 2400 | args->mod >= args->prod) { | 2258 | args->mod >= args->prod) { |
| 2401 | args->fsbno = NULLFSBLOCK; | 2259 | args->fsbno = NULLFSBLOCK; |
| 2402 | TRACE_ALLOC("badargs", args); | 2260 | trace_xfs_alloc_vextent_badargs(args); |
| 2403 | return 0; | 2261 | return 0; |
| 2404 | } | 2262 | } |
| 2405 | minleft = args->minleft; | 2263 | minleft = args->minleft; |
| @@ -2418,12 +2276,12 @@ xfs_alloc_vextent( | |||
| 2418 | error = xfs_alloc_fix_freelist(args, 0); | 2276 | error = xfs_alloc_fix_freelist(args, 0); |
| 2419 | args->minleft = minleft; | 2277 | args->minleft = minleft; |
| 2420 | if (error) { | 2278 | if (error) { |
| 2421 | TRACE_ALLOC("nofix", args); | 2279 | trace_xfs_alloc_vextent_nofix(args); |
| 2422 | goto error0; | 2280 | goto error0; |
| 2423 | } | 2281 | } |
| 2424 | if (!args->agbp) { | 2282 | if (!args->agbp) { |
| 2425 | up_read(&mp->m_peraglock); | 2283 | up_read(&mp->m_peraglock); |
| 2426 | TRACE_ALLOC("noagbp", args); | 2284 | trace_xfs_alloc_vextent_noagbp(args); |
| 2427 | break; | 2285 | break; |
| 2428 | } | 2286 | } |
| 2429 | args->agbno = XFS_FSB_TO_AGBNO(mp, args->fsbno); | 2287 | args->agbno = XFS_FSB_TO_AGBNO(mp, args->fsbno); |
| @@ -2488,7 +2346,7 @@ xfs_alloc_vextent( | |||
| 2488 | error = xfs_alloc_fix_freelist(args, flags); | 2346 | error = xfs_alloc_fix_freelist(args, flags); |
| 2489 | args->minleft = minleft; | 2347 | args->minleft = minleft; |
| 2490 | if (error) { | 2348 | if (error) { |
| 2491 | TRACE_ALLOC("nofix", args); | 2349 | trace_xfs_alloc_vextent_nofix(args); |
| 2492 | goto error0; | 2350 | goto error0; |
| 2493 | } | 2351 | } |
| 2494 | /* | 2352 | /* |
| @@ -2499,7 +2357,9 @@ xfs_alloc_vextent( | |||
| 2499 | goto error0; | 2357 | goto error0; |
| 2500 | break; | 2358 | break; |
| 2501 | } | 2359 | } |
| 2502 | TRACE_ALLOC("loopfailed", args); | 2360 | |
| 2361 | trace_xfs_alloc_vextent_loopfailed(args); | ||
| 2362 | |||
| 2503 | /* | 2363 | /* |
| 2504 | * Didn't work, figure out the next iteration. | 2364 | * Didn't work, figure out the next iteration. |
| 2505 | */ | 2365 | */ |
| @@ -2526,7 +2386,7 @@ xfs_alloc_vextent( | |||
| 2526 | if (args->agno == sagno) { | 2386 | if (args->agno == sagno) { |
| 2527 | if (no_min == 1) { | 2387 | if (no_min == 1) { |
| 2528 | args->agbno = NULLAGBLOCK; | 2388 | args->agbno = NULLAGBLOCK; |
| 2529 | TRACE_ALLOC("allfailed", args); | 2389 | trace_xfs_alloc_vextent_allfailed(args); |
| 2530 | break; | 2390 | break; |
| 2531 | } | 2391 | } |
| 2532 | if (flags == 0) { | 2392 | if (flags == 0) { |
| @@ -2642,16 +2502,16 @@ xfs_alloc_mark_busy(xfs_trans_t *tp, | |||
| 2642 | } | 2502 | } |
| 2643 | } | 2503 | } |
| 2644 | 2504 | ||
| 2505 | trace_xfs_alloc_busy(mp, agno, bno, len, n); | ||
| 2506 | |||
| 2645 | if (n < XFS_PAGB_NUM_SLOTS) { | 2507 | if (n < XFS_PAGB_NUM_SLOTS) { |
| 2646 | bsy = &mp->m_perag[agno].pagb_list[n]; | 2508 | bsy = &mp->m_perag[agno].pagb_list[n]; |
| 2647 | mp->m_perag[agno].pagb_count++; | 2509 | mp->m_perag[agno].pagb_count++; |
| 2648 | TRACE_BUSY("xfs_alloc_mark_busy", "got", agno, bno, len, n, tp); | ||
| 2649 | bsy->busy_start = bno; | 2510 | bsy->busy_start = bno; |
| 2650 | bsy->busy_length = len; | 2511 | bsy->busy_length = len; |
| 2651 | bsy->busy_tp = tp; | 2512 | bsy->busy_tp = tp; |
| 2652 | xfs_trans_add_busy(tp, agno, n); | 2513 | xfs_trans_add_busy(tp, agno, n); |
| 2653 | } else { | 2514 | } else { |
| 2654 | TRACE_BUSY("xfs_alloc_mark_busy", "FULL", agno, bno, len, -1, tp); | ||
| 2655 | /* | 2515 | /* |
| 2656 | * The busy list is full! Since it is now not possible to | 2516 | * The busy list is full! Since it is now not possible to |
| 2657 | * track the free block, make this a synchronous transaction | 2517 | * track the free block, make this a synchronous transaction |
| @@ -2678,12 +2538,12 @@ xfs_alloc_clear_busy(xfs_trans_t *tp, | |||
| 2678 | list = mp->m_perag[agno].pagb_list; | 2538 | list = mp->m_perag[agno].pagb_list; |
| 2679 | 2539 | ||
| 2680 | ASSERT(idx < XFS_PAGB_NUM_SLOTS); | 2540 | ASSERT(idx < XFS_PAGB_NUM_SLOTS); |
| 2541 | |||
| 2542 | trace_xfs_alloc_unbusy(mp, agno, idx, list[idx].busy_tp == tp); | ||
| 2543 | |||
| 2681 | if (list[idx].busy_tp == tp) { | 2544 | if (list[idx].busy_tp == tp) { |
| 2682 | TRACE_UNBUSY("xfs_alloc_clear_busy", "found", agno, idx, tp); | ||
| 2683 | list[idx].busy_tp = NULL; | 2545 | list[idx].busy_tp = NULL; |
| 2684 | mp->m_perag[agno].pagb_count--; | 2546 | mp->m_perag[agno].pagb_count--; |
| 2685 | } else { | ||
| 2686 | TRACE_UNBUSY("xfs_alloc_clear_busy", "missing", agno, idx, tp); | ||
| 2687 | } | 2547 | } |
| 2688 | 2548 | ||
| 2689 | spin_unlock(&mp->m_perag[agno].pagb_lock); | 2549 | spin_unlock(&mp->m_perag[agno].pagb_lock); |
| @@ -2724,24 +2584,22 @@ xfs_alloc_search_busy(xfs_trans_t *tp, | |||
| 2724 | if ((bno > bend) || (uend < bsy->busy_start)) { | 2584 | if ((bno > bend) || (uend < bsy->busy_start)) { |
| 2725 | cnt--; | 2585 | cnt--; |
| 2726 | } else { | 2586 | } else { |
| 2727 | TRACE_BUSYSEARCH("xfs_alloc_search_busy", | ||
| 2728 | "found1", agno, bno, len, tp); | ||
| 2729 | break; | 2587 | break; |
| 2730 | } | 2588 | } |
| 2731 | } | 2589 | } |
| 2732 | } | 2590 | } |
| 2733 | 2591 | ||
| 2592 | trace_xfs_alloc_busysearch(mp, agno, bno, len, !!cnt); | ||
| 2593 | |||
| 2734 | /* | 2594 | /* |
| 2735 | * If a block was found, force the log through the LSN of the | 2595 | * If a block was found, force the log through the LSN of the |
| 2736 | * transaction that freed the block | 2596 | * transaction that freed the block |
| 2737 | */ | 2597 | */ |
| 2738 | if (cnt) { | 2598 | if (cnt) { |
| 2739 | TRACE_BUSYSEARCH("xfs_alloc_search_busy", "found", agno, bno, len, tp); | ||
| 2740 | lsn = bsy->busy_tp->t_commit_lsn; | 2599 | lsn = bsy->busy_tp->t_commit_lsn; |
| 2741 | spin_unlock(&mp->m_perag[agno].pagb_lock); | 2600 | spin_unlock(&mp->m_perag[agno].pagb_lock); |
| 2742 | xfs_log_force(mp, lsn, XFS_LOG_FORCE|XFS_LOG_SYNC); | 2601 | xfs_log_force(mp, lsn, XFS_LOG_FORCE|XFS_LOG_SYNC); |
| 2743 | } else { | 2602 | } else { |
| 2744 | TRACE_BUSYSEARCH("xfs_alloc_search_busy", "not-found", agno, bno, len, tp); | ||
| 2745 | spin_unlock(&mp->m_perag[agno].pagb_lock); | 2603 | spin_unlock(&mp->m_perag[agno].pagb_lock); |
| 2746 | } | 2604 | } |
| 2747 | } | 2605 | } |
diff --git a/fs/xfs/xfs_alloc.h b/fs/xfs/xfs_alloc.h index e704caee10df..599bffa39784 100644 --- a/fs/xfs/xfs_alloc.h +++ b/fs/xfs/xfs_alloc.h | |||
| @@ -37,6 +37,15 @@ typedef enum xfs_alloctype | |||
| 37 | XFS_ALLOCTYPE_THIS_BNO /* at exactly this block */ | 37 | XFS_ALLOCTYPE_THIS_BNO /* at exactly this block */ |
| 38 | } xfs_alloctype_t; | 38 | } xfs_alloctype_t; |
| 39 | 39 | ||
| 40 | #define XFS_ALLOC_TYPES \ | ||
| 41 | { XFS_ALLOCTYPE_ANY_AG, "ANY_AG" }, \ | ||
| 42 | { XFS_ALLOCTYPE_FIRST_AG, "FIRST_AG" }, \ | ||
| 43 | { XFS_ALLOCTYPE_START_AG, "START_AG" }, \ | ||
| 44 | { XFS_ALLOCTYPE_THIS_AG, "THIS_AG" }, \ | ||
| 45 | { XFS_ALLOCTYPE_START_BNO, "START_BNO" }, \ | ||
| 46 | { XFS_ALLOCTYPE_NEAR_BNO, "NEAR_BNO" }, \ | ||
| 47 | { XFS_ALLOCTYPE_THIS_BNO, "THIS_BNO" } | ||
| 48 | |||
| 40 | /* | 49 | /* |
| 41 | * Flags for xfs_alloc_fix_freelist. | 50 | * Flags for xfs_alloc_fix_freelist. |
| 42 | */ | 51 | */ |
| @@ -109,24 +118,6 @@ xfs_alloc_longest_free_extent(struct xfs_mount *mp, | |||
| 109 | 118 | ||
| 110 | #ifdef __KERNEL__ | 119 | #ifdef __KERNEL__ |
| 111 | 120 | ||
| 112 | #if defined(XFS_ALLOC_TRACE) | ||
| 113 | /* | ||
| 114 | * Allocation tracing buffer size. | ||
| 115 | */ | ||
| 116 | #define XFS_ALLOC_TRACE_SIZE 4096 | ||
| 117 | extern ktrace_t *xfs_alloc_trace_buf; | ||
| 118 | |||
| 119 | /* | ||
| 120 | * Types for alloc tracing. | ||
| 121 | */ | ||
| 122 | #define XFS_ALLOC_KTRACE_ALLOC 1 | ||
| 123 | #define XFS_ALLOC_KTRACE_FREE 2 | ||
| 124 | #define XFS_ALLOC_KTRACE_MODAGF 3 | ||
| 125 | #define XFS_ALLOC_KTRACE_BUSY 4 | ||
| 126 | #define XFS_ALLOC_KTRACE_UNBUSY 5 | ||
| 127 | #define XFS_ALLOC_KTRACE_BUSYSEARCH 6 | ||
| 128 | #endif | ||
| 129 | |||
| 130 | void | 121 | void |
| 131 | xfs_alloc_mark_busy(xfs_trans_t *tp, | 122 | xfs_alloc_mark_busy(xfs_trans_t *tp, |
| 132 | xfs_agnumber_t agno, | 123 | xfs_agnumber_t agno, |
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c index c10c3a292d30..adbd9141aea1 100644 --- a/fs/xfs/xfs_alloc_btree.c +++ b/fs/xfs/xfs_alloc_btree.c | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | #include "xfs_ialloc.h" | 39 | #include "xfs_ialloc.h" |
| 40 | #include "xfs_alloc.h" | 40 | #include "xfs_alloc.h" |
| 41 | #include "xfs_error.h" | 41 | #include "xfs_error.h" |
| 42 | #include "xfs_trace.h" | ||
| 42 | 43 | ||
| 43 | 44 | ||
| 44 | STATIC struct xfs_btree_cur * | 45 | STATIC struct xfs_btree_cur * |
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c index 8fe6f6b78a4a..e953b6cfb2a8 100644 --- a/fs/xfs/xfs_attr.c +++ b/fs/xfs/xfs_attr.c | |||
| @@ -47,6 +47,7 @@ | |||
| 47 | #include "xfs_trans_space.h" | 47 | #include "xfs_trans_space.h" |
| 48 | #include "xfs_rw.h" | 48 | #include "xfs_rw.h" |
| 49 | #include "xfs_vnodeops.h" | 49 | #include "xfs_vnodeops.h" |
| 50 | #include "xfs_trace.h" | ||
| 50 | 51 | ||
| 51 | /* | 52 | /* |
| 52 | * xfs_attr.c | 53 | * xfs_attr.c |
| @@ -89,10 +90,6 @@ STATIC int xfs_attr_rmtval_remove(xfs_da_args_t *args); | |||
| 89 | 90 | ||
| 90 | #define ATTR_RMTVALUE_MAPSIZE 1 /* # of map entries at once */ | 91 | #define ATTR_RMTVALUE_MAPSIZE 1 /* # of map entries at once */ |
| 91 | 92 | ||
| 92 | #if defined(XFS_ATTR_TRACE) | ||
| 93 | ktrace_t *xfs_attr_trace_buf; | ||
| 94 | #endif | ||
| 95 | |||
| 96 | STATIC int | 93 | STATIC int |
| 97 | xfs_attr_name_to_xname( | 94 | xfs_attr_name_to_xname( |
| 98 | struct xfs_name *xname, | 95 | struct xfs_name *xname, |
| @@ -640,7 +637,6 @@ xfs_attr_list_int(xfs_attr_list_context_t *context) | |||
| 640 | return EIO; | 637 | return EIO; |
| 641 | 638 | ||
| 642 | xfs_ilock(dp, XFS_ILOCK_SHARED); | 639 | xfs_ilock(dp, XFS_ILOCK_SHARED); |
| 643 | xfs_attr_trace_l_c("syscall start", context); | ||
| 644 | 640 | ||
| 645 | /* | 641 | /* |
| 646 | * Decide on what work routines to call based on the inode size. | 642 | * Decide on what work routines to call based on the inode size. |
| @@ -656,7 +652,6 @@ xfs_attr_list_int(xfs_attr_list_context_t *context) | |||
| 656 | } | 652 | } |
| 657 | 653 | ||
| 658 | xfs_iunlock(dp, XFS_ILOCK_SHARED); | 654 | xfs_iunlock(dp, XFS_ILOCK_SHARED); |
| 659 | xfs_attr_trace_l_c("syscall end", context); | ||
| 660 | 655 | ||
| 661 | return error; | 656 | return error; |
| 662 | } | 657 | } |
| @@ -702,7 +697,7 @@ xfs_attr_put_listent(xfs_attr_list_context_t *context, int flags, | |||
| 702 | context->count * sizeof(alist->al_offset[0]); | 697 | context->count * sizeof(alist->al_offset[0]); |
| 703 | context->firstu -= ATTR_ENTSIZE(namelen); | 698 | context->firstu -= ATTR_ENTSIZE(namelen); |
| 704 | if (context->firstu < arraytop) { | 699 | if (context->firstu < arraytop) { |
| 705 | xfs_attr_trace_l_c("buffer full", context); | 700 | trace_xfs_attr_list_full(context); |
| 706 | alist->al_more = 1; | 701 | alist->al_more = 1; |
| 707 | context->seen_enough = 1; | 702 | context->seen_enough = 1; |
| 708 | return 1; | 703 | return 1; |
| @@ -714,7 +709,7 @@ xfs_attr_put_listent(xfs_attr_list_context_t *context, int flags, | |||
| 714 | aep->a_name[namelen] = 0; | 709 | aep->a_name[namelen] = 0; |
| 715 | alist->al_offset[context->count++] = context->firstu; | 710 | alist->al_offset[context->count++] = context->firstu; |
| 716 | alist->al_count = context->count; | 711 | alist->al_count = context->count; |
| 717 | xfs_attr_trace_l_c("add", context); | 712 | trace_xfs_attr_list_add(context); |
| 718 | return 0; | 713 | return 0; |
| 719 | } | 714 | } |
| 720 | 715 | ||
| @@ -1853,7 +1848,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
| 1853 | node = bp->data; | 1848 | node = bp->data; |
| 1854 | switch (be16_to_cpu(node->hdr.info.magic)) { | 1849 | switch (be16_to_cpu(node->hdr.info.magic)) { |
| 1855 | case XFS_DA_NODE_MAGIC: | 1850 | case XFS_DA_NODE_MAGIC: |
| 1856 | xfs_attr_trace_l_cn("wrong blk", context, node); | 1851 | trace_xfs_attr_list_wrong_blk(context); |
| 1857 | xfs_da_brelse(NULL, bp); | 1852 | xfs_da_brelse(NULL, bp); |
| 1858 | bp = NULL; | 1853 | bp = NULL; |
| 1859 | break; | 1854 | break; |
| @@ -1861,20 +1856,18 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
| 1861 | leaf = bp->data; | 1856 | leaf = bp->data; |
| 1862 | if (cursor->hashval > be32_to_cpu(leaf->entries[ | 1857 | if (cursor->hashval > be32_to_cpu(leaf->entries[ |
| 1863 | be16_to_cpu(leaf->hdr.count)-1].hashval)) { | 1858 | be16_to_cpu(leaf->hdr.count)-1].hashval)) { |
| 1864 | xfs_attr_trace_l_cl("wrong blk", | 1859 | trace_xfs_attr_list_wrong_blk(context); |
| 1865 | context, leaf); | ||
| 1866 | xfs_da_brelse(NULL, bp); | 1860 | xfs_da_brelse(NULL, bp); |
| 1867 | bp = NULL; | 1861 | bp = NULL; |
| 1868 | } else if (cursor->hashval <= | 1862 | } else if (cursor->hashval <= |
| 1869 | be32_to_cpu(leaf->entries[0].hashval)) { | 1863 | be32_to_cpu(leaf->entries[0].hashval)) { |
| 1870 | xfs_attr_trace_l_cl("maybe wrong blk", | 1864 | trace_xfs_attr_list_wrong_blk(context); |
| 1871 | context, leaf); | ||
| 1872 | xfs_da_brelse(NULL, bp); | 1865 | xfs_da_brelse(NULL, bp); |
| 1873 | bp = NULL; | 1866 | bp = NULL; |
| 1874 | } | 1867 | } |
| 1875 | break; | 1868 | break; |
| 1876 | default: | 1869 | default: |
| 1877 | xfs_attr_trace_l_c("wrong blk - ??", context); | 1870 | trace_xfs_attr_list_wrong_blk(context); |
| 1878 | xfs_da_brelse(NULL, bp); | 1871 | xfs_da_brelse(NULL, bp); |
| 1879 | bp = NULL; | 1872 | bp = NULL; |
| 1880 | } | 1873 | } |
| @@ -1919,8 +1912,8 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
| 1919 | if (cursor->hashval | 1912 | if (cursor->hashval |
| 1920 | <= be32_to_cpu(btree->hashval)) { | 1913 | <= be32_to_cpu(btree->hashval)) { |
| 1921 | cursor->blkno = be32_to_cpu(btree->before); | 1914 | cursor->blkno = be32_to_cpu(btree->before); |
| 1922 | xfs_attr_trace_l_cb("descending", | 1915 | trace_xfs_attr_list_node_descend(context, |
| 1923 | context, btree); | 1916 | btree); |
| 1924 | break; | 1917 | break; |
| 1925 | } | 1918 | } |
| 1926 | } | 1919 | } |
| @@ -2270,85 +2263,3 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args) | |||
| 2270 | } | 2263 | } |
| 2271 | return(0); | 2264 | return(0); |
| 2272 | } | 2265 | } |
| 2273 | |||
| 2274 | #if defined(XFS_ATTR_TRACE) | ||
| 2275 | /* | ||
| 2276 | * Add a trace buffer entry for an attr_list context structure. | ||
| 2277 | */ | ||
| 2278 | void | ||
| 2279 | xfs_attr_trace_l_c(char *where, struct xfs_attr_list_context *context) | ||
| 2280 | { | ||
| 2281 | xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_C, where, context, | ||
| 2282 | (__psunsigned_t)NULL, | ||
| 2283 | (__psunsigned_t)NULL, | ||
| 2284 | (__psunsigned_t)NULL); | ||
| 2285 | } | ||
| 2286 | |||
| 2287 | /* | ||
| 2288 | * Add a trace buffer entry for a context structure and a Btree node. | ||
| 2289 | */ | ||
| 2290 | void | ||
| 2291 | xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context, | ||
| 2292 | struct xfs_da_intnode *node) | ||
| 2293 | { | ||
| 2294 | xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_CN, where, context, | ||
| 2295 | (__psunsigned_t)be16_to_cpu(node->hdr.count), | ||
| 2296 | (__psunsigned_t)be32_to_cpu(node->btree[0].hashval), | ||
| 2297 | (__psunsigned_t)be32_to_cpu(node->btree[ | ||
| 2298 | be16_to_cpu(node->hdr.count)-1].hashval)); | ||
| 2299 | } | ||
| 2300 | |||
| 2301 | /* | ||
| 2302 | * Add a trace buffer entry for a context structure and a Btree element. | ||
| 2303 | */ | ||
| 2304 | void | ||
| 2305 | xfs_attr_trace_l_cb(char *where, struct xfs_attr_list_context *context, | ||
| 2306 | struct xfs_da_node_entry *btree) | ||
| 2307 | { | ||
| 2308 | xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_CB, where, context, | ||
| 2309 | (__psunsigned_t)be32_to_cpu(btree->hashval), | ||
| 2310 | (__psunsigned_t)be32_to_cpu(btree->before), | ||
| 2311 | (__psunsigned_t)NULL); | ||
| 2312 | } | ||
| 2313 | |||
| 2314 | /* | ||
| 2315 | * Add a trace buffer entry for a context structure and a leaf block. | ||
| 2316 | */ | ||
| 2317 | void | ||
| 2318 | xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context, | ||
| 2319 | struct xfs_attr_leafblock *leaf) | ||
| 2320 | { | ||
| 2321 | xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_CL, where, context, | ||
| 2322 | (__psunsigned_t)be16_to_cpu(leaf->hdr.count), | ||
| 2323 | (__psunsigned_t)be32_to_cpu(leaf->entries[0].hashval), | ||
| 2324 | (__psunsigned_t)be32_to_cpu(leaf->entries[ | ||
| 2325 | be16_to_cpu(leaf->hdr.count)-1].hashval)); | ||
| 2326 | } | ||
| 2327 | |||
| 2328 | /* | ||
| 2329 | * Add a trace buffer entry for the arguments given to the routine, | ||
| 2330 | * generic form. | ||
| 2331 | */ | ||
| 2332 | void | ||
| 2333 | xfs_attr_trace_enter(int type, char *where, | ||
| 2334 | struct xfs_attr_list_context *context, | ||
| 2335 | __psunsigned_t a13, __psunsigned_t a14, | ||
| 2336 | __psunsigned_t a15) | ||
| 2337 | { | ||
| 2338 | ASSERT(xfs_attr_trace_buf); | ||
| 2339 | ktrace_enter(xfs_attr_trace_buf, (void *)((__psunsigned_t)type), | ||
| 2340 | (void *)((__psunsigned_t)where), | ||
| 2341 | (void *)((__psunsigned_t)context->dp), | ||
| 2342 | (void *)((__psunsigned_t)context->cursor->hashval), | ||
| 2343 | (void *)((__psunsigned_t)context->cursor->blkno), | ||
| 2344 | (void *)((__psunsigned_t)context->cursor->offset), | ||
| 2345 | (void *)((__psunsigned_t)context->alist), | ||
| 2346 | (void *)((__psunsigned_t)context->bufsize), | ||
| 2347 | (void *)((__psunsigned_t)context->count), | ||
| 2348 | (void *)((__psunsigned_t)context->firstu), | ||
| 2349 | NULL, | ||
| 2350 | (void *)((__psunsigned_t)context->dupcnt), | ||
| 2351 | (void *)((__psunsigned_t)context->flags), | ||
| 2352 | (void *)a13, (void *)a14, (void *)a15); | ||
| 2353 | } | ||
| 2354 | #endif /* XFS_ATTR_TRACE */ | ||
diff --git a/fs/xfs/xfs_attr.h b/fs/xfs/xfs_attr.h index 12f0be3a73d4..59b410ce69a1 100644 --- a/fs/xfs/xfs_attr.h +++ b/fs/xfs/xfs_attr.h | |||
| @@ -48,6 +48,16 @@ struct xfs_attr_list_context; | |||
| 48 | #define ATTR_KERNOTIME 0x1000 /* [kernel] don't update inode timestamps */ | 48 | #define ATTR_KERNOTIME 0x1000 /* [kernel] don't update inode timestamps */ |
| 49 | #define ATTR_KERNOVAL 0x2000 /* [kernel] get attr size only, not value */ | 49 | #define ATTR_KERNOVAL 0x2000 /* [kernel] get attr size only, not value */ |
| 50 | 50 | ||
| 51 | #define XFS_ATTR_FLAGS \ | ||
| 52 | { ATTR_DONTFOLLOW, "DONTFOLLOW" }, \ | ||
| 53 | { ATTR_ROOT, "ROOT" }, \ | ||
| 54 | { ATTR_TRUST, "TRUST" }, \ | ||
| 55 | { ATTR_SECURE, "SECURE" }, \ | ||
| 56 | { ATTR_CREATE, "CREATE" }, \ | ||
| 57 | { ATTR_REPLACE, "REPLACE" }, \ | ||
| 58 | { ATTR_KERNOTIME, "KERNOTIME" }, \ | ||
| 59 | { ATTR_KERNOVAL, "KERNOVAL" } | ||
| 60 | |||
| 51 | /* | 61 | /* |
| 52 | * The maximum size (into the kernel or returned from the kernel) of an | 62 | * The maximum size (into the kernel or returned from the kernel) of an |
| 53 | * attribute value or the buffer used for an attr_list() call. Larger | 63 | * attribute value or the buffer used for an attr_list() call. Larger |
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c index 0b687351293f..baf41b5af756 100644 --- a/fs/xfs/xfs_attr_leaf.c +++ b/fs/xfs/xfs_attr_leaf.c | |||
| @@ -42,6 +42,7 @@ | |||
| 42 | #include "xfs_attr.h" | 42 | #include "xfs_attr.h" |
| 43 | #include "xfs_attr_leaf.h" | 43 | #include "xfs_attr_leaf.h" |
| 44 | #include "xfs_error.h" | 44 | #include "xfs_error.h" |
| 45 | #include "xfs_trace.h" | ||
| 45 | 46 | ||
| 46 | /* | 47 | /* |
| 47 | * xfs_attr_leaf.c | 48 | * xfs_attr_leaf.c |
| @@ -594,7 +595,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
| 594 | cursor = context->cursor; | 595 | cursor = context->cursor; |
| 595 | ASSERT(cursor != NULL); | 596 | ASSERT(cursor != NULL); |
| 596 | 597 | ||
| 597 | xfs_attr_trace_l_c("sf start", context); | 598 | trace_xfs_attr_list_sf(context); |
| 598 | 599 | ||
| 599 | /* | 600 | /* |
| 600 | * If the buffer is large enough and the cursor is at the start, | 601 | * If the buffer is large enough and the cursor is at the start, |
| @@ -627,7 +628,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
| 627 | return error; | 628 | return error; |
| 628 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); | 629 | sfe = XFS_ATTR_SF_NEXTENTRY(sfe); |
| 629 | } | 630 | } |
| 630 | xfs_attr_trace_l_c("sf big-gulp", context); | 631 | trace_xfs_attr_list_sf_all(context); |
| 631 | return(0); | 632 | return(0); |
| 632 | } | 633 | } |
| 633 | 634 | ||
| @@ -653,7 +654,6 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
| 653 | XFS_CORRUPTION_ERROR("xfs_attr_shortform_list", | 654 | XFS_CORRUPTION_ERROR("xfs_attr_shortform_list", |
| 654 | XFS_ERRLEVEL_LOW, | 655 | XFS_ERRLEVEL_LOW, |
| 655 | context->dp->i_mount, sfe); | 656 | context->dp->i_mount, sfe); |
| 656 | xfs_attr_trace_l_c("sf corrupted", context); | ||
| 657 | kmem_free(sbuf); | 657 | kmem_free(sbuf); |
| 658 | return XFS_ERROR(EFSCORRUPTED); | 658 | return XFS_ERROR(EFSCORRUPTED); |
| 659 | } | 659 | } |
| @@ -693,7 +693,6 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
| 693 | } | 693 | } |
| 694 | if (i == nsbuf) { | 694 | if (i == nsbuf) { |
| 695 | kmem_free(sbuf); | 695 | kmem_free(sbuf); |
| 696 | xfs_attr_trace_l_c("blk end", context); | ||
| 697 | return(0); | 696 | return(0); |
| 698 | } | 697 | } |
| 699 | 698 | ||
| @@ -719,7 +718,6 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
| 719 | } | 718 | } |
| 720 | 719 | ||
| 721 | kmem_free(sbuf); | 720 | kmem_free(sbuf); |
| 722 | xfs_attr_trace_l_c("sf E-O-F", context); | ||
| 723 | return(0); | 721 | return(0); |
| 724 | } | 722 | } |
| 725 | 723 | ||
| @@ -2323,7 +2321,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
| 2323 | cursor = context->cursor; | 2321 | cursor = context->cursor; |
| 2324 | cursor->initted = 1; | 2322 | cursor->initted = 1; |
| 2325 | 2323 | ||
| 2326 | xfs_attr_trace_l_cl("blk start", context, leaf); | 2324 | trace_xfs_attr_list_leaf(context); |
| 2327 | 2325 | ||
| 2328 | /* | 2326 | /* |
| 2329 | * Re-find our place in the leaf block if this is a new syscall. | 2327 | * Re-find our place in the leaf block if this is a new syscall. |
| @@ -2344,7 +2342,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
| 2344 | } | 2342 | } |
| 2345 | } | 2343 | } |
| 2346 | if (i == be16_to_cpu(leaf->hdr.count)) { | 2344 | if (i == be16_to_cpu(leaf->hdr.count)) { |
| 2347 | xfs_attr_trace_l_c("not found", context); | 2345 | trace_xfs_attr_list_notfound(context); |
| 2348 | return(0); | 2346 | return(0); |
| 2349 | } | 2347 | } |
| 2350 | } else { | 2348 | } else { |
| @@ -2419,7 +2417,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context) | |||
| 2419 | break; | 2417 | break; |
| 2420 | cursor->offset++; | 2418 | cursor->offset++; |
| 2421 | } | 2419 | } |
| 2422 | xfs_attr_trace_l_cl("blk end", context, leaf); | 2420 | trace_xfs_attr_list_leaf_end(context); |
| 2423 | return(retval); | 2421 | return(retval); |
| 2424 | } | 2422 | } |
| 2425 | 2423 | ||
diff --git a/fs/xfs/xfs_attr_sf.h b/fs/xfs/xfs_attr_sf.h index ea22839caed2..76ab7b0cbb3a 100644 --- a/fs/xfs/xfs_attr_sf.h +++ b/fs/xfs/xfs_attr_sf.h | |||
| @@ -25,8 +25,6 @@ | |||
| 25 | * to fit into the literal area of the inode. | 25 | * to fit into the literal area of the inode. |
| 26 | */ | 26 | */ |
| 27 | 27 | ||
| 28 | struct xfs_inode; | ||
| 29 | |||
| 30 | /* | 28 | /* |
| 31 | * Entries are packed toward the top as tight as possible. | 29 | * Entries are packed toward the top as tight as possible. |
| 32 | */ | 30 | */ |
| @@ -69,42 +67,4 @@ typedef struct xfs_attr_sf_sort { | |||
| 69 | (be16_to_cpu(((xfs_attr_shortform_t *) \ | 67 | (be16_to_cpu(((xfs_attr_shortform_t *) \ |
| 70 | ((dp)->i_afp->if_u1.if_data))->hdr.totsize)) | 68 | ((dp)->i_afp->if_u1.if_data))->hdr.totsize)) |
| 71 | 69 | ||
| 72 | #if defined(XFS_ATTR_TRACE) | ||
| 73 | /* | ||
| 74 | * Kernel tracing support for attribute lists | ||
| 75 | */ | ||
| 76 | struct xfs_attr_list_context; | ||
| 77 | struct xfs_da_intnode; | ||
| 78 | struct xfs_da_node_entry; | ||
| 79 | struct xfs_attr_leafblock; | ||
| 80 | |||
| 81 | #define XFS_ATTR_TRACE_SIZE 4096 /* size of global trace buffer */ | ||
| 82 | extern ktrace_t *xfs_attr_trace_buf; | ||
| 83 | |||
| 84 | /* | ||
| 85 | * Trace record types. | ||
| 86 | */ | ||
| 87 | #define XFS_ATTR_KTRACE_L_C 1 /* context */ | ||
| 88 | #define XFS_ATTR_KTRACE_L_CN 2 /* context, node */ | ||
| 89 | #define XFS_ATTR_KTRACE_L_CB 3 /* context, btree */ | ||
| 90 | #define XFS_ATTR_KTRACE_L_CL 4 /* context, leaf */ | ||
| 91 | |||
| 92 | void xfs_attr_trace_l_c(char *where, struct xfs_attr_list_context *context); | ||
| 93 | void xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context, | ||
| 94 | struct xfs_da_intnode *node); | ||
| 95 | void xfs_attr_trace_l_cb(char *where, struct xfs_attr_list_context *context, | ||
| 96 | struct xfs_da_node_entry *btree); | ||
| 97 | void xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context, | ||
| 98 | struct xfs_attr_leafblock *leaf); | ||
| 99 | void xfs_attr_trace_enter(int type, char *where, | ||
| 100 | struct xfs_attr_list_context *context, | ||
| 101 | __psunsigned_t a13, __psunsigned_t a14, | ||
| 102 | __psunsigned_t a15); | ||
| 103 | #else | ||
| 104 | #define xfs_attr_trace_l_c(w,c) | ||
| 105 | #define xfs_attr_trace_l_cn(w,c,n) | ||
| 106 | #define xfs_attr_trace_l_cb(w,c,b) | ||
| 107 | #define xfs_attr_trace_l_cl(w,c,l) | ||
| 108 | #endif /* XFS_ATTR_TRACE */ | ||
| 109 | |||
| 110 | #endif /* __XFS_ATTR_SF_H__ */ | 70 | #endif /* __XFS_ATTR_SF_H__ */ |
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 8971fb09d387..98251cdc52aa 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
| @@ -54,6 +54,7 @@ | |||
| 54 | #include "xfs_buf_item.h" | 54 | #include "xfs_buf_item.h" |
| 55 | #include "xfs_filestream.h" | 55 | #include "xfs_filestream.h" |
| 56 | #include "xfs_vnodeops.h" | 56 | #include "xfs_vnodeops.h" |
| 57 | #include "xfs_trace.h" | ||
| 57 | 58 | ||
| 58 | 59 | ||
| 59 | #ifdef DEBUG | 60 | #ifdef DEBUG |
| @@ -272,71 +273,6 @@ xfs_bmap_isaeof( | |||
| 272 | int whichfork, /* data or attribute fork */ | 273 | int whichfork, /* data or attribute fork */ |
| 273 | char *aeof); /* return value */ | 274 | char *aeof); /* return value */ |
| 274 | 275 | ||
| 275 | #ifdef XFS_BMAP_TRACE | ||
| 276 | /* | ||
| 277 | * Add bmap trace entry prior to a call to xfs_iext_remove. | ||
| 278 | */ | ||
| 279 | STATIC void | ||
| 280 | xfs_bmap_trace_delete( | ||
| 281 | const char *fname, /* function name */ | ||
| 282 | char *desc, /* operation description */ | ||
| 283 | xfs_inode_t *ip, /* incore inode pointer */ | ||
| 284 | xfs_extnum_t idx, /* index of entry(entries) deleted */ | ||
| 285 | xfs_extnum_t cnt, /* count of entries deleted, 1 or 2 */ | ||
| 286 | int whichfork); /* data or attr fork */ | ||
| 287 | |||
| 288 | /* | ||
| 289 | * Add bmap trace entry prior to a call to xfs_iext_insert, or | ||
| 290 | * reading in the extents list from the disk (in the btree). | ||
| 291 | */ | ||
| 292 | STATIC void | ||
| 293 | xfs_bmap_trace_insert( | ||
| 294 | const char *fname, /* function name */ | ||
| 295 | char *desc, /* operation description */ | ||
| 296 | xfs_inode_t *ip, /* incore inode pointer */ | ||
| 297 | xfs_extnum_t idx, /* index of entry(entries) inserted */ | ||
| 298 | xfs_extnum_t cnt, /* count of entries inserted, 1 or 2 */ | ||
| 299 | xfs_bmbt_irec_t *r1, /* inserted record 1 */ | ||
| 300 | xfs_bmbt_irec_t *r2, /* inserted record 2 or null */ | ||
| 301 | int whichfork); /* data or attr fork */ | ||
| 302 | |||
| 303 | /* | ||
| 304 | * Add bmap trace entry after updating an extent record in place. | ||
| 305 | */ | ||
| 306 | STATIC void | ||
| 307 | xfs_bmap_trace_post_update( | ||
| 308 | const char *fname, /* function name */ | ||
| 309 | char *desc, /* operation description */ | ||
| 310 | xfs_inode_t *ip, /* incore inode pointer */ | ||
| 311 | xfs_extnum_t idx, /* index of entry updated */ | ||
| 312 | int whichfork); /* data or attr fork */ | ||
| 313 | |||
| 314 | /* | ||
| 315 | * Add bmap trace entry prior to updating an extent record in place. | ||
| 316 | */ | ||
| 317 | STATIC void | ||
| 318 | xfs_bmap_trace_pre_update( | ||
| 319 | const char *fname, /* function name */ | ||
| 320 | char *desc, /* operation description */ | ||
| 321 | xfs_inode_t *ip, /* incore inode pointer */ | ||
| 322 | xfs_extnum_t idx, /* index of entry to be updated */ | ||
| 323 | int whichfork); /* data or attr fork */ | ||
| 324 | |||
| 325 | #define XFS_BMAP_TRACE_DELETE(d,ip,i,c,w) \ | ||
| 326 | xfs_bmap_trace_delete(__func__,d,ip,i,c,w) | ||
| 327 | #define XFS_BMAP_TRACE_INSERT(d,ip,i,c,r1,r2,w) \ | ||
| 328 | xfs_bmap_trace_insert(__func__,d,ip,i,c,r1,r2,w) | ||
| 329 | #define XFS_BMAP_TRACE_POST_UPDATE(d,ip,i,w) \ | ||
| 330 | xfs_bmap_trace_post_update(__func__,d,ip,i,w) | ||
| 331 | #define XFS_BMAP_TRACE_PRE_UPDATE(d,ip,i,w) \ | ||
| 332 | xfs_bmap_trace_pre_update(__func__,d,ip,i,w) | ||
| 333 | #else | ||
| 334 | #define XFS_BMAP_TRACE_DELETE(d,ip,i,c,w) | ||
| 335 | #define XFS_BMAP_TRACE_INSERT(d,ip,i,c,r1,r2,w) | ||
| 336 | #define XFS_BMAP_TRACE_POST_UPDATE(d,ip,i,w) | ||
| 337 | #define XFS_BMAP_TRACE_PRE_UPDATE(d,ip,i,w) | ||
| 338 | #endif /* XFS_BMAP_TRACE */ | ||
| 339 | |||
| 340 | /* | 276 | /* |
| 341 | * Compute the worst-case number of indirect blocks that will be used | 277 | * Compute the worst-case number of indirect blocks that will be used |
| 342 | * for ip's delayed extent of length "len". | 278 | * for ip's delayed extent of length "len". |
| @@ -363,18 +299,6 @@ xfs_bmap_validate_ret( | |||
| 363 | #define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) | 299 | #define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) |
| 364 | #endif /* DEBUG */ | 300 | #endif /* DEBUG */ |
| 365 | 301 | ||
| 366 | #if defined(XFS_RW_TRACE) | ||
| 367 | STATIC void | ||
| 368 | xfs_bunmap_trace( | ||
| 369 | xfs_inode_t *ip, | ||
| 370 | xfs_fileoff_t bno, | ||
| 371 | xfs_filblks_t len, | ||
| 372 | int flags, | ||
| 373 | inst_t *ra); | ||
| 374 | #else | ||
| 375 | #define xfs_bunmap_trace(ip, bno, len, flags, ra) | ||
| 376 | #endif /* XFS_RW_TRACE */ | ||
| 377 | |||
| 378 | STATIC int | 302 | STATIC int |
| 379 | xfs_bmap_count_tree( | 303 | xfs_bmap_count_tree( |
| 380 | xfs_mount_t *mp, | 304 | xfs_mount_t *mp, |
| @@ -590,9 +514,9 @@ xfs_bmap_add_extent( | |||
| 590 | * already extents in the list. | 514 | * already extents in the list. |
| 591 | */ | 515 | */ |
| 592 | if (nextents == 0) { | 516 | if (nextents == 0) { |
| 593 | XFS_BMAP_TRACE_INSERT("insert empty", ip, 0, 1, new, NULL, | 517 | xfs_iext_insert(ip, 0, 1, new, |
| 594 | whichfork); | 518 | whichfork == XFS_ATTR_FORK ? BMAP_ATTRFORK : 0); |
| 595 | xfs_iext_insert(ifp, 0, 1, new); | 519 | |
| 596 | ASSERT(cur == NULL); | 520 | ASSERT(cur == NULL); |
| 597 | ifp->if_lastex = 0; | 521 | ifp->if_lastex = 0; |
| 598 | if (!isnullstartblock(new->br_startblock)) { | 522 | if (!isnullstartblock(new->br_startblock)) { |
| @@ -759,26 +683,10 @@ xfs_bmap_add_extent_delay_real( | |||
| 759 | xfs_filblks_t temp=0; /* value for dnew calculations */ | 683 | xfs_filblks_t temp=0; /* value for dnew calculations */ |
| 760 | xfs_filblks_t temp2=0;/* value for dnew calculations */ | 684 | xfs_filblks_t temp2=0;/* value for dnew calculations */ |
| 761 | int tmp_rval; /* partial logging flags */ | 685 | int tmp_rval; /* partial logging flags */ |
| 762 | enum { /* bit number definitions for state */ | ||
| 763 | LEFT_CONTIG, RIGHT_CONTIG, | ||
| 764 | LEFT_FILLING, RIGHT_FILLING, | ||
| 765 | LEFT_DELAY, RIGHT_DELAY, | ||
| 766 | LEFT_VALID, RIGHT_VALID | ||
| 767 | }; | ||
| 768 | 686 | ||
| 769 | #define LEFT r[0] | 687 | #define LEFT r[0] |
| 770 | #define RIGHT r[1] | 688 | #define RIGHT r[1] |
| 771 | #define PREV r[2] | 689 | #define PREV r[2] |
| 772 | #define MASK(b) (1 << (b)) | ||
| 773 | #define MASK2(a,b) (MASK(a) | MASK(b)) | ||
| 774 | #define MASK3(a,b,c) (MASK2(a,b) | MASK(c)) | ||
| 775 | #define MASK4(a,b,c,d) (MASK3(a,b,c) | MASK(d)) | ||
| 776 | #define STATE_SET(b,v) ((v) ? (state |= MASK(b)) : (state &= ~MASK(b))) | ||
| 777 | #define STATE_TEST(b) (state & MASK(b)) | ||
| 778 | #define STATE_SET_TEST(b,v) ((v) ? ((state |= MASK(b)), 1) : \ | ||
| 779 | ((state &= ~MASK(b)), 0)) | ||
| 780 | #define SWITCH_STATE \ | ||
| 781 | (state & MASK4(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG)) | ||
| 782 | 690 | ||
| 783 | /* | 691 | /* |
| 784 | * Set up a bunch of variables to make the tests simpler. | 692 | * Set up a bunch of variables to make the tests simpler. |
| @@ -790,69 +698,80 @@ xfs_bmap_add_extent_delay_real( | |||
| 790 | new_endoff = new->br_startoff + new->br_blockcount; | 698 | new_endoff = new->br_startoff + new->br_blockcount; |
| 791 | ASSERT(PREV.br_startoff <= new->br_startoff); | 699 | ASSERT(PREV.br_startoff <= new->br_startoff); |
| 792 | ASSERT(PREV.br_startoff + PREV.br_blockcount >= new_endoff); | 700 | ASSERT(PREV.br_startoff + PREV.br_blockcount >= new_endoff); |
| 701 | |||
| 793 | /* | 702 | /* |
| 794 | * Set flags determining what part of the previous delayed allocation | 703 | * Set flags determining what part of the previous delayed allocation |
| 795 | * extent is being replaced by a real allocation. | 704 | * extent is being replaced by a real allocation. |
| 796 | */ | 705 | */ |
| 797 | STATE_SET(LEFT_FILLING, PREV.br_startoff == new->br_startoff); | 706 | if (PREV.br_startoff == new->br_startoff) |
| 798 | STATE_SET(RIGHT_FILLING, | 707 | state |= BMAP_LEFT_FILLING; |
| 799 | PREV.br_startoff + PREV.br_blockcount == new_endoff); | 708 | if (PREV.br_startoff + PREV.br_blockcount == new_endoff) |
| 709 | state |= BMAP_RIGHT_FILLING; | ||
| 710 | |||
| 800 | /* | 711 | /* |
| 801 | * Check and set flags if this segment has a left neighbor. | 712 | * Check and set flags if this segment has a left neighbor. |
| 802 | * Don't set contiguous if the combined extent would be too large. | 713 | * Don't set contiguous if the combined extent would be too large. |
| 803 | */ | 714 | */ |
| 804 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { | 715 | if (idx > 0) { |
| 716 | state |= BMAP_LEFT_VALID; | ||
| 805 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT); | 717 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT); |
| 806 | STATE_SET(LEFT_DELAY, isnullstartblock(LEFT.br_startblock)); | 718 | |
| 719 | if (isnullstartblock(LEFT.br_startblock)) | ||
| 720 | state |= BMAP_LEFT_DELAY; | ||
| 807 | } | 721 | } |
| 808 | STATE_SET(LEFT_CONTIG, | 722 | |
| 809 | STATE_TEST(LEFT_VALID) && !STATE_TEST(LEFT_DELAY) && | 723 | if ((state & BMAP_LEFT_VALID) && !(state & BMAP_LEFT_DELAY) && |
| 810 | LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && | 724 | LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && |
| 811 | LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && | 725 | LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && |
| 812 | LEFT.br_state == new->br_state && | 726 | LEFT.br_state == new->br_state && |
| 813 | LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN); | 727 | LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN) |
| 728 | state |= BMAP_LEFT_CONTIG; | ||
| 729 | |||
| 814 | /* | 730 | /* |
| 815 | * Check and set flags if this segment has a right neighbor. | 731 | * Check and set flags if this segment has a right neighbor. |
| 816 | * Don't set contiguous if the combined extent would be too large. | 732 | * Don't set contiguous if the combined extent would be too large. |
| 817 | * Also check for all-three-contiguous being too large. | 733 | * Also check for all-three-contiguous being too large. |
| 818 | */ | 734 | */ |
| 819 | if (STATE_SET_TEST(RIGHT_VALID, | 735 | if (idx < ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1) { |
| 820 | idx < | 736 | state |= BMAP_RIGHT_VALID; |
| 821 | ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) { | ||
| 822 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT); | 737 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT); |
| 823 | STATE_SET(RIGHT_DELAY, isnullstartblock(RIGHT.br_startblock)); | 738 | |
| 739 | if (isnullstartblock(RIGHT.br_startblock)) | ||
| 740 | state |= BMAP_RIGHT_DELAY; | ||
| 824 | } | 741 | } |
| 825 | STATE_SET(RIGHT_CONTIG, | 742 | |
| 826 | STATE_TEST(RIGHT_VALID) && !STATE_TEST(RIGHT_DELAY) && | 743 | if ((state & BMAP_RIGHT_VALID) && !(state & BMAP_RIGHT_DELAY) && |
| 827 | new_endoff == RIGHT.br_startoff && | 744 | new_endoff == RIGHT.br_startoff && |
| 828 | new->br_startblock + new->br_blockcount == | 745 | new->br_startblock + new->br_blockcount == RIGHT.br_startblock && |
| 829 | RIGHT.br_startblock && | 746 | new->br_state == RIGHT.br_state && |
| 830 | new->br_state == RIGHT.br_state && | 747 | new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN && |
| 831 | new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN && | 748 | ((state & (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING | |
| 832 | ((state & MASK3(LEFT_CONTIG, LEFT_FILLING, RIGHT_FILLING)) != | 749 | BMAP_RIGHT_FILLING)) != |
| 833 | MASK3(LEFT_CONTIG, LEFT_FILLING, RIGHT_FILLING) || | 750 | (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING | |
| 834 | LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount | 751 | BMAP_RIGHT_FILLING) || |
| 835 | <= MAXEXTLEN)); | 752 | LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount |
| 753 | <= MAXEXTLEN)) | ||
| 754 | state |= BMAP_RIGHT_CONTIG; | ||
| 755 | |||
| 836 | error = 0; | 756 | error = 0; |
| 837 | /* | 757 | /* |
| 838 | * Switch out based on the FILLING and CONTIG state bits. | 758 | * Switch out based on the FILLING and CONTIG state bits. |
| 839 | */ | 759 | */ |
| 840 | switch (SWITCH_STATE) { | 760 | switch (state & (BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | |
| 841 | 761 | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG)) { | |
| 842 | case MASK4(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG): | 762 | case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | |
| 763 | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: | ||
| 843 | /* | 764 | /* |
| 844 | * Filling in all of a previously delayed allocation extent. | 765 | * Filling in all of a previously delayed allocation extent. |
| 845 | * The left and right neighbors are both contiguous with new. | 766 | * The left and right neighbors are both contiguous with new. |
| 846 | */ | 767 | */ |
| 847 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|LC|RC", ip, idx - 1, | 768 | trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_); |
| 848 | XFS_DATA_FORK); | ||
| 849 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 769 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
| 850 | LEFT.br_blockcount + PREV.br_blockcount + | 770 | LEFT.br_blockcount + PREV.br_blockcount + |
| 851 | RIGHT.br_blockcount); | 771 | RIGHT.br_blockcount); |
| 852 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC|RC", ip, idx - 1, | 772 | trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_); |
| 853 | XFS_DATA_FORK); | 773 | |
| 854 | XFS_BMAP_TRACE_DELETE("LF|RF|LC|RC", ip, idx, 2, XFS_DATA_FORK); | 774 | xfs_iext_remove(ip, idx, 2, state); |
| 855 | xfs_iext_remove(ifp, idx, 2); | ||
| 856 | ip->i_df.if_lastex = idx - 1; | 775 | ip->i_df.if_lastex = idx - 1; |
| 857 | ip->i_d.di_nextents--; | 776 | ip->i_d.di_nextents--; |
| 858 | if (cur == NULL) | 777 | if (cur == NULL) |
| @@ -885,20 +804,18 @@ xfs_bmap_add_extent_delay_real( | |||
| 885 | RIGHT.br_blockcount; | 804 | RIGHT.br_blockcount; |
| 886 | break; | 805 | break; |
| 887 | 806 | ||
| 888 | case MASK3(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG): | 807 | case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG: |
| 889 | /* | 808 | /* |
| 890 | * Filling in all of a previously delayed allocation extent. | 809 | * Filling in all of a previously delayed allocation extent. |
| 891 | * The left neighbor is contiguous, the right is not. | 810 | * The left neighbor is contiguous, the right is not. |
| 892 | */ | 811 | */ |
| 893 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|LC", ip, idx - 1, | 812 | trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_); |
| 894 | XFS_DATA_FORK); | ||
| 895 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 813 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
| 896 | LEFT.br_blockcount + PREV.br_blockcount); | 814 | LEFT.br_blockcount + PREV.br_blockcount); |
| 897 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC", ip, idx - 1, | 815 | trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_); |
| 898 | XFS_DATA_FORK); | 816 | |
| 899 | ip->i_df.if_lastex = idx - 1; | 817 | ip->i_df.if_lastex = idx - 1; |
| 900 | XFS_BMAP_TRACE_DELETE("LF|RF|LC", ip, idx, 1, XFS_DATA_FORK); | 818 | xfs_iext_remove(ip, idx, 1, state); |
| 901 | xfs_iext_remove(ifp, idx, 1); | ||
| 902 | if (cur == NULL) | 819 | if (cur == NULL) |
| 903 | rval = XFS_ILOG_DEXT; | 820 | rval = XFS_ILOG_DEXT; |
| 904 | else { | 821 | else { |
| @@ -921,19 +838,19 @@ xfs_bmap_add_extent_delay_real( | |||
| 921 | PREV.br_blockcount; | 838 | PREV.br_blockcount; |
| 922 | break; | 839 | break; |
| 923 | 840 | ||
| 924 | case MASK3(LEFT_FILLING, RIGHT_FILLING, RIGHT_CONTIG): | 841 | case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: |
| 925 | /* | 842 | /* |
| 926 | * Filling in all of a previously delayed allocation extent. | 843 | * Filling in all of a previously delayed allocation extent. |
| 927 | * The right neighbor is contiguous, the left is not. | 844 | * The right neighbor is contiguous, the left is not. |
| 928 | */ | 845 | */ |
| 929 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|RC", ip, idx, XFS_DATA_FORK); | 846 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 930 | xfs_bmbt_set_startblock(ep, new->br_startblock); | 847 | xfs_bmbt_set_startblock(ep, new->br_startblock); |
| 931 | xfs_bmbt_set_blockcount(ep, | 848 | xfs_bmbt_set_blockcount(ep, |
| 932 | PREV.br_blockcount + RIGHT.br_blockcount); | 849 | PREV.br_blockcount + RIGHT.br_blockcount); |
| 933 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF|RC", ip, idx, XFS_DATA_FORK); | 850 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 851 | |||
| 934 | ip->i_df.if_lastex = idx; | 852 | ip->i_df.if_lastex = idx; |
| 935 | XFS_BMAP_TRACE_DELETE("LF|RF|RC", ip, idx + 1, 1, XFS_DATA_FORK); | 853 | xfs_iext_remove(ip, idx + 1, 1, state); |
| 936 | xfs_iext_remove(ifp, idx + 1, 1); | ||
| 937 | if (cur == NULL) | 854 | if (cur == NULL) |
| 938 | rval = XFS_ILOG_DEXT; | 855 | rval = XFS_ILOG_DEXT; |
| 939 | else { | 856 | else { |
| @@ -956,15 +873,16 @@ xfs_bmap_add_extent_delay_real( | |||
| 956 | RIGHT.br_blockcount; | 873 | RIGHT.br_blockcount; |
| 957 | break; | 874 | break; |
| 958 | 875 | ||
| 959 | case MASK2(LEFT_FILLING, RIGHT_FILLING): | 876 | case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING: |
| 960 | /* | 877 | /* |
| 961 | * Filling in all of a previously delayed allocation extent. | 878 | * Filling in all of a previously delayed allocation extent. |
| 962 | * Neither the left nor right neighbors are contiguous with | 879 | * Neither the left nor right neighbors are contiguous with |
| 963 | * the new one. | 880 | * the new one. |
| 964 | */ | 881 | */ |
| 965 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF", ip, idx, XFS_DATA_FORK); | 882 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 966 | xfs_bmbt_set_startblock(ep, new->br_startblock); | 883 | xfs_bmbt_set_startblock(ep, new->br_startblock); |
| 967 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF", ip, idx, XFS_DATA_FORK); | 884 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 885 | |||
| 968 | ip->i_df.if_lastex = idx; | 886 | ip->i_df.if_lastex = idx; |
| 969 | ip->i_d.di_nextents++; | 887 | ip->i_d.di_nextents++; |
| 970 | if (cur == NULL) | 888 | if (cur == NULL) |
| @@ -987,19 +905,20 @@ xfs_bmap_add_extent_delay_real( | |||
| 987 | temp2 = new->br_blockcount; | 905 | temp2 = new->br_blockcount; |
| 988 | break; | 906 | break; |
| 989 | 907 | ||
| 990 | case MASK2(LEFT_FILLING, LEFT_CONTIG): | 908 | case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG: |
| 991 | /* | 909 | /* |
| 992 | * Filling in the first part of a previous delayed allocation. | 910 | * Filling in the first part of a previous delayed allocation. |
| 993 | * The left neighbor is contiguous. | 911 | * The left neighbor is contiguous. |
| 994 | */ | 912 | */ |
| 995 | XFS_BMAP_TRACE_PRE_UPDATE("LF|LC", ip, idx - 1, XFS_DATA_FORK); | 913 | trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_); |
| 996 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 914 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
| 997 | LEFT.br_blockcount + new->br_blockcount); | 915 | LEFT.br_blockcount + new->br_blockcount); |
| 998 | xfs_bmbt_set_startoff(ep, | 916 | xfs_bmbt_set_startoff(ep, |
| 999 | PREV.br_startoff + new->br_blockcount); | 917 | PREV.br_startoff + new->br_blockcount); |
| 1000 | XFS_BMAP_TRACE_POST_UPDATE("LF|LC", ip, idx - 1, XFS_DATA_FORK); | 918 | trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_); |
| 919 | |||
| 1001 | temp = PREV.br_blockcount - new->br_blockcount; | 920 | temp = PREV.br_blockcount - new->br_blockcount; |
| 1002 | XFS_BMAP_TRACE_PRE_UPDATE("LF|LC", ip, idx, XFS_DATA_FORK); | 921 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 1003 | xfs_bmbt_set_blockcount(ep, temp); | 922 | xfs_bmbt_set_blockcount(ep, temp); |
| 1004 | ip->i_df.if_lastex = idx - 1; | 923 | ip->i_df.if_lastex = idx - 1; |
| 1005 | if (cur == NULL) | 924 | if (cur == NULL) |
| @@ -1021,7 +940,7 @@ xfs_bmap_add_extent_delay_real( | |||
| 1021 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), | 940 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), |
| 1022 | startblockval(PREV.br_startblock)); | 941 | startblockval(PREV.br_startblock)); |
| 1023 | xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); | 942 | xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); |
| 1024 | XFS_BMAP_TRACE_POST_UPDATE("LF|LC", ip, idx, XFS_DATA_FORK); | 943 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 1025 | *dnew = temp; | 944 | *dnew = temp; |
| 1026 | /* DELTA: The boundary between two in-core extents moved. */ | 945 | /* DELTA: The boundary between two in-core extents moved. */ |
| 1027 | temp = LEFT.br_startoff; | 946 | temp = LEFT.br_startoff; |
| @@ -1029,18 +948,16 @@ xfs_bmap_add_extent_delay_real( | |||
| 1029 | PREV.br_blockcount; | 948 | PREV.br_blockcount; |
| 1030 | break; | 949 | break; |
| 1031 | 950 | ||
| 1032 | case MASK(LEFT_FILLING): | 951 | case BMAP_LEFT_FILLING: |
| 1033 | /* | 952 | /* |
| 1034 | * Filling in the first part of a previous delayed allocation. | 953 | * Filling in the first part of a previous delayed allocation. |
| 1035 | * The left neighbor is not contiguous. | 954 | * The left neighbor is not contiguous. |
| 1036 | */ | 955 | */ |
| 1037 | XFS_BMAP_TRACE_PRE_UPDATE("LF", ip, idx, XFS_DATA_FORK); | 956 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 1038 | xfs_bmbt_set_startoff(ep, new_endoff); | 957 | xfs_bmbt_set_startoff(ep, new_endoff); |
| 1039 | temp = PREV.br_blockcount - new->br_blockcount; | 958 | temp = PREV.br_blockcount - new->br_blockcount; |
| 1040 | xfs_bmbt_set_blockcount(ep, temp); | 959 | xfs_bmbt_set_blockcount(ep, temp); |
| 1041 | XFS_BMAP_TRACE_INSERT("LF", ip, idx, 1, new, NULL, | 960 | xfs_iext_insert(ip, idx, 1, new, state); |
| 1042 | XFS_DATA_FORK); | ||
| 1043 | xfs_iext_insert(ifp, idx, 1, new); | ||
| 1044 | ip->i_df.if_lastex = idx; | 961 | ip->i_df.if_lastex = idx; |
| 1045 | ip->i_d.di_nextents++; | 962 | ip->i_d.di_nextents++; |
| 1046 | if (cur == NULL) | 963 | if (cur == NULL) |
| @@ -1071,27 +988,27 @@ xfs_bmap_add_extent_delay_real( | |||
| 1071 | (cur ? cur->bc_private.b.allocated : 0)); | 988 | (cur ? cur->bc_private.b.allocated : 0)); |
| 1072 | ep = xfs_iext_get_ext(ifp, idx + 1); | 989 | ep = xfs_iext_get_ext(ifp, idx + 1); |
| 1073 | xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); | 990 | xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); |
| 1074 | XFS_BMAP_TRACE_POST_UPDATE("LF", ip, idx + 1, XFS_DATA_FORK); | 991 | trace_xfs_bmap_post_update(ip, idx + 1, state, _THIS_IP_); |
| 1075 | *dnew = temp; | 992 | *dnew = temp; |
| 1076 | /* DELTA: One in-core extent is split in two. */ | 993 | /* DELTA: One in-core extent is split in two. */ |
| 1077 | temp = PREV.br_startoff; | 994 | temp = PREV.br_startoff; |
| 1078 | temp2 = PREV.br_blockcount; | 995 | temp2 = PREV.br_blockcount; |
| 1079 | break; | 996 | break; |
| 1080 | 997 | ||
| 1081 | case MASK2(RIGHT_FILLING, RIGHT_CONTIG): | 998 | case BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: |
| 1082 | /* | 999 | /* |
| 1083 | * Filling in the last part of a previous delayed allocation. | 1000 | * Filling in the last part of a previous delayed allocation. |
| 1084 | * The right neighbor is contiguous with the new allocation. | 1001 | * The right neighbor is contiguous with the new allocation. |
| 1085 | */ | 1002 | */ |
| 1086 | temp = PREV.br_blockcount - new->br_blockcount; | 1003 | temp = PREV.br_blockcount - new->br_blockcount; |
| 1087 | XFS_BMAP_TRACE_PRE_UPDATE("RF|RC", ip, idx, XFS_DATA_FORK); | 1004 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 1088 | XFS_BMAP_TRACE_PRE_UPDATE("RF|RC", ip, idx + 1, XFS_DATA_FORK); | 1005 | trace_xfs_bmap_pre_update(ip, idx + 1, state, _THIS_IP_); |
| 1089 | xfs_bmbt_set_blockcount(ep, temp); | 1006 | xfs_bmbt_set_blockcount(ep, temp); |
| 1090 | xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, idx + 1), | 1007 | xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, idx + 1), |
| 1091 | new->br_startoff, new->br_startblock, | 1008 | new->br_startoff, new->br_startblock, |
| 1092 | new->br_blockcount + RIGHT.br_blockcount, | 1009 | new->br_blockcount + RIGHT.br_blockcount, |
| 1093 | RIGHT.br_state); | 1010 | RIGHT.br_state); |
| 1094 | XFS_BMAP_TRACE_POST_UPDATE("RF|RC", ip, idx + 1, XFS_DATA_FORK); | 1011 | trace_xfs_bmap_post_update(ip, idx + 1, state, _THIS_IP_); |
| 1095 | ip->i_df.if_lastex = idx + 1; | 1012 | ip->i_df.if_lastex = idx + 1; |
| 1096 | if (cur == NULL) | 1013 | if (cur == NULL) |
| 1097 | rval = XFS_ILOG_DEXT; | 1014 | rval = XFS_ILOG_DEXT; |
| @@ -1112,7 +1029,7 @@ xfs_bmap_add_extent_delay_real( | |||
| 1112 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), | 1029 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), |
| 1113 | startblockval(PREV.br_startblock)); | 1030 | startblockval(PREV.br_startblock)); |
| 1114 | xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); | 1031 | xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); |
| 1115 | XFS_BMAP_TRACE_POST_UPDATE("RF|RC", ip, idx, XFS_DATA_FORK); | 1032 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 1116 | *dnew = temp; | 1033 | *dnew = temp; |
| 1117 | /* DELTA: The boundary between two in-core extents moved. */ | 1034 | /* DELTA: The boundary between two in-core extents moved. */ |
| 1118 | temp = PREV.br_startoff; | 1035 | temp = PREV.br_startoff; |
| @@ -1120,17 +1037,15 @@ xfs_bmap_add_extent_delay_real( | |||
| 1120 | RIGHT.br_blockcount; | 1037 | RIGHT.br_blockcount; |
| 1121 | break; | 1038 | break; |
| 1122 | 1039 | ||
| 1123 | case MASK(RIGHT_FILLING): | 1040 | case BMAP_RIGHT_FILLING: |
| 1124 | /* | 1041 | /* |
| 1125 | * Filling in the last part of a previous delayed allocation. | 1042 | * Filling in the last part of a previous delayed allocation. |
| 1126 | * The right neighbor is not contiguous. | 1043 | * The right neighbor is not contiguous. |
| 1127 | */ | 1044 | */ |
| 1128 | temp = PREV.br_blockcount - new->br_blockcount; | 1045 | temp = PREV.br_blockcount - new->br_blockcount; |
| 1129 | XFS_BMAP_TRACE_PRE_UPDATE("RF", ip, idx, XFS_DATA_FORK); | 1046 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 1130 | xfs_bmbt_set_blockcount(ep, temp); | 1047 | xfs_bmbt_set_blockcount(ep, temp); |
| 1131 | XFS_BMAP_TRACE_INSERT("RF", ip, idx + 1, 1, new, NULL, | 1048 | xfs_iext_insert(ip, idx + 1, 1, new, state); |
| 1132 | XFS_DATA_FORK); | ||
| 1133 | xfs_iext_insert(ifp, idx + 1, 1, new); | ||
| 1134 | ip->i_df.if_lastex = idx + 1; | 1049 | ip->i_df.if_lastex = idx + 1; |
| 1135 | ip->i_d.di_nextents++; | 1050 | ip->i_d.di_nextents++; |
| 1136 | if (cur == NULL) | 1051 | if (cur == NULL) |
| @@ -1161,7 +1076,7 @@ xfs_bmap_add_extent_delay_real( | |||
| 1161 | (cur ? cur->bc_private.b.allocated : 0)); | 1076 | (cur ? cur->bc_private.b.allocated : 0)); |
| 1162 | ep = xfs_iext_get_ext(ifp, idx); | 1077 | ep = xfs_iext_get_ext(ifp, idx); |
| 1163 | xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); | 1078 | xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); |
| 1164 | XFS_BMAP_TRACE_POST_UPDATE("RF", ip, idx, XFS_DATA_FORK); | 1079 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 1165 | *dnew = temp; | 1080 | *dnew = temp; |
| 1166 | /* DELTA: One in-core extent is split in two. */ | 1081 | /* DELTA: One in-core extent is split in two. */ |
| 1167 | temp = PREV.br_startoff; | 1082 | temp = PREV.br_startoff; |
| @@ -1175,7 +1090,7 @@ xfs_bmap_add_extent_delay_real( | |||
| 1175 | * This case is avoided almost all the time. | 1090 | * This case is avoided almost all the time. |
| 1176 | */ | 1091 | */ |
| 1177 | temp = new->br_startoff - PREV.br_startoff; | 1092 | temp = new->br_startoff - PREV.br_startoff; |
| 1178 | XFS_BMAP_TRACE_PRE_UPDATE("0", ip, idx, XFS_DATA_FORK); | 1093 | trace_xfs_bmap_pre_update(ip, idx, 0, _THIS_IP_); |
| 1179 | xfs_bmbt_set_blockcount(ep, temp); | 1094 | xfs_bmbt_set_blockcount(ep, temp); |
| 1180 | r[0] = *new; | 1095 | r[0] = *new; |
| 1181 | r[1].br_state = PREV.br_state; | 1096 | r[1].br_state = PREV.br_state; |
| @@ -1183,9 +1098,7 @@ xfs_bmap_add_extent_delay_real( | |||
| 1183 | r[1].br_startoff = new_endoff; | 1098 | r[1].br_startoff = new_endoff; |
| 1184 | temp2 = PREV.br_startoff + PREV.br_blockcount - new_endoff; | 1099 | temp2 = PREV.br_startoff + PREV.br_blockcount - new_endoff; |
| 1185 | r[1].br_blockcount = temp2; | 1100 | r[1].br_blockcount = temp2; |
| 1186 | XFS_BMAP_TRACE_INSERT("0", ip, idx + 1, 2, &r[0], &r[1], | 1101 | xfs_iext_insert(ip, idx + 1, 2, &r[0], state); |
| 1187 | XFS_DATA_FORK); | ||
| 1188 | xfs_iext_insert(ifp, idx + 1, 2, &r[0]); | ||
| 1189 | ip->i_df.if_lastex = idx + 1; | 1102 | ip->i_df.if_lastex = idx + 1; |
| 1190 | ip->i_d.di_nextents++; | 1103 | ip->i_d.di_nextents++; |
| 1191 | if (cur == NULL) | 1104 | if (cur == NULL) |
| @@ -1242,24 +1155,24 @@ xfs_bmap_add_extent_delay_real( | |||
| 1242 | } | 1155 | } |
| 1243 | ep = xfs_iext_get_ext(ifp, idx); | 1156 | ep = xfs_iext_get_ext(ifp, idx); |
| 1244 | xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); | 1157 | xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); |
| 1245 | XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx, XFS_DATA_FORK); | 1158 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 1246 | XFS_BMAP_TRACE_PRE_UPDATE("0", ip, idx + 2, XFS_DATA_FORK); | 1159 | trace_xfs_bmap_pre_update(ip, idx + 2, state, _THIS_IP_); |
| 1247 | xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx + 2), | 1160 | xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx + 2), |
| 1248 | nullstartblock((int)temp2)); | 1161 | nullstartblock((int)temp2)); |
| 1249 | XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx + 2, XFS_DATA_FORK); | 1162 | trace_xfs_bmap_post_update(ip, idx + 2, state, _THIS_IP_); |
| 1250 | *dnew = temp + temp2; | 1163 | *dnew = temp + temp2; |
| 1251 | /* DELTA: One in-core extent is split in three. */ | 1164 | /* DELTA: One in-core extent is split in three. */ |
| 1252 | temp = PREV.br_startoff; | 1165 | temp = PREV.br_startoff; |
| 1253 | temp2 = PREV.br_blockcount; | 1166 | temp2 = PREV.br_blockcount; |
| 1254 | break; | 1167 | break; |
| 1255 | 1168 | ||
| 1256 | case MASK3(LEFT_FILLING, LEFT_CONTIG, RIGHT_CONTIG): | 1169 | case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: |
| 1257 | case MASK3(RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG): | 1170 | case BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: |
| 1258 | case MASK2(LEFT_FILLING, RIGHT_CONTIG): | 1171 | case BMAP_LEFT_FILLING | BMAP_RIGHT_CONTIG: |
| 1259 | case MASK2(RIGHT_FILLING, LEFT_CONTIG): | 1172 | case BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG: |
| 1260 | case MASK2(LEFT_CONTIG, RIGHT_CONTIG): | 1173 | case BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: |
| 1261 | case MASK(LEFT_CONTIG): | 1174 | case BMAP_LEFT_CONTIG: |
| 1262 | case MASK(RIGHT_CONTIG): | 1175 | case BMAP_RIGHT_CONTIG: |
| 1263 | /* | 1176 | /* |
| 1264 | * These cases are all impossible. | 1177 | * These cases are all impossible. |
| 1265 | */ | 1178 | */ |
| @@ -1279,14 +1192,6 @@ done: | |||
| 1279 | #undef LEFT | 1192 | #undef LEFT |
| 1280 | #undef RIGHT | 1193 | #undef RIGHT |
| 1281 | #undef PREV | 1194 | #undef PREV |
| 1282 | #undef MASK | ||
| 1283 | #undef MASK2 | ||
| 1284 | #undef MASK3 | ||
| 1285 | #undef MASK4 | ||
| 1286 | #undef STATE_SET | ||
| 1287 | #undef STATE_TEST | ||
| 1288 | #undef STATE_SET_TEST | ||
| 1289 | #undef SWITCH_STATE | ||
| 1290 | } | 1195 | } |
| 1291 | 1196 | ||
| 1292 | /* | 1197 | /* |
| @@ -1316,27 +1221,10 @@ xfs_bmap_add_extent_unwritten_real( | |||
| 1316 | int state = 0;/* state bits, accessed thru macros */ | 1221 | int state = 0;/* state bits, accessed thru macros */ |
| 1317 | xfs_filblks_t temp=0; | 1222 | xfs_filblks_t temp=0; |
| 1318 | xfs_filblks_t temp2=0; | 1223 | xfs_filblks_t temp2=0; |
| 1319 | enum { /* bit number definitions for state */ | ||
| 1320 | LEFT_CONTIG, RIGHT_CONTIG, | ||
| 1321 | LEFT_FILLING, RIGHT_FILLING, | ||
| 1322 | LEFT_DELAY, RIGHT_DELAY, | ||
| 1323 | LEFT_VALID, RIGHT_VALID | ||
| 1324 | }; | ||
| 1325 | 1224 | ||
| 1326 | #define LEFT r[0] | 1225 | #define LEFT r[0] |
| 1327 | #define RIGHT r[1] | 1226 | #define RIGHT r[1] |
| 1328 | #define PREV r[2] | 1227 | #define PREV r[2] |
| 1329 | #define MASK(b) (1 << (b)) | ||
| 1330 | #define MASK2(a,b) (MASK(a) | MASK(b)) | ||
| 1331 | #define MASK3(a,b,c) (MASK2(a,b) | MASK(c)) | ||
| 1332 | #define MASK4(a,b,c,d) (MASK3(a,b,c) | MASK(d)) | ||
| 1333 | #define STATE_SET(b,v) ((v) ? (state |= MASK(b)) : (state &= ~MASK(b))) | ||
| 1334 | #define STATE_TEST(b) (state & MASK(b)) | ||
| 1335 | #define STATE_SET_TEST(b,v) ((v) ? ((state |= MASK(b)), 1) : \ | ||
| 1336 | ((state &= ~MASK(b)), 0)) | ||
| 1337 | #define SWITCH_STATE \ | ||
| 1338 | (state & MASK4(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG)) | ||
| 1339 | |||
| 1340 | /* | 1228 | /* |
| 1341 | * Set up a bunch of variables to make the tests simpler. | 1229 | * Set up a bunch of variables to make the tests simpler. |
| 1342 | */ | 1230 | */ |
| @@ -1352,68 +1240,78 @@ xfs_bmap_add_extent_unwritten_real( | |||
| 1352 | new_endoff = new->br_startoff + new->br_blockcount; | 1240 | new_endoff = new->br_startoff + new->br_blockcount; |
| 1353 | ASSERT(PREV.br_startoff <= new->br_startoff); | 1241 | ASSERT(PREV.br_startoff <= new->br_startoff); |
| 1354 | ASSERT(PREV.br_startoff + PREV.br_blockcount >= new_endoff); | 1242 | ASSERT(PREV.br_startoff + PREV.br_blockcount >= new_endoff); |
| 1243 | |||
| 1355 | /* | 1244 | /* |
| 1356 | * Set flags determining what part of the previous oldext allocation | 1245 | * Set flags determining what part of the previous oldext allocation |
| 1357 | * extent is being replaced by a newext allocation. | 1246 | * extent is being replaced by a newext allocation. |
| 1358 | */ | 1247 | */ |
| 1359 | STATE_SET(LEFT_FILLING, PREV.br_startoff == new->br_startoff); | 1248 | if (PREV.br_startoff == new->br_startoff) |
| 1360 | STATE_SET(RIGHT_FILLING, | 1249 | state |= BMAP_LEFT_FILLING; |
| 1361 | PREV.br_startoff + PREV.br_blockcount == new_endoff); | 1250 | if (PREV.br_startoff + PREV.br_blockcount == new_endoff) |
| 1251 | state |= BMAP_RIGHT_FILLING; | ||
| 1252 | |||
| 1362 | /* | 1253 | /* |
| 1363 | * Check and set flags if this segment has a left neighbor. | 1254 | * Check and set flags if this segment has a left neighbor. |
| 1364 | * Don't set contiguous if the combined extent would be too large. | 1255 | * Don't set contiguous if the combined extent would be too large. |
| 1365 | */ | 1256 | */ |
| 1366 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { | 1257 | if (idx > 0) { |
| 1258 | state |= BMAP_LEFT_VALID; | ||
| 1367 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT); | 1259 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT); |
| 1368 | STATE_SET(LEFT_DELAY, isnullstartblock(LEFT.br_startblock)); | 1260 | |
| 1261 | if (isnullstartblock(LEFT.br_startblock)) | ||
| 1262 | state |= BMAP_LEFT_DELAY; | ||
| 1369 | } | 1263 | } |
| 1370 | STATE_SET(LEFT_CONTIG, | 1264 | |
| 1371 | STATE_TEST(LEFT_VALID) && !STATE_TEST(LEFT_DELAY) && | 1265 | if ((state & BMAP_LEFT_VALID) && !(state & BMAP_LEFT_DELAY) && |
| 1372 | LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && | 1266 | LEFT.br_startoff + LEFT.br_blockcount == new->br_startoff && |
| 1373 | LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && | 1267 | LEFT.br_startblock + LEFT.br_blockcount == new->br_startblock && |
| 1374 | LEFT.br_state == newext && | 1268 | LEFT.br_state == newext && |
| 1375 | LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN); | 1269 | LEFT.br_blockcount + new->br_blockcount <= MAXEXTLEN) |
| 1270 | state |= BMAP_LEFT_CONTIG; | ||
| 1271 | |||
| 1376 | /* | 1272 | /* |
| 1377 | * Check and set flags if this segment has a right neighbor. | 1273 | * Check and set flags if this segment has a right neighbor. |
| 1378 | * Don't set contiguous if the combined extent would be too large. | 1274 | * Don't set contiguous if the combined extent would be too large. |
| 1379 | * Also check for all-three-contiguous being too large. | 1275 | * Also check for all-three-contiguous being too large. |
| 1380 | */ | 1276 | */ |
| 1381 | if (STATE_SET_TEST(RIGHT_VALID, | 1277 | if (idx < ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1) { |
| 1382 | idx < | 1278 | state |= BMAP_RIGHT_VALID; |
| 1383 | ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) { | ||
| 1384 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT); | 1279 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT); |
| 1385 | STATE_SET(RIGHT_DELAY, isnullstartblock(RIGHT.br_startblock)); | 1280 | if (isnullstartblock(RIGHT.br_startblock)) |
| 1281 | state |= BMAP_RIGHT_DELAY; | ||
| 1386 | } | 1282 | } |
| 1387 | STATE_SET(RIGHT_CONTIG, | 1283 | |
| 1388 | STATE_TEST(RIGHT_VALID) && !STATE_TEST(RIGHT_DELAY) && | 1284 | if ((state & BMAP_RIGHT_VALID) && !(state & BMAP_RIGHT_DELAY) && |
| 1389 | new_endoff == RIGHT.br_startoff && | 1285 | new_endoff == RIGHT.br_startoff && |
| 1390 | new->br_startblock + new->br_blockcount == | 1286 | new->br_startblock + new->br_blockcount == RIGHT.br_startblock && |
| 1391 | RIGHT.br_startblock && | 1287 | newext == RIGHT.br_state && |
| 1392 | newext == RIGHT.br_state && | 1288 | new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN && |
| 1393 | new->br_blockcount + RIGHT.br_blockcount <= MAXEXTLEN && | 1289 | ((state & (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING | |
| 1394 | ((state & MASK3(LEFT_CONTIG, LEFT_FILLING, RIGHT_FILLING)) != | 1290 | BMAP_RIGHT_FILLING)) != |
| 1395 | MASK3(LEFT_CONTIG, LEFT_FILLING, RIGHT_FILLING) || | 1291 | (BMAP_LEFT_CONTIG | BMAP_LEFT_FILLING | |
| 1396 | LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount | 1292 | BMAP_RIGHT_FILLING) || |
| 1397 | <= MAXEXTLEN)); | 1293 | LEFT.br_blockcount + new->br_blockcount + RIGHT.br_blockcount |
| 1294 | <= MAXEXTLEN)) | ||
| 1295 | state |= BMAP_RIGHT_CONTIG; | ||
| 1296 | |||
| 1398 | /* | 1297 | /* |
| 1399 | * Switch out based on the FILLING and CONTIG state bits. | 1298 | * Switch out based on the FILLING and CONTIG state bits. |
| 1400 | */ | 1299 | */ |
| 1401 | switch (SWITCH_STATE) { | 1300 | switch (state & (BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | |
| 1402 | 1301 | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG)) { | |
| 1403 | case MASK4(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG): | 1302 | case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | |
| 1303 | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: | ||
| 1404 | /* | 1304 | /* |
| 1405 | * Setting all of a previous oldext extent to newext. | 1305 | * Setting all of a previous oldext extent to newext. |
| 1406 | * The left and right neighbors are both contiguous with new. | 1306 | * The left and right neighbors are both contiguous with new. |
| 1407 | */ | 1307 | */ |
| 1408 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|LC|RC", ip, idx - 1, | 1308 | trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_); |
| 1409 | XFS_DATA_FORK); | ||
| 1410 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 1309 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
| 1411 | LEFT.br_blockcount + PREV.br_blockcount + | 1310 | LEFT.br_blockcount + PREV.br_blockcount + |
| 1412 | RIGHT.br_blockcount); | 1311 | RIGHT.br_blockcount); |
| 1413 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC|RC", ip, idx - 1, | 1312 | trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_); |
| 1414 | XFS_DATA_FORK); | 1313 | |
| 1415 | XFS_BMAP_TRACE_DELETE("LF|RF|LC|RC", ip, idx, 2, XFS_DATA_FORK); | 1314 | xfs_iext_remove(ip, idx, 2, state); |
| 1416 | xfs_iext_remove(ifp, idx, 2); | ||
| 1417 | ip->i_df.if_lastex = idx - 1; | 1315 | ip->i_df.if_lastex = idx - 1; |
| 1418 | ip->i_d.di_nextents -= 2; | 1316 | ip->i_d.di_nextents -= 2; |
| 1419 | if (cur == NULL) | 1317 | if (cur == NULL) |
| @@ -1450,20 +1348,18 @@ xfs_bmap_add_extent_unwritten_real( | |||
| 1450 | RIGHT.br_blockcount; | 1348 | RIGHT.br_blockcount; |
| 1451 | break; | 1349 | break; |
| 1452 | 1350 | ||
| 1453 | case MASK3(LEFT_FILLING, RIGHT_FILLING, LEFT_CONTIG): | 1351 | case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG: |
| 1454 | /* | 1352 | /* |
| 1455 | * Setting all of a previous oldext extent to newext. | 1353 | * Setting all of a previous oldext extent to newext. |
| 1456 | * The left neighbor is contiguous, the right is not. | 1354 | * The left neighbor is contiguous, the right is not. |
| 1457 | */ | 1355 | */ |
| 1458 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|LC", ip, idx - 1, | 1356 | trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_); |
| 1459 | XFS_DATA_FORK); | ||
| 1460 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 1357 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
| 1461 | LEFT.br_blockcount + PREV.br_blockcount); | 1358 | LEFT.br_blockcount + PREV.br_blockcount); |
| 1462 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF|LC", ip, idx - 1, | 1359 | trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_); |
| 1463 | XFS_DATA_FORK); | 1360 | |
| 1464 | ip->i_df.if_lastex = idx - 1; | 1361 | ip->i_df.if_lastex = idx - 1; |
| 1465 | XFS_BMAP_TRACE_DELETE("LF|RF|LC", ip, idx, 1, XFS_DATA_FORK); | 1362 | xfs_iext_remove(ip, idx, 1, state); |
| 1466 | xfs_iext_remove(ifp, idx, 1); | ||
| 1467 | ip->i_d.di_nextents--; | 1363 | ip->i_d.di_nextents--; |
| 1468 | if (cur == NULL) | 1364 | if (cur == NULL) |
| 1469 | rval = XFS_ILOG_CORE | XFS_ILOG_DEXT; | 1365 | rval = XFS_ILOG_CORE | XFS_ILOG_DEXT; |
| @@ -1492,21 +1388,18 @@ xfs_bmap_add_extent_unwritten_real( | |||
| 1492 | PREV.br_blockcount; | 1388 | PREV.br_blockcount; |
| 1493 | break; | 1389 | break; |
| 1494 | 1390 | ||
| 1495 | case MASK3(LEFT_FILLING, RIGHT_FILLING, RIGHT_CONTIG): | 1391 | case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: |
| 1496 | /* | 1392 | /* |
| 1497 | * Setting all of a previous oldext extent to newext. | 1393 | * Setting all of a previous oldext extent to newext. |
| 1498 | * The right neighbor is contiguous, the left is not. | 1394 | * The right neighbor is contiguous, the left is not. |
| 1499 | */ | 1395 | */ |
| 1500 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF|RC", ip, idx, | 1396 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 1501 | XFS_DATA_FORK); | ||
| 1502 | xfs_bmbt_set_blockcount(ep, | 1397 | xfs_bmbt_set_blockcount(ep, |
| 1503 | PREV.br_blockcount + RIGHT.br_blockcount); | 1398 | PREV.br_blockcount + RIGHT.br_blockcount); |
| 1504 | xfs_bmbt_set_state(ep, newext); | 1399 | xfs_bmbt_set_state(ep, newext); |
| 1505 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF|RC", ip, idx, | 1400 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 1506 | XFS_DATA_FORK); | ||
| 1507 | ip->i_df.if_lastex = idx; | 1401 | ip->i_df.if_lastex = idx; |
| 1508 | XFS_BMAP_TRACE_DELETE("LF|RF|RC", ip, idx + 1, 1, XFS_DATA_FORK); | 1402 | xfs_iext_remove(ip, idx + 1, 1, state); |
| 1509 | xfs_iext_remove(ifp, idx + 1, 1); | ||
| 1510 | ip->i_d.di_nextents--; | 1403 | ip->i_d.di_nextents--; |
| 1511 | if (cur == NULL) | 1404 | if (cur == NULL) |
| 1512 | rval = XFS_ILOG_CORE | XFS_ILOG_DEXT; | 1405 | rval = XFS_ILOG_CORE | XFS_ILOG_DEXT; |
| @@ -1535,17 +1428,16 @@ xfs_bmap_add_extent_unwritten_real( | |||
| 1535 | RIGHT.br_blockcount; | 1428 | RIGHT.br_blockcount; |
| 1536 | break; | 1429 | break; |
| 1537 | 1430 | ||
| 1538 | case MASK2(LEFT_FILLING, RIGHT_FILLING): | 1431 | case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING: |
| 1539 | /* | 1432 | /* |
| 1540 | * Setting all of a previous oldext extent to newext. | 1433 | * Setting all of a previous oldext extent to newext. |
| 1541 | * Neither the left nor right neighbors are contiguous with | 1434 | * Neither the left nor right neighbors are contiguous with |
| 1542 | * the new one. | 1435 | * the new one. |
| 1543 | */ | 1436 | */ |
| 1544 | XFS_BMAP_TRACE_PRE_UPDATE("LF|RF", ip, idx, | 1437 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 1545 | XFS_DATA_FORK); | ||
| 1546 | xfs_bmbt_set_state(ep, newext); | 1438 | xfs_bmbt_set_state(ep, newext); |
| 1547 | XFS_BMAP_TRACE_POST_UPDATE("LF|RF", ip, idx, | 1439 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 1548 | XFS_DATA_FORK); | 1440 | |
| 1549 | ip->i_df.if_lastex = idx; | 1441 | ip->i_df.if_lastex = idx; |
| 1550 | if (cur == NULL) | 1442 | if (cur == NULL) |
| 1551 | rval = XFS_ILOG_DEXT; | 1443 | rval = XFS_ILOG_DEXT; |
| @@ -1566,27 +1458,25 @@ xfs_bmap_add_extent_unwritten_real( | |||
| 1566 | temp2 = new->br_blockcount; | 1458 | temp2 = new->br_blockcount; |
| 1567 | break; | 1459 | break; |
| 1568 | 1460 | ||
| 1569 | case MASK2(LEFT_FILLING, LEFT_CONTIG): | 1461 | case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG: |
| 1570 | /* | 1462 | /* |
| 1571 | * Setting the first part of a previous oldext extent to newext. | 1463 | * Setting the first part of a previous oldext extent to newext. |
| 1572 | * The left neighbor is contiguous. | 1464 | * The left neighbor is contiguous. |
| 1573 | */ | 1465 | */ |
| 1574 | XFS_BMAP_TRACE_PRE_UPDATE("LF|LC", ip, idx - 1, | 1466 | trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_); |
| 1575 | XFS_DATA_FORK); | ||
| 1576 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 1467 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
| 1577 | LEFT.br_blockcount + new->br_blockcount); | 1468 | LEFT.br_blockcount + new->br_blockcount); |
| 1578 | xfs_bmbt_set_startoff(ep, | 1469 | xfs_bmbt_set_startoff(ep, |
| 1579 | PREV.br_startoff + new->br_blockcount); | 1470 | PREV.br_startoff + new->br_blockcount); |
| 1580 | XFS_BMAP_TRACE_POST_UPDATE("LF|LC", ip, idx - 1, | 1471 | trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_); |
| 1581 | XFS_DATA_FORK); | 1472 | |
| 1582 | XFS_BMAP_TRACE_PRE_UPDATE("LF|LC", ip, idx, | 1473 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 1583 | XFS_DATA_FORK); | ||
| 1584 | xfs_bmbt_set_startblock(ep, | 1474 | xfs_bmbt_set_startblock(ep, |
| 1585 | new->br_startblock + new->br_blockcount); | 1475 | new->br_startblock + new->br_blockcount); |
| 1586 | xfs_bmbt_set_blockcount(ep, | 1476 | xfs_bmbt_set_blockcount(ep, |
| 1587 | PREV.br_blockcount - new->br_blockcount); | 1477 | PREV.br_blockcount - new->br_blockcount); |
| 1588 | XFS_BMAP_TRACE_POST_UPDATE("LF|LC", ip, idx, | 1478 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 1589 | XFS_DATA_FORK); | 1479 | |
| 1590 | ip->i_df.if_lastex = idx - 1; | 1480 | ip->i_df.if_lastex = idx - 1; |
| 1591 | if (cur == NULL) | 1481 | if (cur == NULL) |
| 1592 | rval = XFS_ILOG_DEXT; | 1482 | rval = XFS_ILOG_DEXT; |
| @@ -1617,22 +1507,21 @@ xfs_bmap_add_extent_unwritten_real( | |||
| 1617 | PREV.br_blockcount; | 1507 | PREV.br_blockcount; |
| 1618 | break; | 1508 | break; |
| 1619 | 1509 | ||
| 1620 | case MASK(LEFT_FILLING): | 1510 | case BMAP_LEFT_FILLING: |
| 1621 | /* | 1511 | /* |
| 1622 | * Setting the first part of a previous oldext extent to newext. | 1512 | * Setting the first part of a previous oldext extent to newext. |
| 1623 | * The left neighbor is not contiguous. | 1513 | * The left neighbor is not contiguous. |
| 1624 | */ | 1514 | */ |
| 1625 | XFS_BMAP_TRACE_PRE_UPDATE("LF", ip, idx, XFS_DATA_FORK); | 1515 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 1626 | ASSERT(ep && xfs_bmbt_get_state(ep) == oldext); | 1516 | ASSERT(ep && xfs_bmbt_get_state(ep) == oldext); |
| 1627 | xfs_bmbt_set_startoff(ep, new_endoff); | 1517 | xfs_bmbt_set_startoff(ep, new_endoff); |
| 1628 | xfs_bmbt_set_blockcount(ep, | 1518 | xfs_bmbt_set_blockcount(ep, |
| 1629 | PREV.br_blockcount - new->br_blockcount); | 1519 | PREV.br_blockcount - new->br_blockcount); |
| 1630 | xfs_bmbt_set_startblock(ep, | 1520 | xfs_bmbt_set_startblock(ep, |
| 1631 | new->br_startblock + new->br_blockcount); | 1521 | new->br_startblock + new->br_blockcount); |
| 1632 | XFS_BMAP_TRACE_POST_UPDATE("LF", ip, idx, XFS_DATA_FORK); | 1522 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 1633 | XFS_BMAP_TRACE_INSERT("LF", ip, idx, 1, new, NULL, | 1523 | |
| 1634 | XFS_DATA_FORK); | 1524 | xfs_iext_insert(ip, idx, 1, new, state); |
| 1635 | xfs_iext_insert(ifp, idx, 1, new); | ||
| 1636 | ip->i_df.if_lastex = idx; | 1525 | ip->i_df.if_lastex = idx; |
| 1637 | ip->i_d.di_nextents++; | 1526 | ip->i_d.di_nextents++; |
| 1638 | if (cur == NULL) | 1527 | if (cur == NULL) |
| @@ -1660,24 +1549,21 @@ xfs_bmap_add_extent_unwritten_real( | |||
| 1660 | temp2 = PREV.br_blockcount; | 1549 | temp2 = PREV.br_blockcount; |
| 1661 | break; | 1550 | break; |
| 1662 | 1551 | ||
| 1663 | case MASK2(RIGHT_FILLING, RIGHT_CONTIG): | 1552 | case BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: |
| 1664 | /* | 1553 | /* |
| 1665 | * Setting the last part of a previous oldext extent to newext. | 1554 | * Setting the last part of a previous oldext extent to newext. |
| 1666 | * The right neighbor is contiguous with the new allocation. | 1555 | * The right neighbor is contiguous with the new allocation. |
| 1667 | */ | 1556 | */ |
| 1668 | XFS_BMAP_TRACE_PRE_UPDATE("RF|RC", ip, idx, | 1557 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 1669 | XFS_DATA_FORK); | 1558 | trace_xfs_bmap_pre_update(ip, idx + 1, state, _THIS_IP_); |
| 1670 | XFS_BMAP_TRACE_PRE_UPDATE("RF|RC", ip, idx + 1, | ||
| 1671 | XFS_DATA_FORK); | ||
| 1672 | xfs_bmbt_set_blockcount(ep, | 1559 | xfs_bmbt_set_blockcount(ep, |
| 1673 | PREV.br_blockcount - new->br_blockcount); | 1560 | PREV.br_blockcount - new->br_blockcount); |
| 1674 | XFS_BMAP_TRACE_POST_UPDATE("RF|RC", ip, idx, | 1561 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 1675 | XFS_DATA_FORK); | ||
| 1676 | xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, idx + 1), | 1562 | xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, idx + 1), |
| 1677 | new->br_startoff, new->br_startblock, | 1563 | new->br_startoff, new->br_startblock, |
| 1678 | new->br_blockcount + RIGHT.br_blockcount, newext); | 1564 | new->br_blockcount + RIGHT.br_blockcount, newext); |
| 1679 | XFS_BMAP_TRACE_POST_UPDATE("RF|RC", ip, idx + 1, | 1565 | trace_xfs_bmap_post_update(ip, idx + 1, state, _THIS_IP_); |
| 1680 | XFS_DATA_FORK); | 1566 | |
| 1681 | ip->i_df.if_lastex = idx + 1; | 1567 | ip->i_df.if_lastex = idx + 1; |
| 1682 | if (cur == NULL) | 1568 | if (cur == NULL) |
| 1683 | rval = XFS_ILOG_DEXT; | 1569 | rval = XFS_ILOG_DEXT; |
| @@ -1707,18 +1593,17 @@ xfs_bmap_add_extent_unwritten_real( | |||
| 1707 | RIGHT.br_blockcount; | 1593 | RIGHT.br_blockcount; |
| 1708 | break; | 1594 | break; |
| 1709 | 1595 | ||
| 1710 | case MASK(RIGHT_FILLING): | 1596 | case BMAP_RIGHT_FILLING: |
| 1711 | /* | 1597 | /* |
| 1712 | * Setting the last part of a previous oldext extent to newext. | 1598 | * Setting the last part of a previous oldext extent to newext. |
| 1713 | * The right neighbor is not contiguous. | 1599 | * The right neighbor is not contiguous. |
| 1714 | */ | 1600 | */ |
| 1715 | XFS_BMAP_TRACE_PRE_UPDATE("RF", ip, idx, XFS_DATA_FORK); | 1601 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 1716 | xfs_bmbt_set_blockcount(ep, | 1602 | xfs_bmbt_set_blockcount(ep, |
| 1717 | PREV.br_blockcount - new->br_blockcount); | 1603 | PREV.br_blockcount - new->br_blockcount); |
| 1718 | XFS_BMAP_TRACE_POST_UPDATE("RF", ip, idx, XFS_DATA_FORK); | 1604 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 1719 | XFS_BMAP_TRACE_INSERT("RF", ip, idx + 1, 1, new, NULL, | 1605 | |
| 1720 | XFS_DATA_FORK); | 1606 | xfs_iext_insert(ip, idx + 1, 1, new, state); |
| 1721 | xfs_iext_insert(ifp, idx + 1, 1, new); | ||
| 1722 | ip->i_df.if_lastex = idx + 1; | 1607 | ip->i_df.if_lastex = idx + 1; |
| 1723 | ip->i_d.di_nextents++; | 1608 | ip->i_d.di_nextents++; |
| 1724 | if (cur == NULL) | 1609 | if (cur == NULL) |
| @@ -1756,19 +1641,18 @@ xfs_bmap_add_extent_unwritten_real( | |||
| 1756 | * newext. Contiguity is impossible here. | 1641 | * newext. Contiguity is impossible here. |
| 1757 | * One extent becomes three extents. | 1642 | * One extent becomes three extents. |
| 1758 | */ | 1643 | */ |
| 1759 | XFS_BMAP_TRACE_PRE_UPDATE("0", ip, idx, XFS_DATA_FORK); | 1644 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 1760 | xfs_bmbt_set_blockcount(ep, | 1645 | xfs_bmbt_set_blockcount(ep, |
| 1761 | new->br_startoff - PREV.br_startoff); | 1646 | new->br_startoff - PREV.br_startoff); |
| 1762 | XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx, XFS_DATA_FORK); | 1647 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 1648 | |||
| 1763 | r[0] = *new; | 1649 | r[0] = *new; |
| 1764 | r[1].br_startoff = new_endoff; | 1650 | r[1].br_startoff = new_endoff; |
| 1765 | r[1].br_blockcount = | 1651 | r[1].br_blockcount = |
| 1766 | PREV.br_startoff + PREV.br_blockcount - new_endoff; | 1652 | PREV.br_startoff + PREV.br_blockcount - new_endoff; |
| 1767 | r[1].br_startblock = new->br_startblock + new->br_blockcount; | 1653 | r[1].br_startblock = new->br_startblock + new->br_blockcount; |
| 1768 | r[1].br_state = oldext; | 1654 | r[1].br_state = oldext; |
| 1769 | XFS_BMAP_TRACE_INSERT("0", ip, idx + 1, 2, &r[0], &r[1], | 1655 | xfs_iext_insert(ip, idx + 1, 2, &r[0], state); |
| 1770 | XFS_DATA_FORK); | ||
| 1771 | xfs_iext_insert(ifp, idx + 1, 2, &r[0]); | ||
| 1772 | ip->i_df.if_lastex = idx + 1; | 1656 | ip->i_df.if_lastex = idx + 1; |
| 1773 | ip->i_d.di_nextents += 2; | 1657 | ip->i_d.di_nextents += 2; |
| 1774 | if (cur == NULL) | 1658 | if (cur == NULL) |
| @@ -1813,13 +1697,13 @@ xfs_bmap_add_extent_unwritten_real( | |||
| 1813 | temp2 = PREV.br_blockcount; | 1697 | temp2 = PREV.br_blockcount; |
| 1814 | break; | 1698 | break; |
| 1815 | 1699 | ||
| 1816 | case MASK3(LEFT_FILLING, LEFT_CONTIG, RIGHT_CONTIG): | 1700 | case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: |
| 1817 | case MASK3(RIGHT_FILLING, LEFT_CONTIG, RIGHT_CONTIG): | 1701 | case BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: |
| 1818 | case MASK2(LEFT_FILLING, RIGHT_CONTIG): | 1702 | case BMAP_LEFT_FILLING | BMAP_RIGHT_CONTIG: |
| 1819 | case MASK2(RIGHT_FILLING, LEFT_CONTIG): | 1703 | case BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG: |
| 1820 | case MASK2(LEFT_CONTIG, RIGHT_CONTIG): | 1704 | case BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: |
| 1821 | case MASK(LEFT_CONTIG): | 1705 | case BMAP_LEFT_CONTIG: |
| 1822 | case MASK(RIGHT_CONTIG): | 1706 | case BMAP_RIGHT_CONTIG: |
| 1823 | /* | 1707 | /* |
| 1824 | * These cases are all impossible. | 1708 | * These cases are all impossible. |
| 1825 | */ | 1709 | */ |
| @@ -1839,14 +1723,6 @@ done: | |||
| 1839 | #undef LEFT | 1723 | #undef LEFT |
| 1840 | #undef RIGHT | 1724 | #undef RIGHT |
| 1841 | #undef PREV | 1725 | #undef PREV |
| 1842 | #undef MASK | ||
| 1843 | #undef MASK2 | ||
| 1844 | #undef MASK3 | ||
| 1845 | #undef MASK4 | ||
| 1846 | #undef STATE_SET | ||
| 1847 | #undef STATE_TEST | ||
| 1848 | #undef STATE_SET_TEST | ||
| 1849 | #undef SWITCH_STATE | ||
| 1850 | } | 1726 | } |
| 1851 | 1727 | ||
| 1852 | /* | 1728 | /* |
| @@ -1872,62 +1748,57 @@ xfs_bmap_add_extent_hole_delay( | |||
| 1872 | int state; /* state bits, accessed thru macros */ | 1748 | int state; /* state bits, accessed thru macros */ |
| 1873 | xfs_filblks_t temp=0; /* temp for indirect calculations */ | 1749 | xfs_filblks_t temp=0; /* temp for indirect calculations */ |
| 1874 | xfs_filblks_t temp2=0; | 1750 | xfs_filblks_t temp2=0; |
| 1875 | enum { /* bit number definitions for state */ | ||
| 1876 | LEFT_CONTIG, RIGHT_CONTIG, | ||
| 1877 | LEFT_DELAY, RIGHT_DELAY, | ||
| 1878 | LEFT_VALID, RIGHT_VALID | ||
| 1879 | }; | ||
| 1880 | |||
| 1881 | #define MASK(b) (1 << (b)) | ||
| 1882 | #define MASK2(a,b) (MASK(a) | MASK(b)) | ||
| 1883 | #define STATE_SET(b,v) ((v) ? (state |= MASK(b)) : (state &= ~MASK(b))) | ||
| 1884 | #define STATE_TEST(b) (state & MASK(b)) | ||
| 1885 | #define STATE_SET_TEST(b,v) ((v) ? ((state |= MASK(b)), 1) : \ | ||
| 1886 | ((state &= ~MASK(b)), 0)) | ||
| 1887 | #define SWITCH_STATE (state & MASK2(LEFT_CONTIG, RIGHT_CONTIG)) | ||
| 1888 | 1751 | ||
| 1889 | ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); | 1752 | ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); |
| 1890 | ep = xfs_iext_get_ext(ifp, idx); | 1753 | ep = xfs_iext_get_ext(ifp, idx); |
| 1891 | state = 0; | 1754 | state = 0; |
| 1892 | ASSERT(isnullstartblock(new->br_startblock)); | 1755 | ASSERT(isnullstartblock(new->br_startblock)); |
| 1756 | |||
| 1893 | /* | 1757 | /* |
| 1894 | * Check and set flags if this segment has a left neighbor | 1758 | * Check and set flags if this segment has a left neighbor |
| 1895 | */ | 1759 | */ |
| 1896 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { | 1760 | if (idx > 0) { |
| 1761 | state |= BMAP_LEFT_VALID; | ||
| 1897 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left); | 1762 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left); |
| 1898 | STATE_SET(LEFT_DELAY, isnullstartblock(left.br_startblock)); | 1763 | |
| 1764 | if (isnullstartblock(left.br_startblock)) | ||
| 1765 | state |= BMAP_LEFT_DELAY; | ||
| 1899 | } | 1766 | } |
| 1767 | |||
| 1900 | /* | 1768 | /* |
| 1901 | * Check and set flags if the current (right) segment exists. | 1769 | * Check and set flags if the current (right) segment exists. |
| 1902 | * If it doesn't exist, we're converting the hole at end-of-file. | 1770 | * If it doesn't exist, we're converting the hole at end-of-file. |
| 1903 | */ | 1771 | */ |
| 1904 | if (STATE_SET_TEST(RIGHT_VALID, | 1772 | if (idx < ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) { |
| 1905 | idx < | 1773 | state |= BMAP_RIGHT_VALID; |
| 1906 | ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t))) { | ||
| 1907 | xfs_bmbt_get_all(ep, &right); | 1774 | xfs_bmbt_get_all(ep, &right); |
| 1908 | STATE_SET(RIGHT_DELAY, isnullstartblock(right.br_startblock)); | 1775 | |
| 1776 | if (isnullstartblock(right.br_startblock)) | ||
| 1777 | state |= BMAP_RIGHT_DELAY; | ||
| 1909 | } | 1778 | } |
| 1779 | |||
| 1910 | /* | 1780 | /* |
| 1911 | * Set contiguity flags on the left and right neighbors. | 1781 | * Set contiguity flags on the left and right neighbors. |
| 1912 | * Don't let extents get too large, even if the pieces are contiguous. | 1782 | * Don't let extents get too large, even if the pieces are contiguous. |
| 1913 | */ | 1783 | */ |
| 1914 | STATE_SET(LEFT_CONTIG, | 1784 | if ((state & BMAP_LEFT_VALID) && (state & BMAP_LEFT_DELAY) && |
| 1915 | STATE_TEST(LEFT_VALID) && STATE_TEST(LEFT_DELAY) && | 1785 | left.br_startoff + left.br_blockcount == new->br_startoff && |
| 1916 | left.br_startoff + left.br_blockcount == new->br_startoff && | 1786 | left.br_blockcount + new->br_blockcount <= MAXEXTLEN) |
| 1917 | left.br_blockcount + new->br_blockcount <= MAXEXTLEN); | 1787 | state |= BMAP_LEFT_CONTIG; |
| 1918 | STATE_SET(RIGHT_CONTIG, | 1788 | |
| 1919 | STATE_TEST(RIGHT_VALID) && STATE_TEST(RIGHT_DELAY) && | 1789 | if ((state & BMAP_RIGHT_VALID) && (state & BMAP_RIGHT_DELAY) && |
| 1920 | new->br_startoff + new->br_blockcount == right.br_startoff && | 1790 | new->br_startoff + new->br_blockcount == right.br_startoff && |
| 1921 | new->br_blockcount + right.br_blockcount <= MAXEXTLEN && | 1791 | new->br_blockcount + right.br_blockcount <= MAXEXTLEN && |
| 1922 | (!STATE_TEST(LEFT_CONTIG) || | 1792 | (!(state & BMAP_LEFT_CONTIG) || |
| 1923 | (left.br_blockcount + new->br_blockcount + | 1793 | (left.br_blockcount + new->br_blockcount + |
| 1924 | right.br_blockcount <= MAXEXTLEN))); | 1794 | right.br_blockcount <= MAXEXTLEN))) |
| 1795 | state |= BMAP_RIGHT_CONTIG; | ||
| 1796 | |||
| 1925 | /* | 1797 | /* |
| 1926 | * Switch out based on the contiguity flags. | 1798 | * Switch out based on the contiguity flags. |
| 1927 | */ | 1799 | */ |
| 1928 | switch (SWITCH_STATE) { | 1800 | switch (state & (BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG)) { |
| 1929 | 1801 | case BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: | |
| 1930 | case MASK2(LEFT_CONTIG, RIGHT_CONTIG): | ||
| 1931 | /* | 1802 | /* |
| 1932 | * New allocation is contiguous with delayed allocations | 1803 | * New allocation is contiguous with delayed allocations |
| 1933 | * on the left and on the right. | 1804 | * on the left and on the right. |
| @@ -1935,8 +1806,8 @@ xfs_bmap_add_extent_hole_delay( | |||
| 1935 | */ | 1806 | */ |
| 1936 | temp = left.br_blockcount + new->br_blockcount + | 1807 | temp = left.br_blockcount + new->br_blockcount + |
| 1937 | right.br_blockcount; | 1808 | right.br_blockcount; |
| 1938 | XFS_BMAP_TRACE_PRE_UPDATE("LC|RC", ip, idx - 1, | 1809 | |
| 1939 | XFS_DATA_FORK); | 1810 | trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_); |
| 1940 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp); | 1811 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp); |
| 1941 | oldlen = startblockval(left.br_startblock) + | 1812 | oldlen = startblockval(left.br_startblock) + |
| 1942 | startblockval(new->br_startblock) + | 1813 | startblockval(new->br_startblock) + |
| @@ -1944,53 +1815,52 @@ xfs_bmap_add_extent_hole_delay( | |||
| 1944 | newlen = xfs_bmap_worst_indlen(ip, temp); | 1815 | newlen = xfs_bmap_worst_indlen(ip, temp); |
| 1945 | xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1), | 1816 | xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1), |
| 1946 | nullstartblock((int)newlen)); | 1817 | nullstartblock((int)newlen)); |
| 1947 | XFS_BMAP_TRACE_POST_UPDATE("LC|RC", ip, idx - 1, | 1818 | trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_); |
| 1948 | XFS_DATA_FORK); | 1819 | |
| 1949 | XFS_BMAP_TRACE_DELETE("LC|RC", ip, idx, 1, XFS_DATA_FORK); | 1820 | xfs_iext_remove(ip, idx, 1, state); |
| 1950 | xfs_iext_remove(ifp, idx, 1); | ||
| 1951 | ip->i_df.if_lastex = idx - 1; | 1821 | ip->i_df.if_lastex = idx - 1; |
| 1952 | /* DELTA: Two in-core extents were replaced by one. */ | 1822 | /* DELTA: Two in-core extents were replaced by one. */ |
| 1953 | temp2 = temp; | 1823 | temp2 = temp; |
| 1954 | temp = left.br_startoff; | 1824 | temp = left.br_startoff; |
| 1955 | break; | 1825 | break; |
| 1956 | 1826 | ||
| 1957 | case MASK(LEFT_CONTIG): | 1827 | case BMAP_LEFT_CONTIG: |
| 1958 | /* | 1828 | /* |
| 1959 | * New allocation is contiguous with a delayed allocation | 1829 | * New allocation is contiguous with a delayed allocation |
| 1960 | * on the left. | 1830 | * on the left. |
| 1961 | * Merge the new allocation with the left neighbor. | 1831 | * Merge the new allocation with the left neighbor. |
| 1962 | */ | 1832 | */ |
| 1963 | temp = left.br_blockcount + new->br_blockcount; | 1833 | temp = left.br_blockcount + new->br_blockcount; |
| 1964 | XFS_BMAP_TRACE_PRE_UPDATE("LC", ip, idx - 1, | 1834 | trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_); |
| 1965 | XFS_DATA_FORK); | ||
| 1966 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp); | 1835 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp); |
| 1967 | oldlen = startblockval(left.br_startblock) + | 1836 | oldlen = startblockval(left.br_startblock) + |
| 1968 | startblockval(new->br_startblock); | 1837 | startblockval(new->br_startblock); |
| 1969 | newlen = xfs_bmap_worst_indlen(ip, temp); | 1838 | newlen = xfs_bmap_worst_indlen(ip, temp); |
| 1970 | xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1), | 1839 | xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1), |
| 1971 | nullstartblock((int)newlen)); | 1840 | nullstartblock((int)newlen)); |
| 1972 | XFS_BMAP_TRACE_POST_UPDATE("LC", ip, idx - 1, | 1841 | trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_); |
| 1973 | XFS_DATA_FORK); | 1842 | |
| 1974 | ip->i_df.if_lastex = idx - 1; | 1843 | ip->i_df.if_lastex = idx - 1; |
| 1975 | /* DELTA: One in-core extent grew into a hole. */ | 1844 | /* DELTA: One in-core extent grew into a hole. */ |
| 1976 | temp2 = temp; | 1845 | temp2 = temp; |
| 1977 | temp = left.br_startoff; | 1846 | temp = left.br_startoff; |
| 1978 | break; | 1847 | break; |
| 1979 | 1848 | ||
| 1980 | case MASK(RIGHT_CONTIG): | 1849 | case BMAP_RIGHT_CONTIG: |
| 1981 | /* | 1850 | /* |
| 1982 | * New allocation is contiguous with a delayed allocation | 1851 | * New allocation is contiguous with a delayed allocation |
| 1983 | * on the right. | 1852 | * on the right. |
| 1984 | * Merge the new allocation with the right neighbor. | 1853 | * Merge the new allocation with the right neighbor. |
| 1985 | */ | 1854 | */ |
| 1986 | XFS_BMAP_TRACE_PRE_UPDATE("RC", ip, idx, XFS_DATA_FORK); | 1855 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 1987 | temp = new->br_blockcount + right.br_blockcount; | 1856 | temp = new->br_blockcount + right.br_blockcount; |
| 1988 | oldlen = startblockval(new->br_startblock) + | 1857 | oldlen = startblockval(new->br_startblock) + |
| 1989 | startblockval(right.br_startblock); | 1858 | startblockval(right.br_startblock); |
| 1990 | newlen = xfs_bmap_worst_indlen(ip, temp); | 1859 | newlen = xfs_bmap_worst_indlen(ip, temp); |
| 1991 | xfs_bmbt_set_allf(ep, new->br_startoff, | 1860 | xfs_bmbt_set_allf(ep, new->br_startoff, |
| 1992 | nullstartblock((int)newlen), temp, right.br_state); | 1861 | nullstartblock((int)newlen), temp, right.br_state); |
| 1993 | XFS_BMAP_TRACE_POST_UPDATE("RC", ip, idx, XFS_DATA_FORK); | 1862 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 1863 | |||
| 1994 | ip->i_df.if_lastex = idx; | 1864 | ip->i_df.if_lastex = idx; |
| 1995 | /* DELTA: One in-core extent grew into a hole. */ | 1865 | /* DELTA: One in-core extent grew into a hole. */ |
| 1996 | temp2 = temp; | 1866 | temp2 = temp; |
| @@ -2004,9 +1874,7 @@ xfs_bmap_add_extent_hole_delay( | |||
| 2004 | * Insert a new entry. | 1874 | * Insert a new entry. |
| 2005 | */ | 1875 | */ |
| 2006 | oldlen = newlen = 0; | 1876 | oldlen = newlen = 0; |
| 2007 | XFS_BMAP_TRACE_INSERT("0", ip, idx, 1, new, NULL, | 1877 | xfs_iext_insert(ip, idx, 1, new, state); |
| 2008 | XFS_DATA_FORK); | ||
| 2009 | xfs_iext_insert(ifp, idx, 1, new); | ||
| 2010 | ip->i_df.if_lastex = idx; | 1878 | ip->i_df.if_lastex = idx; |
| 2011 | /* DELTA: A new in-core extent was added in a hole. */ | 1879 | /* DELTA: A new in-core extent was added in a hole. */ |
| 2012 | temp2 = new->br_blockcount; | 1880 | temp2 = new->br_blockcount; |
| @@ -2030,12 +1898,6 @@ xfs_bmap_add_extent_hole_delay( | |||
| 2030 | } | 1898 | } |
| 2031 | *logflagsp = 0; | 1899 | *logflagsp = 0; |
| 2032 | return 0; | 1900 | return 0; |
| 2033 | #undef MASK | ||
| 2034 | #undef MASK2 | ||
| 2035 | #undef STATE_SET | ||
| 2036 | #undef STATE_TEST | ||
| 2037 | #undef STATE_SET_TEST | ||
| 2038 | #undef SWITCH_STATE | ||
| 2039 | } | 1901 | } |
| 2040 | 1902 | ||
| 2041 | /* | 1903 | /* |
| @@ -2062,83 +1924,75 @@ xfs_bmap_add_extent_hole_real( | |||
| 2062 | int state; /* state bits, accessed thru macros */ | 1924 | int state; /* state bits, accessed thru macros */ |
| 2063 | xfs_filblks_t temp=0; | 1925 | xfs_filblks_t temp=0; |
| 2064 | xfs_filblks_t temp2=0; | 1926 | xfs_filblks_t temp2=0; |
| 2065 | enum { /* bit number definitions for state */ | ||
| 2066 | LEFT_CONTIG, RIGHT_CONTIG, | ||
| 2067 | LEFT_DELAY, RIGHT_DELAY, | ||
| 2068 | LEFT_VALID, RIGHT_VALID | ||
| 2069 | }; | ||
| 2070 | |||
| 2071 | #define MASK(b) (1 << (b)) | ||
| 2072 | #define MASK2(a,b) (MASK(a) | MASK(b)) | ||
| 2073 | #define STATE_SET(b,v) ((v) ? (state |= MASK(b)) : (state &= ~MASK(b))) | ||
| 2074 | #define STATE_TEST(b) (state & MASK(b)) | ||
| 2075 | #define STATE_SET_TEST(b,v) ((v) ? ((state |= MASK(b)), 1) : \ | ||
| 2076 | ((state &= ~MASK(b)), 0)) | ||
| 2077 | #define SWITCH_STATE (state & MASK2(LEFT_CONTIG, RIGHT_CONTIG)) | ||
| 2078 | 1927 | ||
| 2079 | ifp = XFS_IFORK_PTR(ip, whichfork); | 1928 | ifp = XFS_IFORK_PTR(ip, whichfork); |
| 2080 | ASSERT(idx <= ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)); | 1929 | ASSERT(idx <= ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)); |
| 2081 | ep = xfs_iext_get_ext(ifp, idx); | 1930 | ep = xfs_iext_get_ext(ifp, idx); |
| 2082 | state = 0; | 1931 | state = 0; |
| 1932 | |||
| 1933 | if (whichfork == XFS_ATTR_FORK) | ||
| 1934 | state |= BMAP_ATTRFORK; | ||
| 1935 | |||
| 2083 | /* | 1936 | /* |
| 2084 | * Check and set flags if this segment has a left neighbor. | 1937 | * Check and set flags if this segment has a left neighbor. |
| 2085 | */ | 1938 | */ |
| 2086 | if (STATE_SET_TEST(LEFT_VALID, idx > 0)) { | 1939 | if (idx > 0) { |
| 1940 | state |= BMAP_LEFT_VALID; | ||
| 2087 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left); | 1941 | xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left); |
| 2088 | STATE_SET(LEFT_DELAY, isnullstartblock(left.br_startblock)); | 1942 | if (isnullstartblock(left.br_startblock)) |
| 1943 | state |= BMAP_LEFT_DELAY; | ||
| 2089 | } | 1944 | } |
| 1945 | |||
| 2090 | /* | 1946 | /* |
| 2091 | * Check and set flags if this segment has a current value. | 1947 | * Check and set flags if this segment has a current value. |
| 2092 | * Not true if we're inserting into the "hole" at eof. | 1948 | * Not true if we're inserting into the "hole" at eof. |
| 2093 | */ | 1949 | */ |
| 2094 | if (STATE_SET_TEST(RIGHT_VALID, | 1950 | if (idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)) { |
| 2095 | idx < | 1951 | state |= BMAP_RIGHT_VALID; |
| 2096 | ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))) { | ||
| 2097 | xfs_bmbt_get_all(ep, &right); | 1952 | xfs_bmbt_get_all(ep, &right); |
| 2098 | STATE_SET(RIGHT_DELAY, isnullstartblock(right.br_startblock)); | 1953 | if (isnullstartblock(right.br_startblock)) |
| 1954 | state |= BMAP_RIGHT_DELAY; | ||
| 2099 | } | 1955 | } |
| 1956 | |||
| 2100 | /* | 1957 | /* |
| 2101 | * We're inserting a real allocation between "left" and "right". | 1958 | * We're inserting a real allocation between "left" and "right". |
| 2102 | * Set the contiguity flags. Don't let extents get too large. | 1959 | * Set the contiguity flags. Don't let extents get too large. |
| 2103 | */ | 1960 | */ |
| 2104 | STATE_SET(LEFT_CONTIG, | 1961 | if ((state & BMAP_LEFT_VALID) && !(state & BMAP_LEFT_DELAY) && |
| 2105 | STATE_TEST(LEFT_VALID) && !STATE_TEST(LEFT_DELAY) && | 1962 | left.br_startoff + left.br_blockcount == new->br_startoff && |
| 2106 | left.br_startoff + left.br_blockcount == new->br_startoff && | 1963 | left.br_startblock + left.br_blockcount == new->br_startblock && |
| 2107 | left.br_startblock + left.br_blockcount == new->br_startblock && | 1964 | left.br_state == new->br_state && |
| 2108 | left.br_state == new->br_state && | 1965 | left.br_blockcount + new->br_blockcount <= MAXEXTLEN) |
| 2109 | left.br_blockcount + new->br_blockcount <= MAXEXTLEN); | 1966 | state |= BMAP_LEFT_CONTIG; |
| 2110 | STATE_SET(RIGHT_CONTIG, | 1967 | |
| 2111 | STATE_TEST(RIGHT_VALID) && !STATE_TEST(RIGHT_DELAY) && | 1968 | if ((state & BMAP_RIGHT_VALID) && !(state & BMAP_RIGHT_DELAY) && |
| 2112 | new->br_startoff + new->br_blockcount == right.br_startoff && | 1969 | new->br_startoff + new->br_blockcount == right.br_startoff && |
| 2113 | new->br_startblock + new->br_blockcount == | 1970 | new->br_startblock + new->br_blockcount == right.br_startblock && |
| 2114 | right.br_startblock && | 1971 | new->br_state == right.br_state && |
| 2115 | new->br_state == right.br_state && | 1972 | new->br_blockcount + right.br_blockcount <= MAXEXTLEN && |
| 2116 | new->br_blockcount + right.br_blockcount <= MAXEXTLEN && | 1973 | (!(state & BMAP_LEFT_CONTIG) || |
| 2117 | (!STATE_TEST(LEFT_CONTIG) || | 1974 | left.br_blockcount + new->br_blockcount + |
| 2118 | left.br_blockcount + new->br_blockcount + | 1975 | right.br_blockcount <= MAXEXTLEN)) |
| 2119 | right.br_blockcount <= MAXEXTLEN)); | 1976 | state |= BMAP_RIGHT_CONTIG; |
| 2120 | 1977 | ||
| 2121 | error = 0; | 1978 | error = 0; |
| 2122 | /* | 1979 | /* |
| 2123 | * Select which case we're in here, and implement it. | 1980 | * Select which case we're in here, and implement it. |
| 2124 | */ | 1981 | */ |
| 2125 | switch (SWITCH_STATE) { | 1982 | switch (state & (BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG)) { |
| 2126 | 1983 | case BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG: | |
| 2127 | case MASK2(LEFT_CONTIG, RIGHT_CONTIG): | ||
| 2128 | /* | 1984 | /* |
| 2129 | * New allocation is contiguous with real allocations on the | 1985 | * New allocation is contiguous with real allocations on the |
| 2130 | * left and on the right. | 1986 | * left and on the right. |
| 2131 | * Merge all three into a single extent record. | 1987 | * Merge all three into a single extent record. |
| 2132 | */ | 1988 | */ |
| 2133 | XFS_BMAP_TRACE_PRE_UPDATE("LC|RC", ip, idx - 1, | 1989 | trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_); |
| 2134 | whichfork); | ||
| 2135 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 1990 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
| 2136 | left.br_blockcount + new->br_blockcount + | 1991 | left.br_blockcount + new->br_blockcount + |
| 2137 | right.br_blockcount); | 1992 | right.br_blockcount); |
| 2138 | XFS_BMAP_TRACE_POST_UPDATE("LC|RC", ip, idx - 1, | 1993 | trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_); |
| 2139 | whichfork); | 1994 | |
| 2140 | XFS_BMAP_TRACE_DELETE("LC|RC", ip, idx, 1, whichfork); | 1995 | xfs_iext_remove(ip, idx, 1, state); |
| 2141 | xfs_iext_remove(ifp, idx, 1); | ||
| 2142 | ifp->if_lastex = idx - 1; | 1996 | ifp->if_lastex = idx - 1; |
| 2143 | XFS_IFORK_NEXT_SET(ip, whichfork, | 1997 | XFS_IFORK_NEXT_SET(ip, whichfork, |
| 2144 | XFS_IFORK_NEXTENTS(ip, whichfork) - 1); | 1998 | XFS_IFORK_NEXTENTS(ip, whichfork) - 1); |
| @@ -2173,16 +2027,17 @@ xfs_bmap_add_extent_hole_real( | |||
| 2173 | right.br_blockcount; | 2027 | right.br_blockcount; |
| 2174 | break; | 2028 | break; |
| 2175 | 2029 | ||
| 2176 | case MASK(LEFT_CONTIG): | 2030 | case BMAP_LEFT_CONTIG: |
| 2177 | /* | 2031 | /* |
| 2178 | * New allocation is contiguous with a real allocation | 2032 | * New allocation is contiguous with a real allocation |
| 2179 | * on the left. | 2033 | * on the left. |
| 2180 | * Merge the new allocation with the left neighbor. | 2034 | * Merge the new allocation with the left neighbor. |
| 2181 | */ | 2035 | */ |
| 2182 | XFS_BMAP_TRACE_PRE_UPDATE("LC", ip, idx - 1, whichfork); | 2036 | trace_xfs_bmap_pre_update(ip, idx - 1, state, _THIS_IP_); |
| 2183 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), | 2037 | xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), |
| 2184 | left.br_blockcount + new->br_blockcount); | 2038 | left.br_blockcount + new->br_blockcount); |
| 2185 | XFS_BMAP_TRACE_POST_UPDATE("LC", ip, idx - 1, whichfork); | 2039 | trace_xfs_bmap_post_update(ip, idx - 1, state, _THIS_IP_); |
| 2040 | |||
| 2186 | ifp->if_lastex = idx - 1; | 2041 | ifp->if_lastex = idx - 1; |
| 2187 | if (cur == NULL) { | 2042 | if (cur == NULL) { |
| 2188 | rval = xfs_ilog_fext(whichfork); | 2043 | rval = xfs_ilog_fext(whichfork); |
| @@ -2207,17 +2062,18 @@ xfs_bmap_add_extent_hole_real( | |||
| 2207 | new->br_blockcount; | 2062 | new->br_blockcount; |
| 2208 | break; | 2063 | break; |
| 2209 | 2064 | ||
| 2210 | case MASK(RIGHT_CONTIG): | 2065 | case BMAP_RIGHT_CONTIG: |
| 2211 | /* | 2066 | /* |
| 2212 | * New allocation is contiguous with a real allocation | 2067 | * New allocation is contiguous with a real allocation |
| 2213 | * on the right. | 2068 | * on the right. |
| 2214 | * Merge the new allocation with the right neighbor. | 2069 | * Merge the new allocation with the right neighbor. |
| 2215 | */ | 2070 | */ |
| 2216 | XFS_BMAP_TRACE_PRE_UPDATE("RC", ip, idx, whichfork); | 2071 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 2217 | xfs_bmbt_set_allf(ep, new->br_startoff, new->br_startblock, | 2072 | xfs_bmbt_set_allf(ep, new->br_startoff, new->br_startblock, |
| 2218 | new->br_blockcount + right.br_blockcount, | 2073 | new->br_blockcount + right.br_blockcount, |
| 2219 | right.br_state); | 2074 | right.br_state); |
| 2220 | XFS_BMAP_TRACE_POST_UPDATE("RC", ip, idx, whichfork); | 2075 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 2076 | |||
| 2221 | ifp->if_lastex = idx; | 2077 | ifp->if_lastex = idx; |
| 2222 | if (cur == NULL) { | 2078 | if (cur == NULL) { |
| 2223 | rval = xfs_ilog_fext(whichfork); | 2079 | rval = xfs_ilog_fext(whichfork); |
| @@ -2248,8 +2104,7 @@ xfs_bmap_add_extent_hole_real( | |||
| 2248 | * real allocation. | 2104 | * real allocation. |
| 2249 | * Insert a new entry. | 2105 | * Insert a new entry. |
| 2250 | */ | 2106 | */ |
| 2251 | XFS_BMAP_TRACE_INSERT("0", ip, idx, 1, new, NULL, whichfork); | 2107 | xfs_iext_insert(ip, idx, 1, new, state); |
| 2252 | xfs_iext_insert(ifp, idx, 1, new); | ||
| 2253 | ifp->if_lastex = idx; | 2108 | ifp->if_lastex = idx; |
| 2254 | XFS_IFORK_NEXT_SET(ip, whichfork, | 2109 | XFS_IFORK_NEXT_SET(ip, whichfork, |
| 2255 | XFS_IFORK_NEXTENTS(ip, whichfork) + 1); | 2110 | XFS_IFORK_NEXTENTS(ip, whichfork) + 1); |
| @@ -2283,12 +2138,6 @@ xfs_bmap_add_extent_hole_real( | |||
| 2283 | done: | 2138 | done: |
| 2284 | *logflagsp = rval; | 2139 | *logflagsp = rval; |
| 2285 | return error; | 2140 | return error; |
| 2286 | #undef MASK | ||
| 2287 | #undef MASK2 | ||
| 2288 | #undef STATE_SET | ||
| 2289 | #undef STATE_TEST | ||
| 2290 | #undef STATE_SET_TEST | ||
| 2291 | #undef SWITCH_STATE | ||
| 2292 | } | 2141 | } |
| 2293 | 2142 | ||
| 2294 | /* | 2143 | /* |
| @@ -3115,8 +2964,13 @@ xfs_bmap_del_extent( | |||
| 3115 | uint qfield; /* quota field to update */ | 2964 | uint qfield; /* quota field to update */ |
| 3116 | xfs_filblks_t temp; /* for indirect length calculations */ | 2965 | xfs_filblks_t temp; /* for indirect length calculations */ |
| 3117 | xfs_filblks_t temp2; /* for indirect length calculations */ | 2966 | xfs_filblks_t temp2; /* for indirect length calculations */ |
| 2967 | int state = 0; | ||
| 3118 | 2968 | ||
| 3119 | XFS_STATS_INC(xs_del_exlist); | 2969 | XFS_STATS_INC(xs_del_exlist); |
| 2970 | |||
| 2971 | if (whichfork == XFS_ATTR_FORK) | ||
| 2972 | state |= BMAP_ATTRFORK; | ||
| 2973 | |||
| 3120 | mp = ip->i_mount; | 2974 | mp = ip->i_mount; |
| 3121 | ifp = XFS_IFORK_PTR(ip, whichfork); | 2975 | ifp = XFS_IFORK_PTR(ip, whichfork); |
| 3122 | ASSERT((idx >= 0) && (idx < ifp->if_bytes / | 2976 | ASSERT((idx >= 0) && (idx < ifp->if_bytes / |
| @@ -3196,8 +3050,8 @@ xfs_bmap_del_extent( | |||
| 3196 | /* | 3050 | /* |
| 3197 | * Matches the whole extent. Delete the entry. | 3051 | * Matches the whole extent. Delete the entry. |
| 3198 | */ | 3052 | */ |
| 3199 | XFS_BMAP_TRACE_DELETE("3", ip, idx, 1, whichfork); | 3053 | xfs_iext_remove(ip, idx, 1, |
| 3200 | xfs_iext_remove(ifp, idx, 1); | 3054 | whichfork == XFS_ATTR_FORK ? BMAP_ATTRFORK : 0); |
| 3201 | ifp->if_lastex = idx; | 3055 | ifp->if_lastex = idx; |
| 3202 | if (delay) | 3056 | if (delay) |
| 3203 | break; | 3057 | break; |
| @@ -3217,7 +3071,7 @@ xfs_bmap_del_extent( | |||
| 3217 | /* | 3071 | /* |
| 3218 | * Deleting the first part of the extent. | 3072 | * Deleting the first part of the extent. |
| 3219 | */ | 3073 | */ |
| 3220 | XFS_BMAP_TRACE_PRE_UPDATE("2", ip, idx, whichfork); | 3074 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 3221 | xfs_bmbt_set_startoff(ep, del_endoff); | 3075 | xfs_bmbt_set_startoff(ep, del_endoff); |
| 3222 | temp = got.br_blockcount - del->br_blockcount; | 3076 | temp = got.br_blockcount - del->br_blockcount; |
| 3223 | xfs_bmbt_set_blockcount(ep, temp); | 3077 | xfs_bmbt_set_blockcount(ep, temp); |
| @@ -3226,13 +3080,12 @@ xfs_bmap_del_extent( | |||
| 3226 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), | 3080 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), |
| 3227 | da_old); | 3081 | da_old); |
| 3228 | xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); | 3082 | xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); |
| 3229 | XFS_BMAP_TRACE_POST_UPDATE("2", ip, idx, | 3083 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 3230 | whichfork); | ||
| 3231 | da_new = temp; | 3084 | da_new = temp; |
| 3232 | break; | 3085 | break; |
| 3233 | } | 3086 | } |
| 3234 | xfs_bmbt_set_startblock(ep, del_endblock); | 3087 | xfs_bmbt_set_startblock(ep, del_endblock); |
| 3235 | XFS_BMAP_TRACE_POST_UPDATE("2", ip, idx, whichfork); | 3088 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 3236 | if (!cur) { | 3089 | if (!cur) { |
| 3237 | flags |= xfs_ilog_fext(whichfork); | 3090 | flags |= xfs_ilog_fext(whichfork); |
| 3238 | break; | 3091 | break; |
| @@ -3248,19 +3101,18 @@ xfs_bmap_del_extent( | |||
| 3248 | * Deleting the last part of the extent. | 3101 | * Deleting the last part of the extent. |
| 3249 | */ | 3102 | */ |
| 3250 | temp = got.br_blockcount - del->br_blockcount; | 3103 | temp = got.br_blockcount - del->br_blockcount; |
| 3251 | XFS_BMAP_TRACE_PRE_UPDATE("1", ip, idx, whichfork); | 3104 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 3252 | xfs_bmbt_set_blockcount(ep, temp); | 3105 | xfs_bmbt_set_blockcount(ep, temp); |
| 3253 | ifp->if_lastex = idx; | 3106 | ifp->if_lastex = idx; |
| 3254 | if (delay) { | 3107 | if (delay) { |
| 3255 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), | 3108 | temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp), |
| 3256 | da_old); | 3109 | da_old); |
| 3257 | xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); | 3110 | xfs_bmbt_set_startblock(ep, nullstartblock((int)temp)); |
| 3258 | XFS_BMAP_TRACE_POST_UPDATE("1", ip, idx, | 3111 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 3259 | whichfork); | ||
| 3260 | da_new = temp; | 3112 | da_new = temp; |
| 3261 | break; | 3113 | break; |
| 3262 | } | 3114 | } |
| 3263 | XFS_BMAP_TRACE_POST_UPDATE("1", ip, idx, whichfork); | 3115 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 3264 | if (!cur) { | 3116 | if (!cur) { |
| 3265 | flags |= xfs_ilog_fext(whichfork); | 3117 | flags |= xfs_ilog_fext(whichfork); |
| 3266 | break; | 3118 | break; |
| @@ -3277,7 +3129,7 @@ xfs_bmap_del_extent( | |||
| 3277 | * Deleting the middle of the extent. | 3129 | * Deleting the middle of the extent. |
| 3278 | */ | 3130 | */ |
| 3279 | temp = del->br_startoff - got.br_startoff; | 3131 | temp = del->br_startoff - got.br_startoff; |
| 3280 | XFS_BMAP_TRACE_PRE_UPDATE("0", ip, idx, whichfork); | 3132 | trace_xfs_bmap_pre_update(ip, idx, state, _THIS_IP_); |
| 3281 | xfs_bmbt_set_blockcount(ep, temp); | 3133 | xfs_bmbt_set_blockcount(ep, temp); |
| 3282 | new.br_startoff = del_endoff; | 3134 | new.br_startoff = del_endoff; |
| 3283 | temp2 = got_endoff - del_endoff; | 3135 | temp2 = got_endoff - del_endoff; |
| @@ -3364,10 +3216,8 @@ xfs_bmap_del_extent( | |||
| 3364 | } | 3216 | } |
| 3365 | } | 3217 | } |
| 3366 | } | 3218 | } |
| 3367 | XFS_BMAP_TRACE_POST_UPDATE("0", ip, idx, whichfork); | 3219 | trace_xfs_bmap_post_update(ip, idx, state, _THIS_IP_); |
| 3368 | XFS_BMAP_TRACE_INSERT("0", ip, idx + 1, 1, &new, NULL, | 3220 | xfs_iext_insert(ip, idx + 1, 1, &new, state); |
| 3369 | whichfork); | ||
| 3370 | xfs_iext_insert(ifp, idx + 1, 1, &new); | ||
| 3371 | ifp->if_lastex = idx + 1; | 3221 | ifp->if_lastex = idx + 1; |
| 3372 | break; | 3222 | break; |
| 3373 | } | 3223 | } |
| @@ -3687,7 +3537,9 @@ xfs_bmap_local_to_extents( | |||
| 3687 | xfs_iext_add(ifp, 0, 1); | 3537 | xfs_iext_add(ifp, 0, 1); |
| 3688 | ep = xfs_iext_get_ext(ifp, 0); | 3538 | ep = xfs_iext_get_ext(ifp, 0); |
| 3689 | xfs_bmbt_set_allf(ep, 0, args.fsbno, 1, XFS_EXT_NORM); | 3539 | xfs_bmbt_set_allf(ep, 0, args.fsbno, 1, XFS_EXT_NORM); |
| 3690 | XFS_BMAP_TRACE_POST_UPDATE("new", ip, 0, whichfork); | 3540 | trace_xfs_bmap_post_update(ip, 0, |
| 3541 | whichfork == XFS_ATTR_FORK ? BMAP_ATTRFORK : 0, | ||
| 3542 | _THIS_IP_); | ||
| 3691 | XFS_IFORK_NEXT_SET(ip, whichfork, 1); | 3543 | XFS_IFORK_NEXT_SET(ip, whichfork, 1); |
| 3692 | ip->i_d.di_nblocks = 1; | 3544 | ip->i_d.di_nblocks = 1; |
| 3693 | xfs_trans_mod_dquot_byino(tp, ip, | 3545 | xfs_trans_mod_dquot_byino(tp, ip, |
| @@ -3800,158 +3652,6 @@ xfs_bmap_search_extents( | |||
| 3800 | return ep; | 3652 | return ep; |
| 3801 | } | 3653 | } |
| 3802 | 3654 | ||
| 3803 | |||
| 3804 | #ifdef XFS_BMAP_TRACE | ||
| 3805 | ktrace_t *xfs_bmap_trace_buf; | ||
| 3806 | |||
| 3807 | /* | ||
| 3808 | * Add a bmap trace buffer entry. Base routine for the others. | ||
| 3809 | */ | ||
| 3810 | STATIC void | ||
| 3811 | xfs_bmap_trace_addentry( | ||
| 3812 | int opcode, /* operation */ | ||
| 3813 | const char *fname, /* function name */ | ||
| 3814 | char *desc, /* operation description */ | ||
| 3815 | xfs_inode_t *ip, /* incore inode pointer */ | ||
| 3816 | xfs_extnum_t idx, /* index of entry(ies) */ | ||
| 3817 | xfs_extnum_t cnt, /* count of entries, 1 or 2 */ | ||
| 3818 | xfs_bmbt_rec_host_t *r1, /* first record */ | ||
| 3819 | xfs_bmbt_rec_host_t *r2, /* second record or null */ | ||
| 3820 | int whichfork) /* data or attr fork */ | ||
| 3821 | { | ||
| 3822 | xfs_bmbt_rec_host_t tr2; | ||
| 3823 | |||
| 3824 | ASSERT(cnt == 1 || cnt == 2); | ||
| 3825 | ASSERT(r1 != NULL); | ||
| 3826 | if (cnt == 1) { | ||
| 3827 | ASSERT(r2 == NULL); | ||
| 3828 | r2 = &tr2; | ||
| 3829 | memset(&tr2, 0, sizeof(tr2)); | ||
| 3830 | } else | ||
| 3831 | ASSERT(r2 != NULL); | ||
| 3832 | ktrace_enter(xfs_bmap_trace_buf, | ||
| 3833 | (void *)(__psint_t)(opcode | (whichfork << 16)), | ||
| 3834 | (void *)fname, (void *)desc, (void *)ip, | ||
| 3835 | (void *)(__psint_t)idx, | ||
| 3836 | (void *)(__psint_t)cnt, | ||
| 3837 | (void *)(__psunsigned_t)(ip->i_ino >> 32), | ||
| 3838 | (void *)(__psunsigned_t)(unsigned)ip->i_ino, | ||
| 3839 | (void *)(__psunsigned_t)(r1->l0 >> 32), | ||
| 3840 | (void *)(__psunsigned_t)(unsigned)(r1->l0), | ||
| 3841 | (void *)(__psunsigned_t)(r1->l1 >> 32), | ||
| 3842 | (void *)(__psunsigned_t)(unsigned)(r1->l1), | ||
| 3843 | (void *)(__psunsigned_t)(r2->l0 >> 32), | ||
| 3844 | (void *)(__psunsigned_t)(unsigned)(r2->l0), | ||
| 3845 | (void *)(__psunsigned_t)(r2->l1 >> 32), | ||
| 3846 | (void *)(__psunsigned_t)(unsigned)(r2->l1) | ||
| 3847 | ); | ||
| 3848 | ASSERT(ip->i_xtrace); | ||
| 3849 | ktrace_enter(ip->i_xtrace, | ||
| 3850 | (void *)(__psint_t)(opcode | (whichfork << 16)), | ||
| 3851 | (void *)fname, (void *)desc, (void *)ip, | ||
| 3852 | (void *)(__psint_t)idx, | ||
| 3853 | (void *)(__psint_t)cnt, | ||
| 3854 | (void *)(__psunsigned_t)(ip->i_ino >> 32), | ||
| 3855 | (void *)(__psunsigned_t)(unsigned)ip->i_ino, | ||
| 3856 | (void *)(__psunsigned_t)(r1->l0 >> 32), | ||
| 3857 | (void *)(__psunsigned_t)(unsigned)(r1->l0), | ||
| 3858 | (void *)(__psunsigned_t)(r1->l1 >> 32), | ||
| 3859 | (void *)(__psunsigned_t)(unsigned)(r1->l1), | ||
| 3860 | (void *)(__psunsigned_t)(r2->l0 >> 32), | ||
| 3861 | (void *)(__psunsigned_t)(unsigned)(r2->l0), | ||
| 3862 | (void *)(__psunsigned_t)(r2->l1 >> 32), | ||
| 3863 | (void *)(__psunsigned_t)(unsigned)(r2->l1) | ||
| 3864 | ); | ||
| 3865 | } | ||
| 3866 | |||
| 3867 | /* | ||
| 3868 | * Add bmap trace entry prior to a call to xfs_iext_remove. | ||
| 3869 | */ | ||
| 3870 | STATIC void | ||
| 3871 | xfs_bmap_trace_delete( | ||
| 3872 | const char *fname, /* function name */ | ||
| 3873 | char *desc, /* operation description */ | ||
| 3874 | xfs_inode_t *ip, /* incore inode pointer */ | ||
| 3875 | xfs_extnum_t idx, /* index of entry(entries) deleted */ | ||
| 3876 | xfs_extnum_t cnt, /* count of entries deleted, 1 or 2 */ | ||
| 3877 | int whichfork) /* data or attr fork */ | ||
| 3878 | { | ||
| 3879 | xfs_ifork_t *ifp; /* inode fork pointer */ | ||
| 3880 | |||
| 3881 | ifp = XFS_IFORK_PTR(ip, whichfork); | ||
| 3882 | xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_DELETE, fname, desc, ip, idx, | ||
| 3883 | cnt, xfs_iext_get_ext(ifp, idx), | ||
| 3884 | cnt == 2 ? xfs_iext_get_ext(ifp, idx + 1) : NULL, | ||
| 3885 | whichfork); | ||
| 3886 | } | ||
| 3887 | |||
| 3888 | /* | ||
| 3889 | * Add bmap trace entry prior to a call to xfs_iext_insert, or | ||
| 3890 | * reading in the extents list from the disk (in the btree). | ||
| 3891 | */ | ||
| 3892 | STATIC void | ||
| 3893 | xfs_bmap_trace_insert( | ||
| 3894 | const char *fname, /* function name */ | ||
| 3895 | char *desc, /* operation description */ | ||
| 3896 | xfs_inode_t *ip, /* incore inode pointer */ | ||
| 3897 | xfs_extnum_t idx, /* index of entry(entries) inserted */ | ||
| 3898 | xfs_extnum_t cnt, /* count of entries inserted, 1 or 2 */ | ||
| 3899 | xfs_bmbt_irec_t *r1, /* inserted record 1 */ | ||
| 3900 | xfs_bmbt_irec_t *r2, /* inserted record 2 or null */ | ||
| 3901 | int whichfork) /* data or attr fork */ | ||
| 3902 | { | ||
| 3903 | xfs_bmbt_rec_host_t tr1; /* compressed record 1 */ | ||
| 3904 | xfs_bmbt_rec_host_t tr2; /* compressed record 2 if needed */ | ||
| 3905 | |||
| 3906 | xfs_bmbt_set_all(&tr1, r1); | ||
| 3907 | if (cnt == 2) { | ||
| 3908 | ASSERT(r2 != NULL); | ||
| 3909 | xfs_bmbt_set_all(&tr2, r2); | ||
| 3910 | } else { | ||
| 3911 | ASSERT(cnt == 1); | ||
| 3912 | ASSERT(r2 == NULL); | ||
| 3913 | } | ||
| 3914 | xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_INSERT, fname, desc, ip, idx, | ||
| 3915 | cnt, &tr1, cnt == 2 ? &tr2 : NULL, whichfork); | ||
| 3916 | } | ||
| 3917 | |||
| 3918 | /* | ||
| 3919 | * Add bmap trace entry after updating an extent record in place. | ||
| 3920 | */ | ||
| 3921 | STATIC void | ||
| 3922 | xfs_bmap_trace_post_update( | ||
| 3923 | const char *fname, /* function name */ | ||
| 3924 | char *desc, /* operation description */ | ||
| 3925 | xfs_inode_t *ip, /* incore inode pointer */ | ||
| 3926 | xfs_extnum_t idx, /* index of entry updated */ | ||
| 3927 | int whichfork) /* data or attr fork */ | ||
| 3928 | { | ||
| 3929 | xfs_ifork_t *ifp; /* inode fork pointer */ | ||
| 3930 | |||
| 3931 | ifp = XFS_IFORK_PTR(ip, whichfork); | ||
| 3932 | xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_POST_UP, fname, desc, ip, idx, | ||
| 3933 | 1, xfs_iext_get_ext(ifp, idx), NULL, whichfork); | ||
| 3934 | } | ||
| 3935 | |||
| 3936 | /* | ||
| 3937 | * Add bmap trace entry prior to updating an extent record in place. | ||
| 3938 | */ | ||
| 3939 | STATIC void | ||
| 3940 | xfs_bmap_trace_pre_update( | ||
| 3941 | const char *fname, /* function name */ | ||
| 3942 | char *desc, /* operation description */ | ||
| 3943 | xfs_inode_t *ip, /* incore inode pointer */ | ||
| 3944 | xfs_extnum_t idx, /* index of entry to be updated */ | ||
| 3945 | int whichfork) /* data or attr fork */ | ||
| 3946 | { | ||
| 3947 | xfs_ifork_t *ifp; /* inode fork pointer */ | ||
| 3948 | |||
| 3949 | ifp = XFS_IFORK_PTR(ip, whichfork); | ||
| 3950 | xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_PRE_UP, fname, desc, ip, idx, 1, | ||
| 3951 | xfs_iext_get_ext(ifp, idx), NULL, whichfork); | ||
| 3952 | } | ||
| 3953 | #endif /* XFS_BMAP_TRACE */ | ||
| 3954 | |||
| 3955 | /* | 3655 | /* |
| 3956 | * Compute the worst-case number of indirect blocks that will be used | 3656 | * Compute the worst-case number of indirect blocks that will be used |
| 3957 | * for ip's delayed extent of length "len". | 3657 | * for ip's delayed extent of length "len". |
| @@ -3983,37 +3683,6 @@ xfs_bmap_worst_indlen( | |||
| 3983 | return rval; | 3683 | return rval; |
| 3984 | } | 3684 | } |
| 3985 | 3685 | ||
| 3986 | #if defined(XFS_RW_TRACE) | ||
| 3987 | STATIC void | ||
| 3988 | xfs_bunmap_trace( | ||
| 3989 | xfs_inode_t *ip, | ||
| 3990 | xfs_fileoff_t bno, | ||
| 3991 | xfs_filblks_t len, | ||
| 3992 | int flags, | ||
| 3993 | inst_t *ra) | ||
| 3994 | { | ||
| 3995 | if (ip->i_rwtrace == NULL) | ||
| 3996 | return; | ||
| 3997 | ktrace_enter(ip->i_rwtrace, | ||
| 3998 | (void *)(__psint_t)XFS_BUNMAP, | ||
| 3999 | (void *)ip, | ||
| 4000 | (void *)(__psint_t)((ip->i_d.di_size >> 32) & 0xffffffff), | ||
| 4001 | (void *)(__psint_t)(ip->i_d.di_size & 0xffffffff), | ||
| 4002 | (void *)(__psint_t)(((xfs_dfiloff_t)bno >> 32) & 0xffffffff), | ||
| 4003 | (void *)(__psint_t)((xfs_dfiloff_t)bno & 0xffffffff), | ||
| 4004 | (void *)(__psint_t)len, | ||
| 4005 | (void *)(__psint_t)flags, | ||
| 4006 | (void *)(unsigned long)current_cpu(), | ||
| 4007 | (void *)ra, | ||
| 4008 | (void *)0, | ||
| 4009 | (void *)0, | ||
| 4010 | (void *)0, | ||
| 4011 | (void *)0, | ||
| 4012 | (void *)0, | ||
| 4013 | (void *)0); | ||
| 4014 | } | ||
| 4015 | #endif | ||
| 4016 | |||
| 4017 | /* | 3686 | /* |
| 4018 | * Convert inode from non-attributed to attributed. | 3687 | * Convert inode from non-attributed to attributed. |
| 4019 | * Must not be in a transaction, ip must not be locked. | 3688 | * Must not be in a transaction, ip must not be locked. |
| @@ -4702,34 +4371,30 @@ error0: | |||
| 4702 | return XFS_ERROR(EFSCORRUPTED); | 4371 | return XFS_ERROR(EFSCORRUPTED); |
| 4703 | } | 4372 | } |
| 4704 | 4373 | ||
| 4705 | #ifdef XFS_BMAP_TRACE | 4374 | #ifdef DEBUG |
| 4706 | /* | 4375 | /* |
| 4707 | * Add bmap trace insert entries for all the contents of the extent records. | 4376 | * Add bmap trace insert entries for all the contents of the extent records. |
| 4708 | */ | 4377 | */ |
| 4709 | void | 4378 | void |
| 4710 | xfs_bmap_trace_exlist( | 4379 | xfs_bmap_trace_exlist( |
| 4711 | const char *fname, /* function name */ | ||
| 4712 | xfs_inode_t *ip, /* incore inode pointer */ | 4380 | xfs_inode_t *ip, /* incore inode pointer */ |
| 4713 | xfs_extnum_t cnt, /* count of entries in the list */ | 4381 | xfs_extnum_t cnt, /* count of entries in the list */ |
| 4714 | int whichfork) /* data or attr fork */ | 4382 | int whichfork, /* data or attr fork */ |
| 4383 | unsigned long caller_ip) | ||
| 4715 | { | 4384 | { |
| 4716 | xfs_bmbt_rec_host_t *ep; /* current extent record */ | ||
| 4717 | xfs_extnum_t idx; /* extent record index */ | 4385 | xfs_extnum_t idx; /* extent record index */ |
| 4718 | xfs_ifork_t *ifp; /* inode fork pointer */ | 4386 | xfs_ifork_t *ifp; /* inode fork pointer */ |
| 4719 | xfs_bmbt_irec_t s; /* file extent record */ | 4387 | int state = 0; |
| 4388 | |||
| 4389 | if (whichfork == XFS_ATTR_FORK) | ||
| 4390 | state |= BMAP_ATTRFORK; | ||
| 4720 | 4391 | ||
| 4721 | ifp = XFS_IFORK_PTR(ip, whichfork); | 4392 | ifp = XFS_IFORK_PTR(ip, whichfork); |
| 4722 | ASSERT(cnt == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))); | 4393 | ASSERT(cnt == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))); |
| 4723 | for (idx = 0; idx < cnt; idx++) { | 4394 | for (idx = 0; idx < cnt; idx++) |
| 4724 | ep = xfs_iext_get_ext(ifp, idx); | 4395 | trace_xfs_extlist(ip, idx, whichfork, caller_ip); |
| 4725 | xfs_bmbt_get_all(ep, &s); | ||
| 4726 | XFS_BMAP_TRACE_INSERT("exlist", ip, idx, 1, &s, NULL, | ||
| 4727 | whichfork); | ||
| 4728 | } | ||
| 4729 | } | 4396 | } |
| 4730 | #endif | ||
| 4731 | 4397 | ||
| 4732 | #ifdef DEBUG | ||
| 4733 | /* | 4398 | /* |
| 4734 | * Validate that the bmbt_irecs being returned from bmapi are valid | 4399 | * Validate that the bmbt_irecs being returned from bmapi are valid |
| 4735 | * given the callers original parameters. Specifically check the | 4400 | * given the callers original parameters. Specifically check the |
| @@ -5478,7 +5143,8 @@ xfs_bunmapi( | |||
| 5478 | int rsvd; /* OK to allocate reserved blocks */ | 5143 | int rsvd; /* OK to allocate reserved blocks */ |
| 5479 | xfs_fsblock_t sum; | 5144 | xfs_fsblock_t sum; |
| 5480 | 5145 | ||
| 5481 | xfs_bunmap_trace(ip, bno, len, flags, (inst_t *)__return_address); | 5146 | trace_xfs_bunmap(ip, bno, len, flags, _RET_IP_); |
| 5147 | |||
| 5482 | whichfork = (flags & XFS_BMAPI_ATTRFORK) ? | 5148 | whichfork = (flags & XFS_BMAPI_ATTRFORK) ? |
| 5483 | XFS_ATTR_FORK : XFS_DATA_FORK; | 5149 | XFS_ATTR_FORK : XFS_DATA_FORK; |
| 5484 | ifp = XFS_IFORK_PTR(ip, whichfork); | 5150 | ifp = XFS_IFORK_PTR(ip, whichfork); |
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h index 56f62d2edc35..419dafb9d87d 100644 --- a/fs/xfs/xfs_bmap.h +++ b/fs/xfs/xfs_bmap.h | |||
| @@ -95,6 +95,21 @@ typedef struct xfs_bmap_free | |||
| 95 | /* need write cache flushing and no */ | 95 | /* need write cache flushing and no */ |
| 96 | /* additional allocation alignments */ | 96 | /* additional allocation alignments */ |
| 97 | 97 | ||
| 98 | #define XFS_BMAPI_FLAGS \ | ||
| 99 | { XFS_BMAPI_WRITE, "WRITE" }, \ | ||
| 100 | { XFS_BMAPI_DELAY, "DELAY" }, \ | ||
| 101 | { XFS_BMAPI_ENTIRE, "ENTIRE" }, \ | ||
| 102 | { XFS_BMAPI_METADATA, "METADATA" }, \ | ||
| 103 | { XFS_BMAPI_EXACT, "EXACT" }, \ | ||
| 104 | { XFS_BMAPI_ATTRFORK, "ATTRFORK" }, \ | ||
| 105 | { XFS_BMAPI_ASYNC, "ASYNC" }, \ | ||
| 106 | { XFS_BMAPI_RSVBLOCKS, "RSVBLOCKS" }, \ | ||
| 107 | { XFS_BMAPI_PREALLOC, "PREALLOC" }, \ | ||
| 108 | { XFS_BMAPI_IGSTATE, "IGSTATE" }, \ | ||
| 109 | { XFS_BMAPI_CONTIG, "CONTIG" }, \ | ||
| 110 | { XFS_BMAPI_CONVERT, "CONVERT" } | ||
| 111 | |||
| 112 | |||
| 98 | static inline int xfs_bmapi_aflag(int w) | 113 | static inline int xfs_bmapi_aflag(int w) |
| 99 | { | 114 | { |
| 100 | return (w == XFS_ATTR_FORK ? XFS_BMAPI_ATTRFORK : 0); | 115 | return (w == XFS_ATTR_FORK ? XFS_BMAPI_ATTRFORK : 0); |
| @@ -135,36 +150,43 @@ typedef struct xfs_bmalloca { | |||
| 135 | char conv; /* overwriting unwritten extents */ | 150 | char conv; /* overwriting unwritten extents */ |
| 136 | } xfs_bmalloca_t; | 151 | } xfs_bmalloca_t; |
| 137 | 152 | ||
| 138 | #if defined(__KERNEL__) && defined(XFS_BMAP_TRACE) | ||
| 139 | /* | 153 | /* |
| 140 | * Trace operations for bmap extent tracing | 154 | * Flags for xfs_bmap_add_extent*. |
| 141 | */ | 155 | */ |
| 142 | #define XFS_BMAP_KTRACE_DELETE 1 | 156 | #define BMAP_LEFT_CONTIG (1 << 0) |
| 143 | #define XFS_BMAP_KTRACE_INSERT 2 | 157 | #define BMAP_RIGHT_CONTIG (1 << 1) |
| 144 | #define XFS_BMAP_KTRACE_PRE_UP 3 | 158 | #define BMAP_LEFT_FILLING (1 << 2) |
| 145 | #define XFS_BMAP_KTRACE_POST_UP 4 | 159 | #define BMAP_RIGHT_FILLING (1 << 3) |
| 146 | 160 | #define BMAP_LEFT_DELAY (1 << 4) | |
| 147 | #define XFS_BMAP_TRACE_SIZE 4096 /* size of global trace buffer */ | 161 | #define BMAP_RIGHT_DELAY (1 << 5) |
| 148 | #define XFS_BMAP_KTRACE_SIZE 32 /* size of per-inode trace buffer */ | 162 | #define BMAP_LEFT_VALID (1 << 6) |
| 149 | extern ktrace_t *xfs_bmap_trace_buf; | 163 | #define BMAP_RIGHT_VALID (1 << 7) |
| 164 | #define BMAP_ATTRFORK (1 << 8) | ||
| 165 | |||
| 166 | #define XFS_BMAP_EXT_FLAGS \ | ||
| 167 | { BMAP_LEFT_CONTIG, "LC" }, \ | ||
| 168 | { BMAP_RIGHT_CONTIG, "RC" }, \ | ||
| 169 | { BMAP_LEFT_FILLING, "LF" }, \ | ||
| 170 | { BMAP_RIGHT_FILLING, "RF" }, \ | ||
| 171 | { BMAP_ATTRFORK, "ATTR" } | ||
| 150 | 172 | ||
| 151 | /* | 173 | /* |
| 152 | * Add bmap trace insert entries for all the contents of the extent list. | 174 | * Add bmap trace insert entries for all the contents of the extent list. |
| 175 | * | ||
| 176 | * Quite excessive tracing. Only do this for debug builds. | ||
| 153 | */ | 177 | */ |
| 178 | #if defined(__KERNEL) && defined(DEBUG) | ||
| 154 | void | 179 | void |
| 155 | xfs_bmap_trace_exlist( | 180 | xfs_bmap_trace_exlist( |
| 156 | const char *fname, /* function name */ | ||
| 157 | struct xfs_inode *ip, /* incore inode pointer */ | 181 | struct xfs_inode *ip, /* incore inode pointer */ |
| 158 | xfs_extnum_t cnt, /* count of entries in list */ | 182 | xfs_extnum_t cnt, /* count of entries in list */ |
| 159 | int whichfork); /* data or attr fork */ | 183 | int whichfork, |
| 184 | unsigned long caller_ip); /* data or attr fork */ | ||
| 160 | #define XFS_BMAP_TRACE_EXLIST(ip,c,w) \ | 185 | #define XFS_BMAP_TRACE_EXLIST(ip,c,w) \ |
| 161 | xfs_bmap_trace_exlist(__func__,ip,c,w) | 186 | xfs_bmap_trace_exlist(ip,c,w, _THIS_IP_) |
| 162 | 187 | #else | |
| 163 | #else /* __KERNEL__ && XFS_BMAP_TRACE */ | ||
| 164 | |||
| 165 | #define XFS_BMAP_TRACE_EXLIST(ip,c,w) | 188 | #define XFS_BMAP_TRACE_EXLIST(ip,c,w) |
| 166 | 189 | #endif | |
| 167 | #endif /* __KERNEL__ && XFS_BMAP_TRACE */ | ||
| 168 | 190 | ||
| 169 | /* | 191 | /* |
| 170 | * Convert inode from non-attributed to attributed. | 192 | * Convert inode from non-attributed to attributed. |
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c index 6f5ccede63f9..38751d5fac6f 100644 --- a/fs/xfs/xfs_bmap_btree.c +++ b/fs/xfs/xfs_bmap_btree.c | |||
| @@ -768,12 +768,6 @@ xfs_bmbt_trace_enter( | |||
| 768 | (void *)a0, (void *)a1, (void *)a2, (void *)a3, | 768 | (void *)a0, (void *)a1, (void *)a2, (void *)a3, |
| 769 | (void *)a4, (void *)a5, (void *)a6, (void *)a7, | 769 | (void *)a4, (void *)a5, (void *)a6, (void *)a7, |
| 770 | (void *)a8, (void *)a9, (void *)a10); | 770 | (void *)a8, (void *)a9, (void *)a10); |
| 771 | ktrace_enter(ip->i_btrace, | ||
| 772 | (void *)((__psint_t)type | (whichfork << 8) | (line << 16)), | ||
| 773 | (void *)func, (void *)s, (void *)ip, (void *)cur, | ||
| 774 | (void *)a0, (void *)a1, (void *)a2, (void *)a3, | ||
| 775 | (void *)a4, (void *)a5, (void *)a6, (void *)a7, | ||
| 776 | (void *)a8, (void *)a9, (void *)a10); | ||
| 777 | } | 771 | } |
| 778 | 772 | ||
| 779 | STATIC void | 773 | STATIC void |
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h index 5549d495947f..cf07ca7c22e7 100644 --- a/fs/xfs/xfs_bmap_btree.h +++ b/fs/xfs/xfs_bmap_btree.h | |||
| @@ -46,20 +46,12 @@ typedef struct xfs_bmdr_block { | |||
| 46 | #define BMBT_STARTBLOCK_BITLEN 52 | 46 | #define BMBT_STARTBLOCK_BITLEN 52 |
| 47 | #define BMBT_BLOCKCOUNT_BITLEN 21 | 47 | #define BMBT_BLOCKCOUNT_BITLEN 21 |
| 48 | 48 | ||
| 49 | 49 | typedef struct xfs_bmbt_rec { | |
| 50 | #define BMBT_USE_64 1 | ||
| 51 | |||
| 52 | typedef struct xfs_bmbt_rec_32 | ||
| 53 | { | ||
| 54 | __uint32_t l0, l1, l2, l3; | ||
| 55 | } xfs_bmbt_rec_32_t; | ||
| 56 | typedef struct xfs_bmbt_rec_64 | ||
| 57 | { | ||
| 58 | __be64 l0, l1; | 50 | __be64 l0, l1; |
| 59 | } xfs_bmbt_rec_64_t; | 51 | } xfs_bmbt_rec_t; |
| 60 | 52 | ||
| 61 | typedef __uint64_t xfs_bmbt_rec_base_t; /* use this for casts */ | 53 | typedef __uint64_t xfs_bmbt_rec_base_t; /* use this for casts */ |
| 62 | typedef xfs_bmbt_rec_64_t xfs_bmbt_rec_t, xfs_bmdr_rec_t; | 54 | typedef xfs_bmbt_rec_t xfs_bmdr_rec_t; |
| 63 | 55 | ||
| 64 | typedef struct xfs_bmbt_rec_host { | 56 | typedef struct xfs_bmbt_rec_host { |
| 65 | __uint64_t l0, l1; | 57 | __uint64_t l0, l1; |
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c index 52b5f14d0c32..36a0992dd669 100644 --- a/fs/xfs/xfs_btree.c +++ b/fs/xfs/xfs_btree.c | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | #include "xfs_btree_trace.h" | 39 | #include "xfs_btree_trace.h" |
| 40 | #include "xfs_ialloc.h" | 40 | #include "xfs_ialloc.h" |
| 41 | #include "xfs_error.h" | 41 | #include "xfs_error.h" |
| 42 | #include "xfs_trace.h" | ||
| 42 | 43 | ||
| 43 | /* | 44 | /* |
| 44 | * Cursor allocation zone. | 45 | * Cursor allocation zone. |
| @@ -81,7 +82,7 @@ xfs_btree_check_lblock( | |||
| 81 | XFS_ERRTAG_BTREE_CHECK_LBLOCK, | 82 | XFS_ERRTAG_BTREE_CHECK_LBLOCK, |
| 82 | XFS_RANDOM_BTREE_CHECK_LBLOCK))) { | 83 | XFS_RANDOM_BTREE_CHECK_LBLOCK))) { |
| 83 | if (bp) | 84 | if (bp) |
| 84 | xfs_buftrace("LBTREE ERROR", bp); | 85 | trace_xfs_btree_corrupt(bp, _RET_IP_); |
| 85 | XFS_ERROR_REPORT("xfs_btree_check_lblock", XFS_ERRLEVEL_LOW, | 86 | XFS_ERROR_REPORT("xfs_btree_check_lblock", XFS_ERRLEVEL_LOW, |
| 86 | mp); | 87 | mp); |
| 87 | return XFS_ERROR(EFSCORRUPTED); | 88 | return XFS_ERROR(EFSCORRUPTED); |
| @@ -119,7 +120,7 @@ xfs_btree_check_sblock( | |||
| 119 | XFS_ERRTAG_BTREE_CHECK_SBLOCK, | 120 | XFS_ERRTAG_BTREE_CHECK_SBLOCK, |
| 120 | XFS_RANDOM_BTREE_CHECK_SBLOCK))) { | 121 | XFS_RANDOM_BTREE_CHECK_SBLOCK))) { |
| 121 | if (bp) | 122 | if (bp) |
| 122 | xfs_buftrace("SBTREE ERROR", bp); | 123 | trace_xfs_btree_corrupt(bp, _RET_IP_); |
| 123 | XFS_CORRUPTION_ERROR("xfs_btree_check_sblock", | 124 | XFS_CORRUPTION_ERROR("xfs_btree_check_sblock", |
| 124 | XFS_ERRLEVEL_LOW, cur->bc_mp, block); | 125 | XFS_ERRLEVEL_LOW, cur->bc_mp, block); |
| 125 | return XFS_ERROR(EFSCORRUPTED); | 126 | return XFS_ERROR(EFSCORRUPTED); |
diff --git a/fs/xfs/xfs_btree_trace.h b/fs/xfs/xfs_btree_trace.h index b3f5eb3c3c6c..2d8a309873ea 100644 --- a/fs/xfs/xfs_btree_trace.h +++ b/fs/xfs/xfs_btree_trace.h | |||
| @@ -58,8 +58,6 @@ void xfs_btree_trace_argbi(const char *, struct xfs_btree_cur *, | |||
| 58 | struct xfs_buf *, int, int); | 58 | struct xfs_buf *, int, int); |
| 59 | void xfs_btree_trace_argbii(const char *, struct xfs_btree_cur *, | 59 | void xfs_btree_trace_argbii(const char *, struct xfs_btree_cur *, |
| 60 | struct xfs_buf *, int, int, int); | 60 | struct xfs_buf *, int, int, int); |
| 61 | void xfs_btree_trace_argfffi(const char *, struct xfs_btree_cur *, | ||
| 62 | xfs_dfiloff_t, xfs_dfsbno_t, xfs_dfilblks_t, int, int); | ||
| 63 | void xfs_btree_trace_argi(const char *, struct xfs_btree_cur *, int, int); | 61 | void xfs_btree_trace_argi(const char *, struct xfs_btree_cur *, int, int); |
| 64 | void xfs_btree_trace_argipk(const char *, struct xfs_btree_cur *, int, | 62 | void xfs_btree_trace_argipk(const char *, struct xfs_btree_cur *, int, |
| 65 | union xfs_btree_ptr, union xfs_btree_key *, int); | 63 | union xfs_btree_ptr, union xfs_btree_key *, int); |
| @@ -71,24 +69,10 @@ void xfs_btree_trace_argr(const char *, struct xfs_btree_cur *, | |||
| 71 | union xfs_btree_rec *, int); | 69 | union xfs_btree_rec *, int); |
| 72 | void xfs_btree_trace_cursor(const char *, struct xfs_btree_cur *, int, int); | 70 | void xfs_btree_trace_cursor(const char *, struct xfs_btree_cur *, int, int); |
| 73 | 71 | ||
| 74 | |||
| 75 | #define XFS_ALLOCBT_TRACE_SIZE 4096 /* size of global trace buffer */ | ||
| 76 | extern ktrace_t *xfs_allocbt_trace_buf; | ||
| 77 | |||
| 78 | #define XFS_INOBT_TRACE_SIZE 4096 /* size of global trace buffer */ | ||
| 79 | extern ktrace_t *xfs_inobt_trace_buf; | ||
| 80 | |||
| 81 | #define XFS_BMBT_TRACE_SIZE 4096 /* size of global trace buffer */ | ||
| 82 | #define XFS_BMBT_KTRACE_SIZE 32 /* size of per-inode trace buffer */ | ||
| 83 | extern ktrace_t *xfs_bmbt_trace_buf; | ||
| 84 | |||
| 85 | |||
| 86 | #define XFS_BTREE_TRACE_ARGBI(c, b, i) \ | 72 | #define XFS_BTREE_TRACE_ARGBI(c, b, i) \ |
| 87 | xfs_btree_trace_argbi(__func__, c, b, i, __LINE__) | 73 | xfs_btree_trace_argbi(__func__, c, b, i, __LINE__) |
| 88 | #define XFS_BTREE_TRACE_ARGBII(c, b, i, j) \ | 74 | #define XFS_BTREE_TRACE_ARGBII(c, b, i, j) \ |
| 89 | xfs_btree_trace_argbii(__func__, c, b, i, j, __LINE__) | 75 | xfs_btree_trace_argbii(__func__, c, b, i, j, __LINE__) |
| 90 | #define XFS_BTREE_TRACE_ARGFFFI(c, o, b, i, j) \ | ||
| 91 | xfs_btree_trace_argfffi(__func__, c, o, b, i, j, __LINE__) | ||
| 92 | #define XFS_BTREE_TRACE_ARGI(c, i) \ | 76 | #define XFS_BTREE_TRACE_ARGI(c, i) \ |
| 93 | xfs_btree_trace_argi(__func__, c, i, __LINE__) | 77 | xfs_btree_trace_argi(__func__, c, i, __LINE__) |
| 94 | #define XFS_BTREE_TRACE_ARGIPK(c, i, p, k) \ | 78 | #define XFS_BTREE_TRACE_ARGIPK(c, i, p, k) \ |
| @@ -104,7 +88,6 @@ extern ktrace_t *xfs_bmbt_trace_buf; | |||
| 104 | #else | 88 | #else |
| 105 | #define XFS_BTREE_TRACE_ARGBI(c, b, i) | 89 | #define XFS_BTREE_TRACE_ARGBI(c, b, i) |
| 106 | #define XFS_BTREE_TRACE_ARGBII(c, b, i, j) | 90 | #define XFS_BTREE_TRACE_ARGBII(c, b, i, j) |
| 107 | #define XFS_BTREE_TRACE_ARGFFFI(c, o, b, i, j) | ||
| 108 | #define XFS_BTREE_TRACE_ARGI(c, i) | 91 | #define XFS_BTREE_TRACE_ARGI(c, i) |
| 109 | #define XFS_BTREE_TRACE_ARGIPK(c, i, p, s) | 92 | #define XFS_BTREE_TRACE_ARGIPK(c, i, p, s) |
| 110 | #define XFS_BTREE_TRACE_ARGIPR(c, i, p, r) | 93 | #define XFS_BTREE_TRACE_ARGIPR(c, i, p, r) |
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index 92af4098c7e8..a30f7e9eb2b9 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #include "xfs_buf_item.h" | 29 | #include "xfs_buf_item.h" |
| 30 | #include "xfs_trans_priv.h" | 30 | #include "xfs_trans_priv.h" |
| 31 | #include "xfs_error.h" | 31 | #include "xfs_error.h" |
| 32 | #include "xfs_trace.h" | ||
| 32 | 33 | ||
| 33 | 34 | ||
| 34 | kmem_zone_t *xfs_buf_item_zone; | 35 | kmem_zone_t *xfs_buf_item_zone; |
| @@ -164,7 +165,7 @@ xfs_buf_item_size( | |||
| 164 | * is the buf log format structure with the | 165 | * is the buf log format structure with the |
| 165 | * cancel flag in it. | 166 | * cancel flag in it. |
| 166 | */ | 167 | */ |
| 167 | xfs_buf_item_trace("SIZE STALE", bip); | 168 | trace_xfs_buf_item_size_stale(bip); |
| 168 | ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL); | 169 | ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL); |
| 169 | return 1; | 170 | return 1; |
| 170 | } | 171 | } |
| @@ -206,7 +207,7 @@ xfs_buf_item_size( | |||
| 206 | } | 207 | } |
| 207 | } | 208 | } |
| 208 | 209 | ||
| 209 | xfs_buf_item_trace("SIZE NORM", bip); | 210 | trace_xfs_buf_item_size(bip); |
| 210 | return nvecs; | 211 | return nvecs; |
| 211 | } | 212 | } |
| 212 | 213 | ||
| @@ -259,7 +260,7 @@ xfs_buf_item_format( | |||
| 259 | * is the buf log format structure with the | 260 | * is the buf log format structure with the |
| 260 | * cancel flag in it. | 261 | * cancel flag in it. |
| 261 | */ | 262 | */ |
| 262 | xfs_buf_item_trace("FORMAT STALE", bip); | 263 | trace_xfs_buf_item_format_stale(bip); |
| 263 | ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL); | 264 | ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL); |
| 264 | bip->bli_format.blf_size = nvecs; | 265 | bip->bli_format.blf_size = nvecs; |
| 265 | return; | 266 | return; |
| @@ -335,7 +336,7 @@ xfs_buf_item_format( | |||
| 335 | /* | 336 | /* |
| 336 | * Check to make sure everything is consistent. | 337 | * Check to make sure everything is consistent. |
| 337 | */ | 338 | */ |
| 338 | xfs_buf_item_trace("FORMAT NORM", bip); | 339 | trace_xfs_buf_item_format(bip); |
| 339 | xfs_buf_item_log_check(bip); | 340 | xfs_buf_item_log_check(bip); |
| 340 | } | 341 | } |
| 341 | 342 | ||
| @@ -355,8 +356,7 @@ xfs_buf_item_pin( | |||
| 355 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 356 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
| 356 | ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || | 357 | ASSERT((bip->bli_flags & XFS_BLI_LOGGED) || |
| 357 | (bip->bli_flags & XFS_BLI_STALE)); | 358 | (bip->bli_flags & XFS_BLI_STALE)); |
| 358 | xfs_buf_item_trace("PIN", bip); | 359 | trace_xfs_buf_item_pin(bip); |
| 359 | xfs_buftrace("XFS_PIN", bp); | ||
| 360 | xfs_bpin(bp); | 360 | xfs_bpin(bp); |
| 361 | } | 361 | } |
| 362 | 362 | ||
| @@ -383,8 +383,7 @@ xfs_buf_item_unpin( | |||
| 383 | ASSERT(bp != NULL); | 383 | ASSERT(bp != NULL); |
| 384 | ASSERT(XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *) == bip); | 384 | ASSERT(XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *) == bip); |
| 385 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 385 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
| 386 | xfs_buf_item_trace("UNPIN", bip); | 386 | trace_xfs_buf_item_unpin(bip); |
| 387 | xfs_buftrace("XFS_UNPIN", bp); | ||
| 388 | 387 | ||
| 389 | freed = atomic_dec_and_test(&bip->bli_refcount); | 388 | freed = atomic_dec_and_test(&bip->bli_refcount); |
| 390 | ailp = bip->bli_item.li_ailp; | 389 | ailp = bip->bli_item.li_ailp; |
| @@ -395,8 +394,8 @@ xfs_buf_item_unpin( | |||
| 395 | ASSERT(!(XFS_BUF_ISDELAYWRITE(bp))); | 394 | ASSERT(!(XFS_BUF_ISDELAYWRITE(bp))); |
| 396 | ASSERT(XFS_BUF_ISSTALE(bp)); | 395 | ASSERT(XFS_BUF_ISSTALE(bp)); |
| 397 | ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL); | 396 | ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL); |
| 398 | xfs_buf_item_trace("UNPIN STALE", bip); | 397 | trace_xfs_buf_item_unpin_stale(bip); |
| 399 | xfs_buftrace("XFS_UNPIN STALE", bp); | 398 | |
| 400 | /* | 399 | /* |
| 401 | * If we get called here because of an IO error, we may | 400 | * If we get called here because of an IO error, we may |
| 402 | * or may not have the item on the AIL. xfs_trans_ail_delete() | 401 | * or may not have the item on the AIL. xfs_trans_ail_delete() |
| @@ -440,8 +439,8 @@ xfs_buf_item_unpin_remove( | |||
| 440 | if ((atomic_read(&bip->bli_refcount) == 1) && | 439 | if ((atomic_read(&bip->bli_refcount) == 1) && |
| 441 | (bip->bli_flags & XFS_BLI_STALE)) { | 440 | (bip->bli_flags & XFS_BLI_STALE)) { |
| 442 | ASSERT(XFS_BUF_VALUSEMA(bip->bli_buf) <= 0); | 441 | ASSERT(XFS_BUF_VALUSEMA(bip->bli_buf) <= 0); |
| 443 | xfs_buf_item_trace("UNPIN REMOVE", bip); | 442 | trace_xfs_buf_item_unpin_stale(bip); |
| 444 | xfs_buftrace("XFS_UNPIN_REMOVE", bp); | 443 | |
| 445 | /* | 444 | /* |
| 446 | * yes -- clear the xaction descriptor in-use flag | 445 | * yes -- clear the xaction descriptor in-use flag |
| 447 | * and free the chunk if required. We can safely | 446 | * and free the chunk if required. We can safely |
| @@ -495,7 +494,7 @@ xfs_buf_item_trylock( | |||
| 495 | XFS_BUF_HOLD(bp); | 494 | XFS_BUF_HOLD(bp); |
| 496 | 495 | ||
| 497 | ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); | 496 | ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); |
| 498 | xfs_buf_item_trace("TRYLOCK SUCCESS", bip); | 497 | trace_xfs_buf_item_trylock(bip); |
| 499 | return XFS_ITEM_SUCCESS; | 498 | return XFS_ITEM_SUCCESS; |
| 500 | } | 499 | } |
| 501 | 500 | ||
| @@ -524,7 +523,6 @@ xfs_buf_item_unlock( | |||
| 524 | uint hold; | 523 | uint hold; |
| 525 | 524 | ||
| 526 | bp = bip->bli_buf; | 525 | bp = bip->bli_buf; |
| 527 | xfs_buftrace("XFS_UNLOCK", bp); | ||
| 528 | 526 | ||
| 529 | /* | 527 | /* |
| 530 | * Clear the buffer's association with this transaction. | 528 | * Clear the buffer's association with this transaction. |
| @@ -547,7 +545,7 @@ xfs_buf_item_unlock( | |||
| 547 | */ | 545 | */ |
| 548 | if (bip->bli_flags & XFS_BLI_STALE) { | 546 | if (bip->bli_flags & XFS_BLI_STALE) { |
| 549 | bip->bli_flags &= ~XFS_BLI_LOGGED; | 547 | bip->bli_flags &= ~XFS_BLI_LOGGED; |
| 550 | xfs_buf_item_trace("UNLOCK STALE", bip); | 548 | trace_xfs_buf_item_unlock_stale(bip); |
| 551 | ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL); | 549 | ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL); |
| 552 | if (!aborted) | 550 | if (!aborted) |
| 553 | return; | 551 | return; |
| @@ -574,7 +572,7 @@ xfs_buf_item_unlock( | |||
| 574 | * release the buffer at the end of this routine. | 572 | * release the buffer at the end of this routine. |
| 575 | */ | 573 | */ |
| 576 | hold = bip->bli_flags & XFS_BLI_HOLD; | 574 | hold = bip->bli_flags & XFS_BLI_HOLD; |
| 577 | xfs_buf_item_trace("UNLOCK", bip); | 575 | trace_xfs_buf_item_unlock(bip); |
| 578 | 576 | ||
| 579 | /* | 577 | /* |
| 580 | * If the buf item isn't tracking any data, free it. | 578 | * If the buf item isn't tracking any data, free it. |
| @@ -618,7 +616,8 @@ xfs_buf_item_committed( | |||
| 618 | xfs_buf_log_item_t *bip, | 616 | xfs_buf_log_item_t *bip, |
| 619 | xfs_lsn_t lsn) | 617 | xfs_lsn_t lsn) |
| 620 | { | 618 | { |
| 621 | xfs_buf_item_trace("COMMITTED", bip); | 619 | trace_xfs_buf_item_committed(bip); |
| 620 | |||
| 622 | if ((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) && | 621 | if ((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) && |
| 623 | (bip->bli_item.li_lsn != 0)) { | 622 | (bip->bli_item.li_lsn != 0)) { |
| 624 | return bip->bli_item.li_lsn; | 623 | return bip->bli_item.li_lsn; |
| @@ -640,7 +639,7 @@ xfs_buf_item_push( | |||
| 640 | xfs_buf_t *bp; | 639 | xfs_buf_t *bp; |
| 641 | 640 | ||
| 642 | ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); | 641 | ASSERT(!(bip->bli_flags & XFS_BLI_STALE)); |
| 643 | xfs_buf_item_trace("PUSH", bip); | 642 | trace_xfs_buf_item_push(bip); |
| 644 | 643 | ||
| 645 | bp = bip->bli_buf; | 644 | bp = bip->bli_buf; |
| 646 | 645 | ||
| @@ -738,9 +737,6 @@ xfs_buf_item_init( | |||
| 738 | bip->bli_format.blf_blkno = (__int64_t)XFS_BUF_ADDR(bp); | 737 | bip->bli_format.blf_blkno = (__int64_t)XFS_BUF_ADDR(bp); |
| 739 | bip->bli_format.blf_len = (ushort)BTOBB(XFS_BUF_COUNT(bp)); | 738 | bip->bli_format.blf_len = (ushort)BTOBB(XFS_BUF_COUNT(bp)); |
| 740 | bip->bli_format.blf_map_size = map_size; | 739 | bip->bli_format.blf_map_size = map_size; |
| 741 | #ifdef XFS_BLI_TRACE | ||
| 742 | bip->bli_trace = ktrace_alloc(XFS_BLI_TRACE_SIZE, KM_NOFS); | ||
| 743 | #endif | ||
| 744 | 740 | ||
| 745 | #ifdef XFS_TRANS_DEBUG | 741 | #ifdef XFS_TRANS_DEBUG |
| 746 | /* | 742 | /* |
| @@ -878,9 +874,6 @@ xfs_buf_item_free( | |||
| 878 | kmem_free(bip->bli_logged); | 874 | kmem_free(bip->bli_logged); |
| 879 | #endif /* XFS_TRANS_DEBUG */ | 875 | #endif /* XFS_TRANS_DEBUG */ |
| 880 | 876 | ||
| 881 | #ifdef XFS_BLI_TRACE | ||
| 882 | ktrace_free(bip->bli_trace); | ||
| 883 | #endif | ||
| 884 | kmem_zone_free(xfs_buf_item_zone, bip); | 877 | kmem_zone_free(xfs_buf_item_zone, bip); |
| 885 | } | 878 | } |
| 886 | 879 | ||
| @@ -897,7 +890,8 @@ xfs_buf_item_relse( | |||
| 897 | { | 890 | { |
| 898 | xfs_buf_log_item_t *bip; | 891 | xfs_buf_log_item_t *bip; |
| 899 | 892 | ||
| 900 | xfs_buftrace("XFS_RELSE", bp); | 893 | trace_xfs_buf_item_relse(bp, _RET_IP_); |
| 894 | |||
| 901 | bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t*); | 895 | bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t*); |
| 902 | XFS_BUF_SET_FSPRIVATE(bp, bip->bli_item.li_bio_list); | 896 | XFS_BUF_SET_FSPRIVATE(bp, bip->bli_item.li_bio_list); |
| 903 | if ((XFS_BUF_FSPRIVATE(bp, void *) == NULL) && | 897 | if ((XFS_BUF_FSPRIVATE(bp, void *) == NULL) && |
| @@ -994,7 +988,7 @@ xfs_buf_iodone_callbacks( | |||
| 994 | if (XFS_FORCED_SHUTDOWN(mp)) { | 988 | if (XFS_FORCED_SHUTDOWN(mp)) { |
| 995 | ASSERT(XFS_BUF_TARGET(bp) == mp->m_ddev_targp); | 989 | ASSERT(XFS_BUF_TARGET(bp) == mp->m_ddev_targp); |
| 996 | XFS_BUF_SUPER_STALE(bp); | 990 | XFS_BUF_SUPER_STALE(bp); |
| 997 | xfs_buftrace("BUF_IODONE_CB", bp); | 991 | trace_xfs_buf_item_iodone(bp, _RET_IP_); |
| 998 | xfs_buf_do_callbacks(bp, lip); | 992 | xfs_buf_do_callbacks(bp, lip); |
| 999 | XFS_BUF_SET_FSPRIVATE(bp, NULL); | 993 | XFS_BUF_SET_FSPRIVATE(bp, NULL); |
| 1000 | XFS_BUF_CLR_IODONE_FUNC(bp); | 994 | XFS_BUF_CLR_IODONE_FUNC(bp); |
| @@ -1030,7 +1024,7 @@ xfs_buf_iodone_callbacks( | |||
| 1030 | XFS_BUF_SET_START(bp); | 1024 | XFS_BUF_SET_START(bp); |
| 1031 | } | 1025 | } |
| 1032 | ASSERT(XFS_BUF_IODONE_FUNC(bp)); | 1026 | ASSERT(XFS_BUF_IODONE_FUNC(bp)); |
| 1033 | xfs_buftrace("BUF_IODONE ASYNC", bp); | 1027 | trace_xfs_buf_item_iodone_async(bp, _RET_IP_); |
| 1034 | xfs_buf_relse(bp); | 1028 | xfs_buf_relse(bp); |
| 1035 | } else { | 1029 | } else { |
| 1036 | /* | 1030 | /* |
| @@ -1053,9 +1047,7 @@ xfs_buf_iodone_callbacks( | |||
| 1053 | } | 1047 | } |
| 1054 | return; | 1048 | return; |
| 1055 | } | 1049 | } |
| 1056 | #ifdef XFSERRORDEBUG | 1050 | |
| 1057 | xfs_buftrace("XFS BUFCB NOERR", bp); | ||
| 1058 | #endif | ||
| 1059 | xfs_buf_do_callbacks(bp, lip); | 1051 | xfs_buf_do_callbacks(bp, lip); |
| 1060 | XFS_BUF_SET_FSPRIVATE(bp, NULL); | 1052 | XFS_BUF_SET_FSPRIVATE(bp, NULL); |
| 1061 | XFS_BUF_CLR_IODONE_FUNC(bp); | 1053 | XFS_BUF_CLR_IODONE_FUNC(bp); |
| @@ -1081,7 +1073,9 @@ xfs_buf_error_relse( | |||
| 1081 | XFS_BUF_DONE(bp); | 1073 | XFS_BUF_DONE(bp); |
| 1082 | XFS_BUF_UNDELAYWRITE(bp); | 1074 | XFS_BUF_UNDELAYWRITE(bp); |
| 1083 | XFS_BUF_ERROR(bp,0); | 1075 | XFS_BUF_ERROR(bp,0); |
| 1084 | xfs_buftrace("BUF_ERROR_RELSE", bp); | 1076 | |
| 1077 | trace_xfs_buf_error_relse(bp, _RET_IP_); | ||
| 1078 | |||
| 1085 | if (! XFS_FORCED_SHUTDOWN(mp)) | 1079 | if (! XFS_FORCED_SHUTDOWN(mp)) |
| 1086 | xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR); | 1080 | xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR); |
| 1087 | /* | 1081 | /* |
| @@ -1128,34 +1122,3 @@ xfs_buf_iodone( | |||
| 1128 | xfs_trans_ail_delete(ailp, (xfs_log_item_t *)bip); | 1122 | xfs_trans_ail_delete(ailp, (xfs_log_item_t *)bip); |
| 1129 | xfs_buf_item_free(bip); | 1123 | xfs_buf_item_free(bip); |
| 1130 | } | 1124 | } |
| 1131 | |||
| 1132 | #if defined(XFS_BLI_TRACE) | ||
| 1133 | void | ||
| 1134 | xfs_buf_item_trace( | ||
| 1135 | char *id, | ||
| 1136 | xfs_buf_log_item_t *bip) | ||
| 1137 | { | ||
| 1138 | xfs_buf_t *bp; | ||
| 1139 | ASSERT(bip->bli_trace != NULL); | ||
| 1140 | |||
| 1141 | bp = bip->bli_buf; | ||
| 1142 | ktrace_enter(bip->bli_trace, | ||
| 1143 | (void *)id, | ||
| 1144 | (void *)bip->bli_buf, | ||
| 1145 | (void *)((unsigned long)bip->bli_flags), | ||
| 1146 | (void *)((unsigned long)bip->bli_recur), | ||
| 1147 | (void *)((unsigned long)atomic_read(&bip->bli_refcount)), | ||
| 1148 | (void *)((unsigned long) | ||
| 1149 | (0xFFFFFFFF & XFS_BUF_ADDR(bp) >> 32)), | ||
| 1150 | (void *)((unsigned long)(0xFFFFFFFF & XFS_BUF_ADDR(bp))), | ||
| 1151 | (void *)((unsigned long)XFS_BUF_COUNT(bp)), | ||
| 1152 | (void *)((unsigned long)XFS_BUF_BFLAGS(bp)), | ||
| 1153 | XFS_BUF_FSPRIVATE(bp, void *), | ||
| 1154 | XFS_BUF_FSPRIVATE2(bp, void *), | ||
| 1155 | (void *)(unsigned long)XFS_BUF_ISPINNED(bp), | ||
| 1156 | (void *)XFS_BUF_IODONE_FUNC(bp), | ||
| 1157 | (void *)((unsigned long)(XFS_BUF_VALUSEMA(bp))), | ||
| 1158 | (void *)bip->bli_item.li_desc, | ||
| 1159 | (void *)((unsigned long)bip->bli_item.li_flags)); | ||
| 1160 | } | ||
| 1161 | #endif /* XFS_BLI_TRACE */ | ||
diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h index 5a41c348bb1c..217f34af00cb 100644 --- a/fs/xfs/xfs_buf_item.h +++ b/fs/xfs/xfs_buf_item.h | |||
| @@ -70,22 +70,21 @@ typedef struct xfs_buf_log_format_t { | |||
| 70 | #define XFS_BLI_INODE_ALLOC_BUF 0x10 | 70 | #define XFS_BLI_INODE_ALLOC_BUF 0x10 |
| 71 | #define XFS_BLI_STALE_INODE 0x20 | 71 | #define XFS_BLI_STALE_INODE 0x20 |
| 72 | 72 | ||
| 73 | #define XFS_BLI_FLAGS \ | ||
| 74 | { XFS_BLI_HOLD, "HOLD" }, \ | ||
| 75 | { XFS_BLI_DIRTY, "DIRTY" }, \ | ||
| 76 | { XFS_BLI_STALE, "STALE" }, \ | ||
| 77 | { XFS_BLI_LOGGED, "LOGGED" }, \ | ||
| 78 | { XFS_BLI_INODE_ALLOC_BUF, "INODE_ALLOC" }, \ | ||
| 79 | { XFS_BLI_STALE_INODE, "STALE_INODE" } | ||
| 80 | |||
| 73 | 81 | ||
| 74 | #ifdef __KERNEL__ | 82 | #ifdef __KERNEL__ |
| 75 | 83 | ||
| 76 | struct xfs_buf; | 84 | struct xfs_buf; |
| 77 | struct ktrace; | ||
| 78 | struct xfs_mount; | 85 | struct xfs_mount; |
| 79 | struct xfs_buf_log_item; | 86 | struct xfs_buf_log_item; |
| 80 | 87 | ||
| 81 | #if defined(XFS_BLI_TRACE) | ||
| 82 | #define XFS_BLI_TRACE_SIZE 32 | ||
| 83 | |||
| 84 | void xfs_buf_item_trace(char *, struct xfs_buf_log_item *); | ||
| 85 | #else | ||
| 86 | #define xfs_buf_item_trace(id, bip) | ||
| 87 | #endif | ||
| 88 | |||
| 89 | /* | 88 | /* |
| 90 | * This is the in core log item structure used to track information | 89 | * This is the in core log item structure used to track information |
| 91 | * needed to log buffers. It tracks how many times the lock has been | 90 | * needed to log buffers. It tracks how many times the lock has been |
| @@ -97,9 +96,6 @@ typedef struct xfs_buf_log_item { | |||
| 97 | unsigned int bli_flags; /* misc flags */ | 96 | unsigned int bli_flags; /* misc flags */ |
| 98 | unsigned int bli_recur; /* lock recursion count */ | 97 | unsigned int bli_recur; /* lock recursion count */ |
| 99 | atomic_t bli_refcount; /* cnt of tp refs */ | 98 | atomic_t bli_refcount; /* cnt of tp refs */ |
| 100 | #ifdef XFS_BLI_TRACE | ||
| 101 | struct ktrace *bli_trace; /* event trace buf */ | ||
| 102 | #endif | ||
| 103 | #ifdef XFS_TRANS_DEBUG | 99 | #ifdef XFS_TRANS_DEBUG |
| 104 | char *bli_orig; /* original buffer copy */ | 100 | char *bli_orig; /* original buffer copy */ |
| 105 | char *bli_logged; /* bytes logged (bitmap) */ | 101 | char *bli_logged; /* bytes logged (bitmap) */ |
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index 2847bbc1c534..c0c8869115b1 100644 --- a/fs/xfs/xfs_da_btree.c +++ b/fs/xfs/xfs_da_btree.c | |||
| @@ -46,6 +46,7 @@ | |||
| 46 | #include "xfs_dir2_block.h" | 46 | #include "xfs_dir2_block.h" |
| 47 | #include "xfs_dir2_node.h" | 47 | #include "xfs_dir2_node.h" |
| 48 | #include "xfs_error.h" | 48 | #include "xfs_error.h" |
| 49 | #include "xfs_trace.h" | ||
| 49 | 50 | ||
| 50 | /* | 51 | /* |
| 51 | * xfs_da_btree.c | 52 | * xfs_da_btree.c |
| @@ -2107,7 +2108,7 @@ xfs_da_do_buf( | |||
| 2107 | (be32_to_cpu(free->hdr.magic) != XFS_DIR2_FREE_MAGIC), | 2108 | (be32_to_cpu(free->hdr.magic) != XFS_DIR2_FREE_MAGIC), |
| 2108 | mp, XFS_ERRTAG_DA_READ_BUF, | 2109 | mp, XFS_ERRTAG_DA_READ_BUF, |
| 2109 | XFS_RANDOM_DA_READ_BUF))) { | 2110 | XFS_RANDOM_DA_READ_BUF))) { |
| 2110 | xfs_buftrace("DA READ ERROR", rbp->bps[0]); | 2111 | trace_xfs_da_btree_corrupt(rbp->bps[0], _RET_IP_); |
| 2111 | XFS_CORRUPTION_ERROR("xfs_da_do_buf(2)", | 2112 | XFS_CORRUPTION_ERROR("xfs_da_do_buf(2)", |
| 2112 | XFS_ERRLEVEL_LOW, mp, info); | 2113 | XFS_ERRLEVEL_LOW, mp, info); |
| 2113 | error = XFS_ERROR(EFSCORRUPTED); | 2114 | error = XFS_ERROR(EFSCORRUPTED); |
diff --git a/fs/xfs/xfs_da_btree.h b/fs/xfs/xfs_da_btree.h index 8c536167bf75..30cd08f56a3a 100644 --- a/fs/xfs/xfs_da_btree.h +++ b/fs/xfs/xfs_da_btree.h | |||
| @@ -125,6 +125,13 @@ typedef struct xfs_da_args { | |||
| 125 | #define XFS_DA_OP_OKNOENT 0x0008 /* lookup/add op, ENOENT ok, else die */ | 125 | #define XFS_DA_OP_OKNOENT 0x0008 /* lookup/add op, ENOENT ok, else die */ |
| 126 | #define XFS_DA_OP_CILOOKUP 0x0010 /* lookup to return CI name if found */ | 126 | #define XFS_DA_OP_CILOOKUP 0x0010 /* lookup to return CI name if found */ |
| 127 | 127 | ||
| 128 | #define XFS_DA_OP_FLAGS \ | ||
| 129 | { XFS_DA_OP_JUSTCHECK, "JUSTCHECK" }, \ | ||
| 130 | { XFS_DA_OP_RENAME, "RENAME" }, \ | ||
| 131 | { XFS_DA_OP_ADDNAME, "ADDNAME" }, \ | ||
| 132 | { XFS_DA_OP_OKNOENT, "OKNOENT" }, \ | ||
| 133 | { XFS_DA_OP_CILOOKUP, "CILOOKUP" } | ||
| 134 | |||
| 128 | /* | 135 | /* |
| 129 | * Structure to describe buffer(s) for a block. | 136 | * Structure to describe buffer(s) for a block. |
| 130 | * This is needed in the directory version 2 format case, when | 137 | * This is needed in the directory version 2 format case, when |
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c index ab89a7e94a0f..d1483a4f71b8 100644 --- a/fs/xfs/xfs_dfrag.c +++ b/fs/xfs/xfs_dfrag.c | |||
| @@ -43,6 +43,7 @@ | |||
| 43 | #include "xfs_error.h" | 43 | #include "xfs_error.h" |
| 44 | #include "xfs_rw.h" | 44 | #include "xfs_rw.h" |
| 45 | #include "xfs_vnodeops.h" | 45 | #include "xfs_vnodeops.h" |
| 46 | #include "xfs_trace.h" | ||
| 46 | 47 | ||
| 47 | /* | 48 | /* |
| 48 | * Syssgi interface for swapext | 49 | * Syssgi interface for swapext |
| @@ -168,7 +169,6 @@ xfs_swap_extents( | |||
| 168 | } | 169 | } |
| 169 | 170 | ||
| 170 | if (VN_CACHED(VFS_I(tip)) != 0) { | 171 | if (VN_CACHED(VFS_I(tip)) != 0) { |
| 171 | xfs_inval_cached_trace(tip, 0, -1, 0, -1); | ||
| 172 | error = xfs_flushinval_pages(tip, 0, -1, | 172 | error = xfs_flushinval_pages(tip, 0, -1, |
| 173 | FI_REMAPF_LOCKED); | 173 | FI_REMAPF_LOCKED); |
| 174 | if (error) | 174 | if (error) |
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c index bb1d58eb3982..93634a7e90e9 100644 --- a/fs/xfs/xfs_dir2.c +++ b/fs/xfs/xfs_dir2.c | |||
| @@ -40,9 +40,9 @@ | |||
| 40 | #include "xfs_dir2_leaf.h" | 40 | #include "xfs_dir2_leaf.h" |
| 41 | #include "xfs_dir2_block.h" | 41 | #include "xfs_dir2_block.h" |
| 42 | #include "xfs_dir2_node.h" | 42 | #include "xfs_dir2_node.h" |
| 43 | #include "xfs_dir2_trace.h" | ||
| 44 | #include "xfs_error.h" | 43 | #include "xfs_error.h" |
| 45 | #include "xfs_vnodeops.h" | 44 | #include "xfs_vnodeops.h" |
| 45 | #include "xfs_trace.h" | ||
| 46 | 46 | ||
| 47 | struct xfs_name xfs_name_dotdot = {"..", 2}; | 47 | struct xfs_name xfs_name_dotdot = {"..", 2}; |
| 48 | 48 | ||
| @@ -525,7 +525,8 @@ xfs_dir2_grow_inode( | |||
| 525 | xfs_trans_t *tp; | 525 | xfs_trans_t *tp; |
| 526 | xfs_drfsbno_t nblks; | 526 | xfs_drfsbno_t nblks; |
| 527 | 527 | ||
| 528 | xfs_dir2_trace_args_s("grow_inode", args, space); | 528 | trace_xfs_dir2_grow_inode(args, space); |
| 529 | |||
| 529 | dp = args->dp; | 530 | dp = args->dp; |
| 530 | tp = args->trans; | 531 | tp = args->trans; |
| 531 | mp = dp->i_mount; | 532 | mp = dp->i_mount; |
| @@ -703,7 +704,8 @@ xfs_dir2_shrink_inode( | |||
| 703 | xfs_mount_t *mp; | 704 | xfs_mount_t *mp; |
| 704 | xfs_trans_t *tp; | 705 | xfs_trans_t *tp; |
| 705 | 706 | ||
| 706 | xfs_dir2_trace_args_db("shrink_inode", args, db, bp); | 707 | trace_xfs_dir2_shrink_inode(args, db); |
| 708 | |||
| 707 | dp = args->dp; | 709 | dp = args->dp; |
| 708 | mp = dp->i_mount; | 710 | mp = dp->i_mount; |
| 709 | tp = args->trans; | 711 | tp = args->trans; |
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index ab52e9e1c1ee..ddc4ecc7807f 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c | |||
| @@ -36,8 +36,8 @@ | |||
| 36 | #include "xfs_dir2_data.h" | 36 | #include "xfs_dir2_data.h" |
| 37 | #include "xfs_dir2_leaf.h" | 37 | #include "xfs_dir2_leaf.h" |
| 38 | #include "xfs_dir2_block.h" | 38 | #include "xfs_dir2_block.h" |
| 39 | #include "xfs_dir2_trace.h" | ||
| 40 | #include "xfs_error.h" | 39 | #include "xfs_error.h" |
| 40 | #include "xfs_trace.h" | ||
| 41 | 41 | ||
| 42 | /* | 42 | /* |
| 43 | * Local function prototypes. | 43 | * Local function prototypes. |
| @@ -94,7 +94,8 @@ xfs_dir2_block_addname( | |||
| 94 | __be16 *tagp; /* pointer to tag value */ | 94 | __be16 *tagp; /* pointer to tag value */ |
| 95 | xfs_trans_t *tp; /* transaction structure */ | 95 | xfs_trans_t *tp; /* transaction structure */ |
| 96 | 96 | ||
| 97 | xfs_dir2_trace_args("block_addname", args); | 97 | trace_xfs_dir2_block_addname(args); |
| 98 | |||
| 98 | dp = args->dp; | 99 | dp = args->dp; |
| 99 | tp = args->trans; | 100 | tp = args->trans; |
| 100 | mp = dp->i_mount; | 101 | mp = dp->i_mount; |
| @@ -590,7 +591,8 @@ xfs_dir2_block_lookup( | |||
| 590 | int error; /* error return value */ | 591 | int error; /* error return value */ |
| 591 | xfs_mount_t *mp; /* filesystem mount point */ | 592 | xfs_mount_t *mp; /* filesystem mount point */ |
| 592 | 593 | ||
| 593 | xfs_dir2_trace_args("block_lookup", args); | 594 | trace_xfs_dir2_block_lookup(args); |
| 595 | |||
| 594 | /* | 596 | /* |
| 595 | * Get the buffer, look up the entry. | 597 | * Get the buffer, look up the entry. |
| 596 | * If not found (ENOENT) then return, have no buffer. | 598 | * If not found (ENOENT) then return, have no buffer. |
| @@ -747,7 +749,8 @@ xfs_dir2_block_removename( | |||
| 747 | int size; /* shortform size */ | 749 | int size; /* shortform size */ |
| 748 | xfs_trans_t *tp; /* transaction pointer */ | 750 | xfs_trans_t *tp; /* transaction pointer */ |
| 749 | 751 | ||
| 750 | xfs_dir2_trace_args("block_removename", args); | 752 | trace_xfs_dir2_block_removename(args); |
| 753 | |||
| 751 | /* | 754 | /* |
| 752 | * Look up the entry in the block. Gets the buffer and entry index. | 755 | * Look up the entry in the block. Gets the buffer and entry index. |
| 753 | * It will always be there, the vnodeops level does a lookup first. | 756 | * It will always be there, the vnodeops level does a lookup first. |
| @@ -823,7 +826,8 @@ xfs_dir2_block_replace( | |||
| 823 | int error; /* error return value */ | 826 | int error; /* error return value */ |
| 824 | xfs_mount_t *mp; /* filesystem mount point */ | 827 | xfs_mount_t *mp; /* filesystem mount point */ |
| 825 | 828 | ||
| 826 | xfs_dir2_trace_args("block_replace", args); | 829 | trace_xfs_dir2_block_replace(args); |
| 830 | |||
| 827 | /* | 831 | /* |
| 828 | * Lookup the entry in the directory. Get buffer and entry index. | 832 | * Lookup the entry in the directory. Get buffer and entry index. |
| 829 | * This will always succeed since the caller has already done a lookup. | 833 | * This will always succeed since the caller has already done a lookup. |
| @@ -897,7 +901,8 @@ xfs_dir2_leaf_to_block( | |||
| 897 | int to; /* block/leaf to index */ | 901 | int to; /* block/leaf to index */ |
| 898 | xfs_trans_t *tp; /* transaction pointer */ | 902 | xfs_trans_t *tp; /* transaction pointer */ |
| 899 | 903 | ||
| 900 | xfs_dir2_trace_args_bb("leaf_to_block", args, lbp, dbp); | 904 | trace_xfs_dir2_leaf_to_block(args); |
| 905 | |||
| 901 | dp = args->dp; | 906 | dp = args->dp; |
| 902 | tp = args->trans; | 907 | tp = args->trans; |
| 903 | mp = dp->i_mount; | 908 | mp = dp->i_mount; |
| @@ -1044,7 +1049,8 @@ xfs_dir2_sf_to_block( | |||
| 1044 | xfs_trans_t *tp; /* transaction pointer */ | 1049 | xfs_trans_t *tp; /* transaction pointer */ |
| 1045 | struct xfs_name name; | 1050 | struct xfs_name name; |
| 1046 | 1051 | ||
| 1047 | xfs_dir2_trace_args("sf_to_block", args); | 1052 | trace_xfs_dir2_sf_to_block(args); |
| 1053 | |||
| 1048 | dp = args->dp; | 1054 | dp = args->dp; |
| 1049 | tp = args->trans; | 1055 | tp = args->trans; |
| 1050 | mp = dp->i_mount; | 1056 | mp = dp->i_mount; |
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c index 41ad537c49e9..29f484c11b3a 100644 --- a/fs/xfs/xfs_dir2_leaf.c +++ b/fs/xfs/xfs_dir2_leaf.c | |||
| @@ -38,8 +38,8 @@ | |||
| 38 | #include "xfs_dir2_leaf.h" | 38 | #include "xfs_dir2_leaf.h" |
| 39 | #include "xfs_dir2_block.h" | 39 | #include "xfs_dir2_block.h" |
| 40 | #include "xfs_dir2_node.h" | 40 | #include "xfs_dir2_node.h" |
| 41 | #include "xfs_dir2_trace.h" | ||
| 42 | #include "xfs_error.h" | 41 | #include "xfs_error.h" |
| 42 | #include "xfs_trace.h" | ||
| 43 | 43 | ||
| 44 | /* | 44 | /* |
| 45 | * Local function declarations. | 45 | * Local function declarations. |
| @@ -80,7 +80,8 @@ xfs_dir2_block_to_leaf( | |||
| 80 | int needscan; /* need to rescan bestfree */ | 80 | int needscan; /* need to rescan bestfree */ |
| 81 | xfs_trans_t *tp; /* transaction pointer */ | 81 | xfs_trans_t *tp; /* transaction pointer */ |
| 82 | 82 | ||
| 83 | xfs_dir2_trace_args_b("block_to_leaf", args, dbp); | 83 | trace_xfs_dir2_block_to_leaf(args); |
| 84 | |||
| 84 | dp = args->dp; | 85 | dp = args->dp; |
| 85 | mp = dp->i_mount; | 86 | mp = dp->i_mount; |
| 86 | tp = args->trans; | 87 | tp = args->trans; |
| @@ -188,7 +189,8 @@ xfs_dir2_leaf_addname( | |||
| 188 | xfs_trans_t *tp; /* transaction pointer */ | 189 | xfs_trans_t *tp; /* transaction pointer */ |
| 189 | xfs_dir2_db_t use_block; /* data block number */ | 190 | xfs_dir2_db_t use_block; /* data block number */ |
| 190 | 191 | ||
| 191 | xfs_dir2_trace_args("leaf_addname", args); | 192 | trace_xfs_dir2_leaf_addname(args); |
| 193 | |||
| 192 | dp = args->dp; | 194 | dp = args->dp; |
| 193 | tp = args->trans; | 195 | tp = args->trans; |
| 194 | mp = dp->i_mount; | 196 | mp = dp->i_mount; |
| @@ -1266,7 +1268,8 @@ xfs_dir2_leaf_lookup( | |||
| 1266 | xfs_dir2_leaf_entry_t *lep; /* leaf entry */ | 1268 | xfs_dir2_leaf_entry_t *lep; /* leaf entry */ |
| 1267 | xfs_trans_t *tp; /* transaction pointer */ | 1269 | xfs_trans_t *tp; /* transaction pointer */ |
| 1268 | 1270 | ||
| 1269 | xfs_dir2_trace_args("leaf_lookup", args); | 1271 | trace_xfs_dir2_leaf_lookup(args); |
| 1272 | |||
| 1270 | /* | 1273 | /* |
| 1271 | * Look up name in the leaf block, returning both buffers and index. | 1274 | * Look up name in the leaf block, returning both buffers and index. |
| 1272 | */ | 1275 | */ |
| @@ -1454,7 +1457,8 @@ xfs_dir2_leaf_removename( | |||
| 1454 | xfs_dir2_data_off_t oldbest; /* old value of best free */ | 1457 | xfs_dir2_data_off_t oldbest; /* old value of best free */ |
| 1455 | xfs_trans_t *tp; /* transaction pointer */ | 1458 | xfs_trans_t *tp; /* transaction pointer */ |
| 1456 | 1459 | ||
| 1457 | xfs_dir2_trace_args("leaf_removename", args); | 1460 | trace_xfs_dir2_leaf_removename(args); |
| 1461 | |||
| 1458 | /* | 1462 | /* |
| 1459 | * Lookup the leaf entry, get the leaf and data blocks read in. | 1463 | * Lookup the leaf entry, get the leaf and data blocks read in. |
| 1460 | */ | 1464 | */ |
| @@ -1586,7 +1590,8 @@ xfs_dir2_leaf_replace( | |||
| 1586 | xfs_dir2_leaf_entry_t *lep; /* leaf entry */ | 1590 | xfs_dir2_leaf_entry_t *lep; /* leaf entry */ |
| 1587 | xfs_trans_t *tp; /* transaction pointer */ | 1591 | xfs_trans_t *tp; /* transaction pointer */ |
| 1588 | 1592 | ||
| 1589 | xfs_dir2_trace_args("leaf_replace", args); | 1593 | trace_xfs_dir2_leaf_replace(args); |
| 1594 | |||
| 1590 | /* | 1595 | /* |
| 1591 | * Look up the entry. | 1596 | * Look up the entry. |
| 1592 | */ | 1597 | */ |
| @@ -1766,7 +1771,9 @@ xfs_dir2_node_to_leaf( | |||
| 1766 | if (state->path.active > 1) | 1771 | if (state->path.active > 1) |
| 1767 | return 0; | 1772 | return 0; |
| 1768 | args = state->args; | 1773 | args = state->args; |
| 1769 | xfs_dir2_trace_args("node_to_leaf", args); | 1774 | |
| 1775 | trace_xfs_dir2_node_to_leaf(args); | ||
| 1776 | |||
| 1770 | mp = state->mp; | 1777 | mp = state->mp; |
| 1771 | dp = args->dp; | 1778 | dp = args->dp; |
| 1772 | tp = args->trans; | 1779 | tp = args->trans; |
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c index 5a81ccd1045b..ce6e355199b5 100644 --- a/fs/xfs/xfs_dir2_node.c +++ b/fs/xfs/xfs_dir2_node.c | |||
| @@ -37,8 +37,8 @@ | |||
| 37 | #include "xfs_dir2_leaf.h" | 37 | #include "xfs_dir2_leaf.h" |
| 38 | #include "xfs_dir2_block.h" | 38 | #include "xfs_dir2_block.h" |
| 39 | #include "xfs_dir2_node.h" | 39 | #include "xfs_dir2_node.h" |
| 40 | #include "xfs_dir2_trace.h" | ||
| 41 | #include "xfs_error.h" | 40 | #include "xfs_error.h" |
| 41 | #include "xfs_trace.h" | ||
| 42 | 42 | ||
| 43 | /* | 43 | /* |
| 44 | * Function declarations. | 44 | * Function declarations. |
| @@ -123,7 +123,8 @@ xfs_dir2_leaf_to_node( | |||
| 123 | __be16 *to; /* pointer to freespace entry */ | 123 | __be16 *to; /* pointer to freespace entry */ |
| 124 | xfs_trans_t *tp; /* transaction pointer */ | 124 | xfs_trans_t *tp; /* transaction pointer */ |
| 125 | 125 | ||
| 126 | xfs_dir2_trace_args_b("leaf_to_node", args, lbp); | 126 | trace_xfs_dir2_leaf_to_node(args); |
| 127 | |||
| 127 | dp = args->dp; | 128 | dp = args->dp; |
| 128 | mp = dp->i_mount; | 129 | mp = dp->i_mount; |
| 129 | tp = args->trans; | 130 | tp = args->trans; |
| @@ -196,7 +197,8 @@ xfs_dir2_leafn_add( | |||
| 196 | xfs_mount_t *mp; /* filesystem mount point */ | 197 | xfs_mount_t *mp; /* filesystem mount point */ |
| 197 | xfs_trans_t *tp; /* transaction pointer */ | 198 | xfs_trans_t *tp; /* transaction pointer */ |
| 198 | 199 | ||
| 199 | xfs_dir2_trace_args_sb("leafn_add", args, index, bp); | 200 | trace_xfs_dir2_leafn_add(args, index); |
| 201 | |||
| 200 | dp = args->dp; | 202 | dp = args->dp; |
| 201 | mp = dp->i_mount; | 203 | mp = dp->i_mount; |
| 202 | tp = args->trans; | 204 | tp = args->trans; |
| @@ -711,8 +713,8 @@ xfs_dir2_leafn_moveents( | |||
| 711 | int stale; /* count stale leaves copied */ | 713 | int stale; /* count stale leaves copied */ |
| 712 | xfs_trans_t *tp; /* transaction pointer */ | 714 | xfs_trans_t *tp; /* transaction pointer */ |
| 713 | 715 | ||
| 714 | xfs_dir2_trace_args_bibii("leafn_moveents", args, bp_s, start_s, bp_d, | 716 | trace_xfs_dir2_leafn_moveents(args, start_s, start_d, count); |
| 715 | start_d, count); | 717 | |
| 716 | /* | 718 | /* |
| 717 | * Silently return if nothing to do. | 719 | * Silently return if nothing to do. |
| 718 | */ | 720 | */ |
| @@ -933,7 +935,8 @@ xfs_dir2_leafn_remove( | |||
| 933 | int needscan; /* need to rescan data frees */ | 935 | int needscan; /* need to rescan data frees */ |
| 934 | xfs_trans_t *tp; /* transaction pointer */ | 936 | xfs_trans_t *tp; /* transaction pointer */ |
| 935 | 937 | ||
| 936 | xfs_dir2_trace_args_sb("leafn_remove", args, index, bp); | 938 | trace_xfs_dir2_leafn_remove(args, index); |
| 939 | |||
| 937 | dp = args->dp; | 940 | dp = args->dp; |
| 938 | tp = args->trans; | 941 | tp = args->trans; |
| 939 | mp = dp->i_mount; | 942 | mp = dp->i_mount; |
| @@ -1363,7 +1366,8 @@ xfs_dir2_node_addname( | |||
| 1363 | int rval; /* sub-return value */ | 1366 | int rval; /* sub-return value */ |
| 1364 | xfs_da_state_t *state; /* btree cursor */ | 1367 | xfs_da_state_t *state; /* btree cursor */ |
| 1365 | 1368 | ||
| 1366 | xfs_dir2_trace_args("node_addname", args); | 1369 | trace_xfs_dir2_node_addname(args); |
| 1370 | |||
| 1367 | /* | 1371 | /* |
| 1368 | * Allocate and initialize the state (btree cursor). | 1372 | * Allocate and initialize the state (btree cursor). |
| 1369 | */ | 1373 | */ |
| @@ -1822,7 +1826,8 @@ xfs_dir2_node_lookup( | |||
| 1822 | int rval; /* operation return value */ | 1826 | int rval; /* operation return value */ |
| 1823 | xfs_da_state_t *state; /* btree cursor */ | 1827 | xfs_da_state_t *state; /* btree cursor */ |
| 1824 | 1828 | ||
| 1825 | xfs_dir2_trace_args("node_lookup", args); | 1829 | trace_xfs_dir2_node_lookup(args); |
| 1830 | |||
| 1826 | /* | 1831 | /* |
| 1827 | * Allocate and initialize the btree cursor. | 1832 | * Allocate and initialize the btree cursor. |
| 1828 | */ | 1833 | */ |
| @@ -1875,7 +1880,8 @@ xfs_dir2_node_removename( | |||
| 1875 | int rval; /* operation return value */ | 1880 | int rval; /* operation return value */ |
| 1876 | xfs_da_state_t *state; /* btree cursor */ | 1881 | xfs_da_state_t *state; /* btree cursor */ |
| 1877 | 1882 | ||
| 1878 | xfs_dir2_trace_args("node_removename", args); | 1883 | trace_xfs_dir2_node_removename(args); |
| 1884 | |||
| 1879 | /* | 1885 | /* |
| 1880 | * Allocate and initialize the btree cursor. | 1886 | * Allocate and initialize the btree cursor. |
| 1881 | */ | 1887 | */ |
| @@ -1944,7 +1950,8 @@ xfs_dir2_node_replace( | |||
| 1944 | int rval; /* internal return value */ | 1950 | int rval; /* internal return value */ |
| 1945 | xfs_da_state_t *state; /* btree cursor */ | 1951 | xfs_da_state_t *state; /* btree cursor */ |
| 1946 | 1952 | ||
| 1947 | xfs_dir2_trace_args("node_replace", args); | 1953 | trace_xfs_dir2_node_replace(args); |
| 1954 | |||
| 1948 | /* | 1955 | /* |
| 1949 | * Allocate and initialize the btree cursor. | 1956 | * Allocate and initialize the btree cursor. |
| 1950 | */ | 1957 | */ |
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c index e89734e84646..9d4f17a69676 100644 --- a/fs/xfs/xfs_dir2_sf.c +++ b/fs/xfs/xfs_dir2_sf.c | |||
| @@ -37,7 +37,7 @@ | |||
| 37 | #include "xfs_dir2_data.h" | 37 | #include "xfs_dir2_data.h" |
| 38 | #include "xfs_dir2_leaf.h" | 38 | #include "xfs_dir2_leaf.h" |
| 39 | #include "xfs_dir2_block.h" | 39 | #include "xfs_dir2_block.h" |
| 40 | #include "xfs_dir2_trace.h" | 40 | #include "xfs_trace.h" |
| 41 | 41 | ||
| 42 | /* | 42 | /* |
| 43 | * Prototypes for internal functions. | 43 | * Prototypes for internal functions. |
| @@ -169,7 +169,8 @@ xfs_dir2_block_to_sf( | |||
| 169 | xfs_dir2_sf_t *sfp; /* shortform structure */ | 169 | xfs_dir2_sf_t *sfp; /* shortform structure */ |
| 170 | xfs_ino_t temp; | 170 | xfs_ino_t temp; |
| 171 | 171 | ||
| 172 | xfs_dir2_trace_args_sb("block_to_sf", args, size, bp); | 172 | trace_xfs_dir2_block_to_sf(args); |
| 173 | |||
| 173 | dp = args->dp; | 174 | dp = args->dp; |
| 174 | mp = dp->i_mount; | 175 | mp = dp->i_mount; |
| 175 | 176 | ||
| @@ -281,7 +282,8 @@ xfs_dir2_sf_addname( | |||
| 281 | xfs_dir2_sf_t *sfp; /* shortform structure */ | 282 | xfs_dir2_sf_t *sfp; /* shortform structure */ |
| 282 | xfs_dir2_sf_entry_t *sfep = NULL; /* shortform entry */ | 283 | xfs_dir2_sf_entry_t *sfep = NULL; /* shortform entry */ |
| 283 | 284 | ||
| 284 | xfs_dir2_trace_args("sf_addname", args); | 285 | trace_xfs_dir2_sf_addname(args); |
| 286 | |||
| 285 | ASSERT(xfs_dir2_sf_lookup(args) == ENOENT); | 287 | ASSERT(xfs_dir2_sf_lookup(args) == ENOENT); |
| 286 | dp = args->dp; | 288 | dp = args->dp; |
| 287 | ASSERT(dp->i_df.if_flags & XFS_IFINLINE); | 289 | ASSERT(dp->i_df.if_flags & XFS_IFINLINE); |
| @@ -654,7 +656,8 @@ xfs_dir2_sf_create( | |||
| 654 | xfs_dir2_sf_t *sfp; /* shortform structure */ | 656 | xfs_dir2_sf_t *sfp; /* shortform structure */ |
| 655 | int size; /* directory size */ | 657 | int size; /* directory size */ |
| 656 | 658 | ||
| 657 | xfs_dir2_trace_args_i("sf_create", args, pino); | 659 | trace_xfs_dir2_sf_create(args); |
| 660 | |||
| 658 | dp = args->dp; | 661 | dp = args->dp; |
| 659 | 662 | ||
| 660 | ASSERT(dp != NULL); | 663 | ASSERT(dp != NULL); |
| @@ -808,7 +811,8 @@ xfs_dir2_sf_lookup( | |||
| 808 | enum xfs_dacmp cmp; /* comparison result */ | 811 | enum xfs_dacmp cmp; /* comparison result */ |
| 809 | xfs_dir2_sf_entry_t *ci_sfep; /* case-insens. entry */ | 812 | xfs_dir2_sf_entry_t *ci_sfep; /* case-insens. entry */ |
| 810 | 813 | ||
| 811 | xfs_dir2_trace_args("sf_lookup", args); | 814 | trace_xfs_dir2_sf_lookup(args); |
| 815 | |||
| 812 | xfs_dir2_sf_check(args); | 816 | xfs_dir2_sf_check(args); |
| 813 | dp = args->dp; | 817 | dp = args->dp; |
| 814 | 818 | ||
| @@ -891,7 +895,8 @@ xfs_dir2_sf_removename( | |||
| 891 | xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */ | 895 | xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */ |
| 892 | xfs_dir2_sf_t *sfp; /* shortform structure */ | 896 | xfs_dir2_sf_t *sfp; /* shortform structure */ |
| 893 | 897 | ||
| 894 | xfs_dir2_trace_args("sf_removename", args); | 898 | trace_xfs_dir2_sf_removename(args); |
| 899 | |||
| 895 | dp = args->dp; | 900 | dp = args->dp; |
| 896 | 901 | ||
| 897 | ASSERT(dp->i_df.if_flags & XFS_IFINLINE); | 902 | ASSERT(dp->i_df.if_flags & XFS_IFINLINE); |
| @@ -982,7 +987,8 @@ xfs_dir2_sf_replace( | |||
| 982 | xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */ | 987 | xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */ |
| 983 | xfs_dir2_sf_t *sfp; /* shortform structure */ | 988 | xfs_dir2_sf_t *sfp; /* shortform structure */ |
| 984 | 989 | ||
| 985 | xfs_dir2_trace_args("sf_replace", args); | 990 | trace_xfs_dir2_sf_replace(args); |
| 991 | |||
| 986 | dp = args->dp; | 992 | dp = args->dp; |
| 987 | 993 | ||
| 988 | ASSERT(dp->i_df.if_flags & XFS_IFINLINE); | 994 | ASSERT(dp->i_df.if_flags & XFS_IFINLINE); |
| @@ -1125,7 +1131,8 @@ xfs_dir2_sf_toino4( | |||
| 1125 | xfs_dir2_sf_entry_t *sfep; /* new sf entry */ | 1131 | xfs_dir2_sf_entry_t *sfep; /* new sf entry */ |
| 1126 | xfs_dir2_sf_t *sfp; /* new sf directory */ | 1132 | xfs_dir2_sf_t *sfp; /* new sf directory */ |
| 1127 | 1133 | ||
| 1128 | xfs_dir2_trace_args("sf_toino4", args); | 1134 | trace_xfs_dir2_sf_toino4(args); |
| 1135 | |||
| 1129 | dp = args->dp; | 1136 | dp = args->dp; |
| 1130 | 1137 | ||
| 1131 | /* | 1138 | /* |
| @@ -1202,7 +1209,8 @@ xfs_dir2_sf_toino8( | |||
| 1202 | xfs_dir2_sf_entry_t *sfep; /* new sf entry */ | 1209 | xfs_dir2_sf_entry_t *sfep; /* new sf entry */ |
| 1203 | xfs_dir2_sf_t *sfp; /* new sf directory */ | 1210 | xfs_dir2_sf_t *sfp; /* new sf directory */ |
| 1204 | 1211 | ||
| 1205 | xfs_dir2_trace_args("sf_toino8", args); | 1212 | trace_xfs_dir2_sf_toino8(args); |
| 1213 | |||
| 1206 | dp = args->dp; | 1214 | dp = args->dp; |
| 1207 | 1215 | ||
| 1208 | /* | 1216 | /* |
diff --git a/fs/xfs/xfs_dir2_trace.c b/fs/xfs/xfs_dir2_trace.c deleted file mode 100644 index 6cc7c0c681ac..000000000000 --- a/fs/xfs/xfs_dir2_trace.c +++ /dev/null | |||
| @@ -1,216 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. | ||
| 3 | * All Rights Reserved. | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU General Public License as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it would be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program; if not, write the Free Software Foundation, | ||
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | #include "xfs.h" | ||
| 19 | #include "xfs_fs.h" | ||
| 20 | #include "xfs_types.h" | ||
| 21 | #include "xfs_inum.h" | ||
| 22 | #include "xfs_dir2.h" | ||
| 23 | #include "xfs_da_btree.h" | ||
| 24 | #include "xfs_bmap_btree.h" | ||
| 25 | #include "xfs_dir2_sf.h" | ||
| 26 | #include "xfs_attr_sf.h" | ||
| 27 | #include "xfs_dinode.h" | ||
| 28 | #include "xfs_inode.h" | ||
| 29 | #include "xfs_dir2_trace.h" | ||
| 30 | |||
| 31 | #ifdef XFS_DIR2_TRACE | ||
| 32 | ktrace_t *xfs_dir2_trace_buf; | ||
| 33 | |||
| 34 | /* | ||
| 35 | * Enter something in the trace buffers. | ||
| 36 | */ | ||
| 37 | static void | ||
| 38 | xfs_dir2_trace_enter( | ||
| 39 | xfs_inode_t *dp, | ||
| 40 | int type, | ||
| 41 | char *where, | ||
| 42 | char *name, | ||
| 43 | int namelen, | ||
| 44 | void *a0, | ||
| 45 | void *a1, | ||
| 46 | void *a2, | ||
| 47 | void *a3, | ||
| 48 | void *a4, | ||
| 49 | void *a5, | ||
| 50 | void *a6, | ||
| 51 | void *a7) | ||
| 52 | { | ||
| 53 | void *n[5]; | ||
| 54 | |||
| 55 | ASSERT(xfs_dir2_trace_buf); | ||
| 56 | ASSERT(dp->i_dir_trace); | ||
| 57 | if (name) | ||
| 58 | memcpy(n, name, min((int)sizeof(n), namelen)); | ||
| 59 | else | ||
| 60 | memset((char *)n, 0, sizeof(n)); | ||
| 61 | ktrace_enter(xfs_dir2_trace_buf, | ||
| 62 | (void *)(long)type, (void *)where, | ||
| 63 | (void *)a0, (void *)a1, (void *)a2, (void *)a3, | ||
| 64 | (void *)a4, (void *)a5, (void *)a6, (void *)a7, | ||
| 65 | (void *)(long)namelen, | ||
| 66 | (void *)n[0], (void *)n[1], (void *)n[2], | ||
| 67 | (void *)n[3], (void *)n[4]); | ||
| 68 | ktrace_enter(dp->i_dir_trace, | ||
| 69 | (void *)(long)type, (void *)where, | ||
| 70 | (void *)a0, (void *)a1, (void *)a2, (void *)a3, | ||
| 71 | (void *)a4, (void *)a5, (void *)a6, (void *)a7, | ||
| 72 | (void *)(long)namelen, | ||
| 73 | (void *)n[0], (void *)n[1], (void *)n[2], | ||
| 74 | (void *)n[3], (void *)n[4]); | ||
| 75 | } | ||
| 76 | |||
| 77 | void | ||
| 78 | xfs_dir2_trace_args( | ||
| 79 | char *where, | ||
| 80 | xfs_da_args_t *args) | ||
| 81 | { | ||
| 82 | xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS, where, | ||
| 83 | (char *)args->name, (int)args->namelen, | ||
| 84 | (void *)(unsigned long)args->hashval, | ||
| 85 | (void *)((unsigned long)(args->inumber >> 32)), | ||
| 86 | (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)), | ||
| 87 | (void *)args->dp, (void *)args->trans, | ||
| 88 | (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK), | ||
| 89 | NULL, NULL); | ||
| 90 | } | ||
| 91 | |||
| 92 | void | ||
| 93 | xfs_dir2_trace_args_b( | ||
| 94 | char *where, | ||
| 95 | xfs_da_args_t *args, | ||
| 96 | xfs_dabuf_t *bp) | ||
| 97 | { | ||
| 98 | xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_B, where, | ||
| 99 | (char *)args->name, (int)args->namelen, | ||
| 100 | (void *)(unsigned long)args->hashval, | ||
| 101 | (void *)((unsigned long)(args->inumber >> 32)), | ||
| 102 | (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)), | ||
| 103 | (void *)args->dp, (void *)args->trans, | ||
| 104 | (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK), | ||
| 105 | (void *)(bp ? bp->bps[0] : NULL), NULL); | ||
| 106 | } | ||
| 107 | |||
| 108 | void | ||
| 109 | xfs_dir2_trace_args_bb( | ||
| 110 | char *where, | ||
| 111 | xfs_da_args_t *args, | ||
| 112 | xfs_dabuf_t *lbp, | ||
| 113 | xfs_dabuf_t *dbp) | ||
| 114 | { | ||
| 115 | xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_BB, where, | ||
| 116 | (char *)args->name, (int)args->namelen, | ||
| 117 | (void *)(unsigned long)args->hashval, | ||
| 118 | (void *)((unsigned long)(args->inumber >> 32)), | ||
| 119 | (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)), | ||
| 120 | (void *)args->dp, (void *)args->trans, | ||
| 121 | (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK), | ||
| 122 | (void *)(lbp ? lbp->bps[0] : NULL), | ||
| 123 | (void *)(dbp ? dbp->bps[0] : NULL)); | ||
| 124 | } | ||
| 125 | |||
| 126 | void | ||
| 127 | xfs_dir2_trace_args_bibii( | ||
| 128 | char *where, | ||
| 129 | xfs_da_args_t *args, | ||
| 130 | xfs_dabuf_t *bs, | ||
| 131 | int ss, | ||
| 132 | xfs_dabuf_t *bd, | ||
| 133 | int sd, | ||
| 134 | int c) | ||
| 135 | { | ||
| 136 | xfs_buf_t *bpbs = bs ? bs->bps[0] : NULL; | ||
| 137 | xfs_buf_t *bpbd = bd ? bd->bps[0] : NULL; | ||
| 138 | |||
| 139 | xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_BIBII, where, | ||
| 140 | (char *)args->name, (int)args->namelen, | ||
| 141 | (void *)args->dp, (void *)args->trans, | ||
| 142 | (void *)bpbs, (void *)(long)ss, (void *)bpbd, (void *)(long)sd, | ||
| 143 | (void *)(long)c, NULL); | ||
| 144 | } | ||
| 145 | |||
| 146 | void | ||
| 147 | xfs_dir2_trace_args_db( | ||
| 148 | char *where, | ||
| 149 | xfs_da_args_t *args, | ||
| 150 | xfs_dir2_db_t db, | ||
| 151 | xfs_dabuf_t *bp) | ||
| 152 | { | ||
| 153 | xfs_buf_t *dbp = bp ? bp->bps[0] : NULL; | ||
| 154 | |||
| 155 | xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_DB, where, | ||
| 156 | (char *)args->name, (int)args->namelen, | ||
| 157 | (void *)(unsigned long)args->hashval, | ||
| 158 | (void *)((unsigned long)(args->inumber >> 32)), | ||
| 159 | (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)), | ||
| 160 | (void *)args->dp, (void *)args->trans, | ||
| 161 | (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK), | ||
| 162 | (void *)(long)db, (void *)dbp); | ||
| 163 | } | ||
| 164 | |||
| 165 | void | ||
| 166 | xfs_dir2_trace_args_i( | ||
| 167 | char *where, | ||
| 168 | xfs_da_args_t *args, | ||
| 169 | xfs_ino_t i) | ||
| 170 | { | ||
| 171 | xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_I, where, | ||
| 172 | (char *)args->name, (int)args->namelen, | ||
| 173 | (void *)(unsigned long)args->hashval, | ||
| 174 | (void *)((unsigned long)(args->inumber >> 32)), | ||
| 175 | (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)), | ||
| 176 | (void *)args->dp, (void *)args->trans, | ||
| 177 | (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK), | ||
| 178 | (void *)((unsigned long)(i >> 32)), | ||
| 179 | (void *)((unsigned long)(i & 0xFFFFFFFF))); | ||
| 180 | } | ||
| 181 | |||
| 182 | void | ||
| 183 | xfs_dir2_trace_args_s( | ||
| 184 | char *where, | ||
| 185 | xfs_da_args_t *args, | ||
| 186 | int s) | ||
| 187 | { | ||
| 188 | xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_S, where, | ||
| 189 | (char *)args->name, (int)args->namelen, | ||
| 190 | (void *)(unsigned long)args->hashval, | ||
| 191 | (void *)((unsigned long)(args->inumber >> 32)), | ||
| 192 | (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)), | ||
| 193 | (void *)args->dp, (void *)args->trans, | ||
| 194 | (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK), | ||
| 195 | (void *)(long)s, NULL); | ||
| 196 | } | ||
| 197 | |||
| 198 | void | ||
| 199 | xfs_dir2_trace_args_sb( | ||
| 200 | char *where, | ||
| 201 | xfs_da_args_t *args, | ||
| 202 | int s, | ||
| 203 | xfs_dabuf_t *bp) | ||
| 204 | { | ||
| 205 | xfs_buf_t *dbp = bp ? bp->bps[0] : NULL; | ||
| 206 | |||
| 207 | xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_SB, where, | ||
| 208 | (char *)args->name, (int)args->namelen, | ||
| 209 | (void *)(unsigned long)args->hashval, | ||
| 210 | (void *)((unsigned long)(args->inumber >> 32)), | ||
| 211 | (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)), | ||
| 212 | (void *)args->dp, (void *)args->trans, | ||
| 213 | (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK), | ||
| 214 | (void *)(long)s, (void *)dbp); | ||
| 215 | } | ||
| 216 | #endif /* XFS_DIR2_TRACE */ | ||
diff --git a/fs/xfs/xfs_dir2_trace.h b/fs/xfs/xfs_dir2_trace.h deleted file mode 100644 index ca3c754f4822..000000000000 --- a/fs/xfs/xfs_dir2_trace.h +++ /dev/null | |||
| @@ -1,72 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. | ||
| 3 | * All Rights Reserved. | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU General Public License as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it would be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program; if not, write the Free Software Foundation, | ||
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | #ifndef __XFS_DIR2_TRACE_H__ | ||
| 19 | #define __XFS_DIR2_TRACE_H__ | ||
| 20 | |||
| 21 | /* | ||
| 22 | * Tracing for xfs v2 directories. | ||
| 23 | */ | ||
| 24 | |||
| 25 | #if defined(XFS_DIR2_TRACE) | ||
| 26 | |||
| 27 | struct ktrace; | ||
| 28 | struct xfs_dabuf; | ||
| 29 | struct xfs_da_args; | ||
| 30 | |||
| 31 | #define XFS_DIR2_GTRACE_SIZE 4096 /* global buffer */ | ||
| 32 | #define XFS_DIR2_KTRACE_SIZE 32 /* per-inode buffer */ | ||
| 33 | extern struct ktrace *xfs_dir2_trace_buf; | ||
| 34 | |||
| 35 | #define XFS_DIR2_KTRACE_ARGS 1 /* args only */ | ||
| 36 | #define XFS_DIR2_KTRACE_ARGS_B 2 /* args + buffer */ | ||
| 37 | #define XFS_DIR2_KTRACE_ARGS_BB 3 /* args + 2 buffers */ | ||
| 38 | #define XFS_DIR2_KTRACE_ARGS_DB 4 /* args, db, buffer */ | ||
| 39 | #define XFS_DIR2_KTRACE_ARGS_I 5 /* args, inum */ | ||
| 40 | #define XFS_DIR2_KTRACE_ARGS_S 6 /* args, int */ | ||
| 41 | #define XFS_DIR2_KTRACE_ARGS_SB 7 /* args, int, buffer */ | ||
| 42 | #define XFS_DIR2_KTRACE_ARGS_BIBII 8 /* args, buf/int/buf/int/int */ | ||
| 43 | |||
| 44 | void xfs_dir2_trace_args(char *where, struct xfs_da_args *args); | ||
| 45 | void xfs_dir2_trace_args_b(char *where, struct xfs_da_args *args, | ||
| 46 | struct xfs_dabuf *bp); | ||
| 47 | void xfs_dir2_trace_args_bb(char *where, struct xfs_da_args *args, | ||
| 48 | struct xfs_dabuf *lbp, struct xfs_dabuf *dbp); | ||
| 49 | void xfs_dir2_trace_args_bibii(char *where, struct xfs_da_args *args, | ||
| 50 | struct xfs_dabuf *bs, int ss, | ||
| 51 | struct xfs_dabuf *bd, int sd, int c); | ||
| 52 | void xfs_dir2_trace_args_db(char *where, struct xfs_da_args *args, | ||
| 53 | xfs_dir2_db_t db, struct xfs_dabuf *bp); | ||
| 54 | void xfs_dir2_trace_args_i(char *where, struct xfs_da_args *args, xfs_ino_t i); | ||
| 55 | void xfs_dir2_trace_args_s(char *where, struct xfs_da_args *args, int s); | ||
| 56 | void xfs_dir2_trace_args_sb(char *where, struct xfs_da_args *args, int s, | ||
| 57 | struct xfs_dabuf *bp); | ||
| 58 | |||
| 59 | #else /* XFS_DIR2_TRACE */ | ||
| 60 | |||
| 61 | #define xfs_dir2_trace_args(where, args) | ||
| 62 | #define xfs_dir2_trace_args_b(where, args, bp) | ||
| 63 | #define xfs_dir2_trace_args_bb(where, args, lbp, dbp) | ||
| 64 | #define xfs_dir2_trace_args_bibii(where, args, bs, ss, bd, sd, c) | ||
| 65 | #define xfs_dir2_trace_args_db(where, args, db, bp) | ||
| 66 | #define xfs_dir2_trace_args_i(where, args, i) | ||
| 67 | #define xfs_dir2_trace_args_s(where, args, s) | ||
| 68 | #define xfs_dir2_trace_args_sb(where, args, s, bp) | ||
| 69 | |||
| 70 | #endif /* XFS_DIR2_TRACE */ | ||
| 71 | |||
| 72 | #endif /* __XFS_DIR2_TRACE_H__ */ | ||
diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c index edf8bdf4141f..a631e1451abb 100644 --- a/fs/xfs/xfs_filestream.c +++ b/fs/xfs/xfs_filestream.c | |||
| @@ -34,6 +34,7 @@ | |||
| 34 | #include "xfs_utils.h" | 34 | #include "xfs_utils.h" |
| 35 | #include "xfs_mru_cache.h" | 35 | #include "xfs_mru_cache.h" |
| 36 | #include "xfs_filestream.h" | 36 | #include "xfs_filestream.h" |
| 37 | #include "xfs_trace.h" | ||
| 37 | 38 | ||
| 38 | #ifdef XFS_FILESTREAMS_TRACE | 39 | #ifdef XFS_FILESTREAMS_TRACE |
| 39 | 40 | ||
| @@ -394,9 +395,7 @@ xfs_filestream_init(void) | |||
| 394 | item_zone = kmem_zone_init(sizeof(fstrm_item_t), "fstrm_item"); | 395 | item_zone = kmem_zone_init(sizeof(fstrm_item_t), "fstrm_item"); |
| 395 | if (!item_zone) | 396 | if (!item_zone) |
| 396 | return -ENOMEM; | 397 | return -ENOMEM; |
| 397 | #ifdef XFS_FILESTREAMS_TRACE | 398 | |
| 398 | xfs_filestreams_trace_buf = ktrace_alloc(XFS_FSTRM_KTRACE_SIZE, KM_NOFS); | ||
| 399 | #endif | ||
| 400 | return 0; | 399 | return 0; |
| 401 | } | 400 | } |
| 402 | 401 | ||
| @@ -407,9 +406,6 @@ xfs_filestream_init(void) | |||
| 407 | void | 406 | void |
| 408 | xfs_filestream_uninit(void) | 407 | xfs_filestream_uninit(void) |
| 409 | { | 408 | { |
| 410 | #ifdef XFS_FILESTREAMS_TRACE | ||
| 411 | ktrace_free(xfs_filestreams_trace_buf); | ||
| 412 | #endif | ||
| 413 | kmem_zone_destroy(item_zone); | 409 | kmem_zone_destroy(item_zone); |
| 414 | } | 410 | } |
| 415 | 411 | ||
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 36079aa91344..a13919a6a364 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c | |||
| @@ -45,6 +45,7 @@ | |||
| 45 | #include "xfs_rtalloc.h" | 45 | #include "xfs_rtalloc.h" |
| 46 | #include "xfs_rw.h" | 46 | #include "xfs_rw.h" |
| 47 | #include "xfs_filestream.h" | 47 | #include "xfs_filestream.h" |
| 48 | #include "xfs_trace.h" | ||
| 48 | 49 | ||
| 49 | /* | 50 | /* |
| 50 | * File system operations | 51 | * File system operations |
| @@ -347,6 +348,7 @@ xfs_growfs_data_private( | |||
| 347 | be32_add_cpu(&agf->agf_length, new); | 348 | be32_add_cpu(&agf->agf_length, new); |
| 348 | ASSERT(be32_to_cpu(agf->agf_length) == | 349 | ASSERT(be32_to_cpu(agf->agf_length) == |
| 349 | be32_to_cpu(agi->agi_length)); | 350 | be32_to_cpu(agi->agi_length)); |
| 351 | |||
| 350 | xfs_alloc_log_agf(tp, bp, XFS_AGF_LENGTH); | 352 | xfs_alloc_log_agf(tp, bp, XFS_AGF_LENGTH); |
| 351 | /* | 353 | /* |
| 352 | * Free the new space. | 354 | * Free the new space. |
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c index 073bb4a26b19..fa402a6bbbcf 100644 --- a/fs/xfs/xfs_iget.c +++ b/fs/xfs/xfs_iget.c | |||
| @@ -43,7 +43,7 @@ | |||
| 43 | #include "xfs_inode_item.h" | 43 | #include "xfs_inode_item.h" |
| 44 | #include "xfs_bmap.h" | 44 | #include "xfs_bmap.h" |
| 45 | #include "xfs_btree_trace.h" | 45 | #include "xfs_btree_trace.h" |
| 46 | #include "xfs_dir2_trace.h" | 46 | #include "xfs_trace.h" |
| 47 | 47 | ||
| 48 | 48 | ||
| 49 | /* | 49 | /* |
| @@ -90,30 +90,8 @@ xfs_inode_alloc( | |||
| 90 | ip->i_size = 0; | 90 | ip->i_size = 0; |
| 91 | ip->i_new_size = 0; | 91 | ip->i_new_size = 0; |
| 92 | 92 | ||
| 93 | /* | ||
| 94 | * Initialize inode's trace buffers. | ||
| 95 | */ | ||
| 96 | #ifdef XFS_INODE_TRACE | ||
| 97 | ip->i_trace = ktrace_alloc(INODE_TRACE_SIZE, KM_NOFS); | ||
| 98 | #endif | ||
| 99 | #ifdef XFS_BMAP_TRACE | ||
| 100 | ip->i_xtrace = ktrace_alloc(XFS_BMAP_KTRACE_SIZE, KM_NOFS); | ||
| 101 | #endif | ||
| 102 | #ifdef XFS_BTREE_TRACE | ||
| 103 | ip->i_btrace = ktrace_alloc(XFS_BMBT_KTRACE_SIZE, KM_NOFS); | ||
| 104 | #endif | ||
| 105 | #ifdef XFS_RW_TRACE | ||
| 106 | ip->i_rwtrace = ktrace_alloc(XFS_RW_KTRACE_SIZE, KM_NOFS); | ||
| 107 | #endif | ||
| 108 | #ifdef XFS_ILOCK_TRACE | ||
| 109 | ip->i_lock_trace = ktrace_alloc(XFS_ILOCK_KTRACE_SIZE, KM_NOFS); | ||
| 110 | #endif | ||
| 111 | #ifdef XFS_DIR2_TRACE | ||
| 112 | ip->i_dir_trace = ktrace_alloc(XFS_DIR2_KTRACE_SIZE, KM_NOFS); | ||
| 113 | #endif | ||
| 114 | |||
| 115 | /* prevent anyone from using this yet */ | 93 | /* prevent anyone from using this yet */ |
| 116 | VFS_I(ip)->i_state = I_NEW|I_LOCK; | 94 | VFS_I(ip)->i_state = I_NEW; |
| 117 | 95 | ||
| 118 | return ip; | 96 | return ip; |
| 119 | } | 97 | } |
| @@ -133,25 +111,6 @@ xfs_inode_free( | |||
| 133 | if (ip->i_afp) | 111 | if (ip->i_afp) |
| 134 | xfs_idestroy_fork(ip, XFS_ATTR_FORK); | 112 | xfs_idestroy_fork(ip, XFS_ATTR_FORK); |
| 135 | 113 | ||
| 136 | #ifdef XFS_INODE_TRACE | ||
| 137 | ktrace_free(ip->i_trace); | ||
| 138 | #endif | ||
| 139 | #ifdef XFS_BMAP_TRACE | ||
| 140 | ktrace_free(ip->i_xtrace); | ||
| 141 | #endif | ||
| 142 | #ifdef XFS_BTREE_TRACE | ||
| 143 | ktrace_free(ip->i_btrace); | ||
| 144 | #endif | ||
| 145 | #ifdef XFS_RW_TRACE | ||
| 146 | ktrace_free(ip->i_rwtrace); | ||
| 147 | #endif | ||
| 148 | #ifdef XFS_ILOCK_TRACE | ||
| 149 | ktrace_free(ip->i_lock_trace); | ||
| 150 | #endif | ||
| 151 | #ifdef XFS_DIR2_TRACE | ||
| 152 | ktrace_free(ip->i_dir_trace); | ||
| 153 | #endif | ||
| 154 | |||
| 155 | if (ip->i_itemp) { | 114 | if (ip->i_itemp) { |
| 156 | /* | 115 | /* |
| 157 | * Only if we are shutting down the fs will we see an | 116 | * Only if we are shutting down the fs will we see an |
| @@ -210,6 +169,7 @@ xfs_iget_cache_hit( | |||
| 210 | * instead of polling for it. | 169 | * instead of polling for it. |
| 211 | */ | 170 | */ |
| 212 | if (ip->i_flags & (XFS_INEW|XFS_IRECLAIM)) { | 171 | if (ip->i_flags & (XFS_INEW|XFS_IRECLAIM)) { |
| 172 | trace_xfs_iget_skip(ip); | ||
| 213 | XFS_STATS_INC(xs_ig_frecycle); | 173 | XFS_STATS_INC(xs_ig_frecycle); |
| 214 | error = EAGAIN; | 174 | error = EAGAIN; |
| 215 | goto out_error; | 175 | goto out_error; |
| @@ -228,7 +188,7 @@ xfs_iget_cache_hit( | |||
| 228 | * Need to carefully get it back into useable state. | 188 | * Need to carefully get it back into useable state. |
| 229 | */ | 189 | */ |
| 230 | if (ip->i_flags & XFS_IRECLAIMABLE) { | 190 | if (ip->i_flags & XFS_IRECLAIMABLE) { |
| 231 | xfs_itrace_exit_tag(ip, "xfs_iget.alloc"); | 191 | trace_xfs_iget_reclaim(ip); |
| 232 | 192 | ||
| 233 | /* | 193 | /* |
| 234 | * We need to set XFS_INEW atomically with clearing the | 194 | * We need to set XFS_INEW atomically with clearing the |
| @@ -254,9 +214,10 @@ xfs_iget_cache_hit( | |||
| 254 | ip->i_flags &= ~XFS_INEW; | 214 | ip->i_flags &= ~XFS_INEW; |
| 255 | ip->i_flags |= XFS_IRECLAIMABLE; | 215 | ip->i_flags |= XFS_IRECLAIMABLE; |
| 256 | __xfs_inode_set_reclaim_tag(pag, ip); | 216 | __xfs_inode_set_reclaim_tag(pag, ip); |
| 217 | trace_xfs_iget_reclaim(ip); | ||
| 257 | goto out_error; | 218 | goto out_error; |
| 258 | } | 219 | } |
| 259 | inode->i_state = I_LOCK|I_NEW; | 220 | inode->i_state = I_NEW; |
| 260 | } else { | 221 | } else { |
| 261 | /* If the VFS inode is being torn down, pause and try again. */ | 222 | /* If the VFS inode is being torn down, pause and try again. */ |
| 262 | if (!igrab(inode)) { | 223 | if (!igrab(inode)) { |
| @@ -273,8 +234,9 @@ xfs_iget_cache_hit( | |||
| 273 | xfs_ilock(ip, lock_flags); | 234 | xfs_ilock(ip, lock_flags); |
| 274 | 235 | ||
| 275 | xfs_iflags_clear(ip, XFS_ISTALE); | 236 | xfs_iflags_clear(ip, XFS_ISTALE); |
| 276 | xfs_itrace_exit_tag(ip, "xfs_iget.found"); | ||
| 277 | XFS_STATS_INC(xs_ig_found); | 237 | XFS_STATS_INC(xs_ig_found); |
| 238 | |||
| 239 | trace_xfs_iget_found(ip); | ||
| 278 | return 0; | 240 | return 0; |
| 279 | 241 | ||
| 280 | out_error: | 242 | out_error: |
| @@ -308,7 +270,7 @@ xfs_iget_cache_miss( | |||
| 308 | if (error) | 270 | if (error) |
| 309 | goto out_destroy; | 271 | goto out_destroy; |
| 310 | 272 | ||
| 311 | xfs_itrace_exit_tag(ip, "xfs_iget.alloc"); | 273 | xfs_itrace_entry(ip); |
| 312 | 274 | ||
| 313 | if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) { | 275 | if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) { |
| 314 | error = ENOENT; | 276 | error = ENOENT; |
| @@ -353,6 +315,8 @@ xfs_iget_cache_miss( | |||
| 353 | 315 | ||
| 354 | write_unlock(&pag->pag_ici_lock); | 316 | write_unlock(&pag->pag_ici_lock); |
| 355 | radix_tree_preload_end(); | 317 | radix_tree_preload_end(); |
| 318 | |||
| 319 | trace_xfs_iget_alloc(ip); | ||
| 356 | *ipp = ip; | 320 | *ipp = ip; |
| 357 | return 0; | 321 | return 0; |
| 358 | 322 | ||
| @@ -514,17 +478,21 @@ xfs_ireclaim( | |||
| 514 | { | 478 | { |
| 515 | struct xfs_mount *mp = ip->i_mount; | 479 | struct xfs_mount *mp = ip->i_mount; |
| 516 | struct xfs_perag *pag; | 480 | struct xfs_perag *pag; |
| 481 | xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino); | ||
| 517 | 482 | ||
| 518 | XFS_STATS_INC(xs_ig_reclaims); | 483 | XFS_STATS_INC(xs_ig_reclaims); |
| 519 | 484 | ||
| 520 | /* | 485 | /* |
| 521 | * Remove the inode from the per-AG radix tree. It doesn't matter | 486 | * Remove the inode from the per-AG radix tree. |
| 522 | * if it was never added to it because radix_tree_delete can deal | 487 | * |
| 523 | * with that case just fine. | 488 | * Because radix_tree_delete won't complain even if the item was never |
| 489 | * added to the tree assert that it's been there before to catch | ||
| 490 | * problems with the inode life time early on. | ||
| 524 | */ | 491 | */ |
| 525 | pag = xfs_get_perag(mp, ip->i_ino); | 492 | pag = xfs_get_perag(mp, ip->i_ino); |
| 526 | write_lock(&pag->pag_ici_lock); | 493 | write_lock(&pag->pag_ici_lock); |
| 527 | radix_tree_delete(&pag->pag_ici_root, XFS_INO_TO_AGINO(mp, ip->i_ino)); | 494 | if (!radix_tree_delete(&pag->pag_ici_root, agino)) |
| 495 | ASSERT(0); | ||
| 528 | write_unlock(&pag->pag_ici_lock); | 496 | write_unlock(&pag->pag_ici_lock); |
| 529 | xfs_put_perag(mp, pag); | 497 | xfs_put_perag(mp, pag); |
| 530 | 498 | ||
| @@ -639,7 +607,7 @@ xfs_ilock( | |||
| 639 | else if (lock_flags & XFS_ILOCK_SHARED) | 607 | else if (lock_flags & XFS_ILOCK_SHARED) |
| 640 | mraccess_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags)); | 608 | mraccess_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags)); |
| 641 | 609 | ||
| 642 | xfs_ilock_trace(ip, 1, lock_flags, (inst_t *)__return_address); | 610 | trace_xfs_ilock(ip, lock_flags, _RET_IP_); |
| 643 | } | 611 | } |
| 644 | 612 | ||
| 645 | /* | 613 | /* |
| @@ -684,7 +652,7 @@ xfs_ilock_nowait( | |||
| 684 | if (!mrtryaccess(&ip->i_lock)) | 652 | if (!mrtryaccess(&ip->i_lock)) |
| 685 | goto out_undo_iolock; | 653 | goto out_undo_iolock; |
| 686 | } | 654 | } |
| 687 | xfs_ilock_trace(ip, 2, lock_flags, (inst_t *)__return_address); | 655 | trace_xfs_ilock_nowait(ip, lock_flags, _RET_IP_); |
| 688 | return 1; | 656 | return 1; |
| 689 | 657 | ||
| 690 | out_undo_iolock: | 658 | out_undo_iolock: |
| @@ -746,7 +714,7 @@ xfs_iunlock( | |||
| 746 | xfs_trans_unlocked_item(ip->i_itemp->ili_item.li_ailp, | 714 | xfs_trans_unlocked_item(ip->i_itemp->ili_item.li_ailp, |
| 747 | (xfs_log_item_t*)(ip->i_itemp)); | 715 | (xfs_log_item_t*)(ip->i_itemp)); |
| 748 | } | 716 | } |
| 749 | xfs_ilock_trace(ip, 3, lock_flags, (inst_t *)__return_address); | 717 | trace_xfs_iunlock(ip, lock_flags, _RET_IP_); |
| 750 | } | 718 | } |
| 751 | 719 | ||
| 752 | /* | 720 | /* |
| @@ -765,6 +733,8 @@ xfs_ilock_demote( | |||
| 765 | mrdemote(&ip->i_lock); | 733 | mrdemote(&ip->i_lock); |
| 766 | if (lock_flags & XFS_IOLOCK_EXCL) | 734 | if (lock_flags & XFS_IOLOCK_EXCL) |
| 767 | mrdemote(&ip->i_iolock); | 735 | mrdemote(&ip->i_iolock); |
| 736 | |||
| 737 | trace_xfs_ilock_demote(ip, lock_flags, _RET_IP_); | ||
| 768 | } | 738 | } |
| 769 | 739 | ||
| 770 | #ifdef DEBUG | 740 | #ifdef DEBUG |
| @@ -795,52 +765,3 @@ xfs_isilocked( | |||
| 795 | return 1; | 765 | return 1; |
| 796 | } | 766 | } |
| 797 | #endif | 767 | #endif |
| 798 | |||
| 799 | #ifdef XFS_INODE_TRACE | ||
| 800 | |||
| 801 | #define KTRACE_ENTER(ip, vk, s, line, ra) \ | ||
| 802 | ktrace_enter((ip)->i_trace, \ | ||
| 803 | /* 0 */ (void *)(__psint_t)(vk), \ | ||
| 804 | /* 1 */ (void *)(s), \ | ||
| 805 | /* 2 */ (void *)(__psint_t) line, \ | ||
| 806 | /* 3 */ (void *)(__psint_t)atomic_read(&VFS_I(ip)->i_count), \ | ||
| 807 | /* 4 */ (void *)(ra), \ | ||
| 808 | /* 5 */ NULL, \ | ||
| 809 | /* 6 */ (void *)(__psint_t)current_cpu(), \ | ||
| 810 | /* 7 */ (void *)(__psint_t)current_pid(), \ | ||
| 811 | /* 8 */ (void *)__return_address, \ | ||
| 812 | /* 9 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL) | ||
| 813 | |||
| 814 | /* | ||
| 815 | * Vnode tracing code. | ||
| 816 | */ | ||
| 817 | void | ||
| 818 | _xfs_itrace_entry(xfs_inode_t *ip, const char *func, inst_t *ra) | ||
| 819 | { | ||
| 820 | KTRACE_ENTER(ip, INODE_KTRACE_ENTRY, func, 0, ra); | ||
| 821 | } | ||
| 822 | |||
| 823 | void | ||
| 824 | _xfs_itrace_exit(xfs_inode_t *ip, const char *func, inst_t *ra) | ||
| 825 | { | ||
| 826 | KTRACE_ENTER(ip, INODE_KTRACE_EXIT, func, 0, ra); | ||
| 827 | } | ||
| 828 | |||
| 829 | void | ||
| 830 | xfs_itrace_hold(xfs_inode_t *ip, char *file, int line, inst_t *ra) | ||
| 831 | { | ||
| 832 | KTRACE_ENTER(ip, INODE_KTRACE_HOLD, file, line, ra); | ||
| 833 | } | ||
| 834 | |||
| 835 | void | ||
| 836 | _xfs_itrace_ref(xfs_inode_t *ip, char *file, int line, inst_t *ra) | ||
| 837 | { | ||
| 838 | KTRACE_ENTER(ip, INODE_KTRACE_REF, file, line, ra); | ||
| 839 | } | ||
| 840 | |||
| 841 | void | ||
| 842 | xfs_itrace_rele(xfs_inode_t *ip, char *file, int line, inst_t *ra) | ||
| 843 | { | ||
| 844 | KTRACE_ENTER(ip, INODE_KTRACE_RELE, file, line, ra); | ||
| 845 | } | ||
| 846 | #endif /* XFS_INODE_TRACE */ | ||
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index b92a4fa2a0a1..ce278b3ae7fc 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
| @@ -47,10 +47,10 @@ | |||
| 47 | #include "xfs_rw.h" | 47 | #include "xfs_rw.h" |
| 48 | #include "xfs_error.h" | 48 | #include "xfs_error.h" |
| 49 | #include "xfs_utils.h" | 49 | #include "xfs_utils.h" |
| 50 | #include "xfs_dir2_trace.h" | ||
| 51 | #include "xfs_quota.h" | 50 | #include "xfs_quota.h" |
| 52 | #include "xfs_filestream.h" | 51 | #include "xfs_filestream.h" |
| 53 | #include "xfs_vnodeops.h" | 52 | #include "xfs_vnodeops.h" |
| 53 | #include "xfs_trace.h" | ||
| 54 | 54 | ||
| 55 | kmem_zone_t *xfs_ifork_zone; | 55 | kmem_zone_t *xfs_ifork_zone; |
| 56 | kmem_zone_t *xfs_inode_zone; | 56 | kmem_zone_t *xfs_inode_zone; |
| @@ -1291,42 +1291,6 @@ xfs_file_last_byte( | |||
| 1291 | return last_byte; | 1291 | return last_byte; |
| 1292 | } | 1292 | } |
| 1293 | 1293 | ||
| 1294 | #if defined(XFS_RW_TRACE) | ||
| 1295 | STATIC void | ||
| 1296 | xfs_itrunc_trace( | ||
| 1297 | int tag, | ||
| 1298 | xfs_inode_t *ip, | ||
| 1299 | int flag, | ||
| 1300 | xfs_fsize_t new_size, | ||
| 1301 | xfs_off_t toss_start, | ||
| 1302 | xfs_off_t toss_finish) | ||
| 1303 | { | ||
| 1304 | if (ip->i_rwtrace == NULL) { | ||
| 1305 | return; | ||
| 1306 | } | ||
| 1307 | |||
| 1308 | ktrace_enter(ip->i_rwtrace, | ||
| 1309 | (void*)((long)tag), | ||
| 1310 | (void*)ip, | ||
| 1311 | (void*)(unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff), | ||
| 1312 | (void*)(unsigned long)(ip->i_d.di_size & 0xffffffff), | ||
| 1313 | (void*)((long)flag), | ||
| 1314 | (void*)(unsigned long)((new_size >> 32) & 0xffffffff), | ||
| 1315 | (void*)(unsigned long)(new_size & 0xffffffff), | ||
| 1316 | (void*)(unsigned long)((toss_start >> 32) & 0xffffffff), | ||
| 1317 | (void*)(unsigned long)(toss_start & 0xffffffff), | ||
| 1318 | (void*)(unsigned long)((toss_finish >> 32) & 0xffffffff), | ||
| 1319 | (void*)(unsigned long)(toss_finish & 0xffffffff), | ||
| 1320 | (void*)(unsigned long)current_cpu(), | ||
| 1321 | (void*)(unsigned long)current_pid(), | ||
| 1322 | (void*)NULL, | ||
| 1323 | (void*)NULL, | ||
| 1324 | (void*)NULL); | ||
| 1325 | } | ||
| 1326 | #else | ||
| 1327 | #define xfs_itrunc_trace(tag, ip, flag, new_size, toss_start, toss_finish) | ||
| 1328 | #endif | ||
| 1329 | |||
| 1330 | /* | 1294 | /* |
| 1331 | * Start the truncation of the file to new_size. The new size | 1295 | * Start the truncation of the file to new_size. The new size |
| 1332 | * must be smaller than the current size. This routine will | 1296 | * must be smaller than the current size. This routine will |
| @@ -1409,8 +1373,7 @@ xfs_itruncate_start( | |||
| 1409 | return 0; | 1373 | return 0; |
| 1410 | } | 1374 | } |
| 1411 | last_byte = xfs_file_last_byte(ip); | 1375 | last_byte = xfs_file_last_byte(ip); |
| 1412 | xfs_itrunc_trace(XFS_ITRUNC_START, ip, flags, new_size, toss_start, | 1376 | trace_xfs_itruncate_start(ip, flags, new_size, toss_start, last_byte); |
| 1413 | last_byte); | ||
| 1414 | if (last_byte > toss_start) { | 1377 | if (last_byte > toss_start) { |
| 1415 | if (flags & XFS_ITRUNC_DEFINITE) { | 1378 | if (flags & XFS_ITRUNC_DEFINITE) { |
| 1416 | xfs_tosspages(ip, toss_start, | 1379 | xfs_tosspages(ip, toss_start, |
| @@ -1514,7 +1477,8 @@ xfs_itruncate_finish( | |||
| 1514 | new_size = 0LL; | 1477 | new_size = 0LL; |
| 1515 | } | 1478 | } |
| 1516 | first_unmap_block = XFS_B_TO_FSB(mp, (xfs_ufsize_t)new_size); | 1479 | first_unmap_block = XFS_B_TO_FSB(mp, (xfs_ufsize_t)new_size); |
| 1517 | xfs_itrunc_trace(XFS_ITRUNC_FINISH1, ip, 0, new_size, 0, 0); | 1480 | trace_xfs_itruncate_finish_start(ip, new_size); |
| 1481 | |||
| 1518 | /* | 1482 | /* |
| 1519 | * The first thing we do is set the size to new_size permanently | 1483 | * The first thing we do is set the size to new_size permanently |
| 1520 | * on disk. This way we don't have to worry about anyone ever | 1484 | * on disk. This way we don't have to worry about anyone ever |
| @@ -1731,7 +1695,7 @@ xfs_itruncate_finish( | |||
| 1731 | ASSERT((new_size != 0) || | 1695 | ASSERT((new_size != 0) || |
| 1732 | (fork == XFS_ATTR_FORK) || | 1696 | (fork == XFS_ATTR_FORK) || |
| 1733 | (ip->i_d.di_nextents == 0)); | 1697 | (ip->i_d.di_nextents == 0)); |
| 1734 | xfs_itrunc_trace(XFS_ITRUNC_FINISH2, ip, 0, new_size, 0, 0); | 1698 | trace_xfs_itruncate_finish_end(ip, new_size); |
| 1735 | return 0; | 1699 | return 0; |
| 1736 | } | 1700 | } |
| 1737 | 1701 | ||
| @@ -3252,23 +3216,6 @@ corrupt_out: | |||
| 3252 | return XFS_ERROR(EFSCORRUPTED); | 3216 | return XFS_ERROR(EFSCORRUPTED); |
| 3253 | } | 3217 | } |
| 3254 | 3218 | ||
| 3255 | |||
| 3256 | |||
| 3257 | #ifdef XFS_ILOCK_TRACE | ||
| 3258 | void | ||
| 3259 | xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags, inst_t *ra) | ||
| 3260 | { | ||
| 3261 | ktrace_enter(ip->i_lock_trace, | ||
| 3262 | (void *)ip, | ||
| 3263 | (void *)(unsigned long)lock, /* 1 = LOCK, 3=UNLOCK, etc */ | ||
| 3264 | (void *)(unsigned long)lockflags, /* XFS_ILOCK_EXCL etc */ | ||
| 3265 | (void *)ra, /* caller of ilock */ | ||
| 3266 | (void *)(unsigned long)current_cpu(), | ||
| 3267 | (void *)(unsigned long)current_pid(), | ||
| 3268 | NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); | ||
| 3269 | } | ||
| 3270 | #endif | ||
| 3271 | |||
| 3272 | /* | 3219 | /* |
| 3273 | * Return a pointer to the extent record at file index idx. | 3220 | * Return a pointer to the extent record at file index idx. |
| 3274 | */ | 3221 | */ |
| @@ -3300,13 +3247,17 @@ xfs_iext_get_ext( | |||
| 3300 | */ | 3247 | */ |
| 3301 | void | 3248 | void |
| 3302 | xfs_iext_insert( | 3249 | xfs_iext_insert( |
| 3303 | xfs_ifork_t *ifp, /* inode fork pointer */ | 3250 | xfs_inode_t *ip, /* incore inode pointer */ |
| 3304 | xfs_extnum_t idx, /* starting index of new items */ | 3251 | xfs_extnum_t idx, /* starting index of new items */ |
| 3305 | xfs_extnum_t count, /* number of inserted items */ | 3252 | xfs_extnum_t count, /* number of inserted items */ |
| 3306 | xfs_bmbt_irec_t *new) /* items to insert */ | 3253 | xfs_bmbt_irec_t *new, /* items to insert */ |
| 3254 | int state) /* type of extent conversion */ | ||
| 3307 | { | 3255 | { |
| 3256 | xfs_ifork_t *ifp = (state & BMAP_ATTRFORK) ? ip->i_afp : &ip->i_df; | ||
| 3308 | xfs_extnum_t i; /* extent record index */ | 3257 | xfs_extnum_t i; /* extent record index */ |
| 3309 | 3258 | ||
| 3259 | trace_xfs_iext_insert(ip, idx, new, state, _RET_IP_); | ||
| 3260 | |||
| 3310 | ASSERT(ifp->if_flags & XFS_IFEXTENTS); | 3261 | ASSERT(ifp->if_flags & XFS_IFEXTENTS); |
| 3311 | xfs_iext_add(ifp, idx, count); | 3262 | xfs_iext_add(ifp, idx, count); |
| 3312 | for (i = idx; i < idx + count; i++, new++) | 3263 | for (i = idx; i < idx + count; i++, new++) |
| @@ -3549,13 +3500,17 @@ xfs_iext_add_indirect_multi( | |||
| 3549 | */ | 3500 | */ |
| 3550 | void | 3501 | void |
| 3551 | xfs_iext_remove( | 3502 | xfs_iext_remove( |
| 3552 | xfs_ifork_t *ifp, /* inode fork pointer */ | 3503 | xfs_inode_t *ip, /* incore inode pointer */ |
| 3553 | xfs_extnum_t idx, /* index to begin removing exts */ | 3504 | xfs_extnum_t idx, /* index to begin removing exts */ |
| 3554 | int ext_diff) /* number of extents to remove */ | 3505 | int ext_diff, /* number of extents to remove */ |
| 3506 | int state) /* type of extent conversion */ | ||
| 3555 | { | 3507 | { |
| 3508 | xfs_ifork_t *ifp = (state & BMAP_ATTRFORK) ? ip->i_afp : &ip->i_df; | ||
| 3556 | xfs_extnum_t nextents; /* number of extents in file */ | 3509 | xfs_extnum_t nextents; /* number of extents in file */ |
| 3557 | int new_size; /* size of extents after removal */ | 3510 | int new_size; /* size of extents after removal */ |
| 3558 | 3511 | ||
| 3512 | trace_xfs_iext_remove(ip, idx, state, _RET_IP_); | ||
| 3513 | |||
| 3559 | ASSERT(ext_diff > 0); | 3514 | ASSERT(ext_diff > 0); |
| 3560 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); | 3515 | nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t); |
| 3561 | new_size = (nextents - ext_diff) * sizeof(xfs_bmbt_rec_t); | 3516 | new_size = (nextents - ext_diff) * sizeof(xfs_bmbt_rec_t); |
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 41555de1d1db..ec1f28c4fc4f 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h | |||
| @@ -213,7 +213,6 @@ typedef struct xfs_icdinode { | |||
| 213 | 213 | ||
| 214 | struct bhv_desc; | 214 | struct bhv_desc; |
| 215 | struct cred; | 215 | struct cred; |
| 216 | struct ktrace; | ||
| 217 | struct xfs_buf; | 216 | struct xfs_buf; |
| 218 | struct xfs_bmap_free; | 217 | struct xfs_bmap_free; |
| 219 | struct xfs_bmbt_irec; | 218 | struct xfs_bmbt_irec; |
| @@ -222,13 +221,6 @@ struct xfs_mount; | |||
| 222 | struct xfs_trans; | 221 | struct xfs_trans; |
| 223 | struct xfs_dquot; | 222 | struct xfs_dquot; |
| 224 | 223 | ||
| 225 | #if defined(XFS_ILOCK_TRACE) | ||
| 226 | #define XFS_ILOCK_KTRACE_SIZE 32 | ||
| 227 | extern void xfs_ilock_trace(struct xfs_inode *, int, unsigned int, inst_t *); | ||
| 228 | #else | ||
| 229 | #define xfs_ilock_trace(i,n,f,ra) | ||
| 230 | #endif | ||
| 231 | |||
| 232 | typedef struct dm_attrs_s { | 224 | typedef struct dm_attrs_s { |
| 233 | __uint32_t da_dmevmask; /* DMIG event mask */ | 225 | __uint32_t da_dmevmask; /* DMIG event mask */ |
| 234 | __uint16_t da_dmstate; /* DMIG state info */ | 226 | __uint16_t da_dmstate; /* DMIG state info */ |
| @@ -271,26 +263,6 @@ typedef struct xfs_inode { | |||
| 271 | 263 | ||
| 272 | /* VFS inode */ | 264 | /* VFS inode */ |
| 273 | struct inode i_vnode; /* embedded VFS inode */ | 265 | struct inode i_vnode; /* embedded VFS inode */ |
| 274 | |||
| 275 | /* Trace buffers per inode. */ | ||
| 276 | #ifdef XFS_INODE_TRACE | ||
| 277 | struct ktrace *i_trace; /* general inode trace */ | ||
| 278 | #endif | ||
| 279 | #ifdef XFS_BMAP_TRACE | ||
| 280 | struct ktrace *i_xtrace; /* inode extent list trace */ | ||
| 281 | #endif | ||
| 282 | #ifdef XFS_BTREE_TRACE | ||
| 283 | struct ktrace *i_btrace; /* inode bmap btree trace */ | ||
| 284 | #endif | ||
| 285 | #ifdef XFS_RW_TRACE | ||
| 286 | struct ktrace *i_rwtrace; /* inode read/write trace */ | ||
| 287 | #endif | ||
| 288 | #ifdef XFS_ILOCK_TRACE | ||
| 289 | struct ktrace *i_lock_trace; /* inode lock/unlock trace */ | ||
| 290 | #endif | ||
| 291 | #ifdef XFS_DIR2_TRACE | ||
| 292 | struct ktrace *i_dir_trace; /* inode directory trace */ | ||
| 293 | #endif | ||
| 294 | } xfs_inode_t; | 266 | } xfs_inode_t; |
| 295 | 267 | ||
| 296 | #define XFS_ISIZE(ip) (((ip)->i_d.di_mode & S_IFMT) == S_IFREG) ? \ | 268 | #define XFS_ISIZE(ip) (((ip)->i_d.di_mode & S_IFMT) == S_IFREG) ? \ |
| @@ -406,6 +378,14 @@ static inline void xfs_ifunlock(xfs_inode_t *ip) | |||
| 406 | #define XFS_LOCK_MASK (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED \ | 378 | #define XFS_LOCK_MASK (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED \ |
| 407 | | XFS_ILOCK_EXCL | XFS_ILOCK_SHARED) | 379 | | XFS_ILOCK_EXCL | XFS_ILOCK_SHARED) |
| 408 | 380 | ||
| 381 | #define XFS_LOCK_FLAGS \ | ||
| 382 | { XFS_IOLOCK_EXCL, "IOLOCK_EXCL" }, \ | ||
| 383 | { XFS_IOLOCK_SHARED, "IOLOCK_SHARED" }, \ | ||
| 384 | { XFS_ILOCK_EXCL, "ILOCK_EXCL" }, \ | ||
| 385 | { XFS_ILOCK_SHARED, "ILOCK_SHARED" }, \ | ||
| 386 | { XFS_IUNLOCK_NONOTIFY, "IUNLOCK_NONOTIFY" } | ||
| 387 | |||
| 388 | |||
| 409 | /* | 389 | /* |
| 410 | * Flags for lockdep annotations. | 390 | * Flags for lockdep annotations. |
| 411 | * | 391 | * |
| @@ -455,6 +435,10 @@ static inline void xfs_ifunlock(xfs_inode_t *ip) | |||
| 455 | #define XFS_ITRUNC_DEFINITE 0x1 | 435 | #define XFS_ITRUNC_DEFINITE 0x1 |
| 456 | #define XFS_ITRUNC_MAYBE 0x2 | 436 | #define XFS_ITRUNC_MAYBE 0x2 |
| 457 | 437 | ||
| 438 | #define XFS_ITRUNC_FLAGS \ | ||
| 439 | { XFS_ITRUNC_DEFINITE, "DEFINITE" }, \ | ||
| 440 | { XFS_ITRUNC_MAYBE, "MAYBE" } | ||
| 441 | |||
| 458 | /* | 442 | /* |
| 459 | * For multiple groups support: if S_ISGID bit is set in the parent | 443 | * For multiple groups support: if S_ISGID bit is set in the parent |
| 460 | * directory, group of new file is set to that of the parent, and | 444 | * directory, group of new file is set to that of the parent, and |
| @@ -507,48 +491,16 @@ void xfs_lock_two_inodes(xfs_inode_t *, xfs_inode_t *, uint); | |||
| 507 | void xfs_synchronize_times(xfs_inode_t *); | 491 | void xfs_synchronize_times(xfs_inode_t *); |
| 508 | void xfs_mark_inode_dirty_sync(xfs_inode_t *); | 492 | void xfs_mark_inode_dirty_sync(xfs_inode_t *); |
| 509 | 493 | ||
| 510 | #if defined(XFS_INODE_TRACE) | ||
| 511 | |||
| 512 | #define INODE_TRACE_SIZE 16 /* number of trace entries */ | ||
| 513 | #define INODE_KTRACE_ENTRY 1 | ||
| 514 | #define INODE_KTRACE_EXIT 2 | ||
| 515 | #define INODE_KTRACE_HOLD 3 | ||
| 516 | #define INODE_KTRACE_REF 4 | ||
| 517 | #define INODE_KTRACE_RELE 5 | ||
| 518 | |||
| 519 | extern void _xfs_itrace_entry(struct xfs_inode *, const char *, inst_t *); | ||
| 520 | extern void _xfs_itrace_exit(struct xfs_inode *, const char *, inst_t *); | ||
| 521 | extern void xfs_itrace_hold(struct xfs_inode *, char *, int, inst_t *); | ||
| 522 | extern void _xfs_itrace_ref(struct xfs_inode *, char *, int, inst_t *); | ||
| 523 | extern void xfs_itrace_rele(struct xfs_inode *, char *, int, inst_t *); | ||
| 524 | #define xfs_itrace_entry(ip) \ | ||
| 525 | _xfs_itrace_entry(ip, __func__, (inst_t *)__return_address) | ||
| 526 | #define xfs_itrace_exit(ip) \ | ||
| 527 | _xfs_itrace_exit(ip, __func__, (inst_t *)__return_address) | ||
| 528 | #define xfs_itrace_exit_tag(ip, tag) \ | ||
| 529 | _xfs_itrace_exit(ip, tag, (inst_t *)__return_address) | ||
| 530 | #define xfs_itrace_ref(ip) \ | ||
| 531 | _xfs_itrace_ref(ip, __FILE__, __LINE__, (inst_t *)__return_address) | ||
| 532 | |||
| 533 | #else | ||
| 534 | #define xfs_itrace_entry(a) | ||
| 535 | #define xfs_itrace_exit(a) | ||
| 536 | #define xfs_itrace_exit_tag(a, b) | ||
| 537 | #define xfs_itrace_hold(a, b, c, d) | ||
| 538 | #define xfs_itrace_ref(a) | ||
| 539 | #define xfs_itrace_rele(a, b, c, d) | ||
| 540 | #endif | ||
| 541 | |||
| 542 | #define IHOLD(ip) \ | 494 | #define IHOLD(ip) \ |
| 543 | do { \ | 495 | do { \ |
| 544 | ASSERT(atomic_read(&VFS_I(ip)->i_count) > 0) ; \ | 496 | ASSERT(atomic_read(&VFS_I(ip)->i_count) > 0) ; \ |
| 545 | atomic_inc(&(VFS_I(ip)->i_count)); \ | 497 | atomic_inc(&(VFS_I(ip)->i_count)); \ |
| 546 | xfs_itrace_hold((ip), __FILE__, __LINE__, (inst_t *)__return_address); \ | 498 | trace_xfs_ihold(ip, _THIS_IP_); \ |
| 547 | } while (0) | 499 | } while (0) |
| 548 | 500 | ||
| 549 | #define IRELE(ip) \ | 501 | #define IRELE(ip) \ |
| 550 | do { \ | 502 | do { \ |
| 551 | xfs_itrace_rele((ip), __FILE__, __LINE__, (inst_t *)__return_address); \ | 503 | trace_xfs_irele(ip, _THIS_IP_); \ |
| 552 | iput(VFS_I(ip)); \ | 504 | iput(VFS_I(ip)); \ |
| 553 | } while (0) | 505 | } while (0) |
| 554 | 506 | ||
| @@ -577,11 +529,11 @@ int xfs_iread_extents(struct xfs_trans *, struct xfs_inode *, int); | |||
| 577 | int xfs_iextents_copy(struct xfs_inode *, xfs_bmbt_rec_t *, int); | 529 | int xfs_iextents_copy(struct xfs_inode *, xfs_bmbt_rec_t *, int); |
| 578 | 530 | ||
| 579 | xfs_bmbt_rec_host_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t); | 531 | xfs_bmbt_rec_host_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t); |
| 580 | void xfs_iext_insert(xfs_ifork_t *, xfs_extnum_t, xfs_extnum_t, | 532 | void xfs_iext_insert(xfs_inode_t *, xfs_extnum_t, xfs_extnum_t, |
| 581 | xfs_bmbt_irec_t *); | 533 | xfs_bmbt_irec_t *, int); |
| 582 | void xfs_iext_add(xfs_ifork_t *, xfs_extnum_t, int); | 534 | void xfs_iext_add(xfs_ifork_t *, xfs_extnum_t, int); |
| 583 | void xfs_iext_add_indirect_multi(xfs_ifork_t *, int, xfs_extnum_t, int); | 535 | void xfs_iext_add_indirect_multi(xfs_ifork_t *, int, xfs_extnum_t, int); |
| 584 | void xfs_iext_remove(xfs_ifork_t *, xfs_extnum_t, int); | 536 | void xfs_iext_remove(xfs_inode_t *, xfs_extnum_t, int, int); |
| 585 | void xfs_iext_remove_inline(xfs_ifork_t *, xfs_extnum_t, int); | 537 | void xfs_iext_remove_inline(xfs_ifork_t *, xfs_extnum_t, int); |
| 586 | void xfs_iext_remove_direct(xfs_ifork_t *, xfs_extnum_t, int); | 538 | void xfs_iext_remove_direct(xfs_ifork_t *, xfs_extnum_t, int); |
| 587 | void xfs_iext_remove_indirect(xfs_ifork_t *, xfs_extnum_t, int); | 539 | void xfs_iext_remove_indirect(xfs_ifork_t *, xfs_extnum_t, int); |
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index 9794b876d6ff..f38855d21ea5 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c | |||
| @@ -41,6 +41,7 @@ | |||
| 41 | #include "xfs_ialloc.h" | 41 | #include "xfs_ialloc.h" |
| 42 | #include "xfs_rw.h" | 42 | #include "xfs_rw.h" |
| 43 | #include "xfs_error.h" | 43 | #include "xfs_error.h" |
| 44 | #include "xfs_trace.h" | ||
| 44 | 45 | ||
| 45 | 46 | ||
| 46 | kmem_zone_t *xfs_ili_zone; /* inode log item zone */ | 47 | kmem_zone_t *xfs_ili_zone; /* inode log item zone */ |
| @@ -800,7 +801,9 @@ xfs_inode_item_pushbuf( | |||
| 800 | !completion_done(&ip->i_flush)); | 801 | !completion_done(&ip->i_flush)); |
| 801 | iip->ili_pushbuf_flag = 0; | 802 | iip->ili_pushbuf_flag = 0; |
| 802 | xfs_iunlock(ip, XFS_ILOCK_SHARED); | 803 | xfs_iunlock(ip, XFS_ILOCK_SHARED); |
| 803 | xfs_buftrace("INODE ITEM PUSH", bp); | 804 | |
| 805 | trace_xfs_inode_item_push(bp, _RET_IP_); | ||
| 806 | |||
| 804 | if (XFS_BUF_ISPINNED(bp)) { | 807 | if (XFS_BUF_ISPINNED(bp)) { |
| 805 | xfs_log_force(mp, (xfs_lsn_t)0, | 808 | xfs_log_force(mp, (xfs_lsn_t)0, |
| 806 | XFS_LOG_FORCE); | 809 | XFS_LOG_FORCE); |
diff --git a/fs/xfs/xfs_inode_item.h b/fs/xfs/xfs_inode_item.h index 65bae4c9b8bf..cc8df1ac7783 100644 --- a/fs/xfs/xfs_inode_item.h +++ b/fs/xfs/xfs_inode_item.h | |||
| @@ -127,7 +127,7 @@ static inline int xfs_ilog_fdata(int w) | |||
| 127 | #ifdef __KERNEL__ | 127 | #ifdef __KERNEL__ |
| 128 | 128 | ||
| 129 | struct xfs_buf; | 129 | struct xfs_buf; |
| 130 | struct xfs_bmbt_rec_64; | 130 | struct xfs_bmbt_rec; |
| 131 | struct xfs_inode; | 131 | struct xfs_inode; |
| 132 | struct xfs_mount; | 132 | struct xfs_mount; |
| 133 | 133 | ||
| @@ -140,9 +140,9 @@ typedef struct xfs_inode_log_item { | |||
| 140 | unsigned short ili_flags; /* misc flags */ | 140 | unsigned short ili_flags; /* misc flags */ |
| 141 | unsigned short ili_logged; /* flushed logged data */ | 141 | unsigned short ili_logged; /* flushed logged data */ |
| 142 | unsigned int ili_last_fields; /* fields when flushed */ | 142 | unsigned int ili_last_fields; /* fields when flushed */ |
| 143 | struct xfs_bmbt_rec_64 *ili_extents_buf; /* array of logged | 143 | struct xfs_bmbt_rec *ili_extents_buf; /* array of logged |
| 144 | data exts */ | 144 | data exts */ |
| 145 | struct xfs_bmbt_rec_64 *ili_aextents_buf; /* array of logged | 145 | struct xfs_bmbt_rec *ili_aextents_buf; /* array of logged |
| 146 | attr exts */ | 146 | attr exts */ |
| 147 | unsigned int ili_pushbuf_flag; /* one bit used in push_ail */ | 147 | unsigned int ili_pushbuf_flag; /* one bit used in push_ail */ |
| 148 | 148 | ||
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 7294abce6ef2..0b65039951a0 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
| @@ -47,72 +47,8 @@ | |||
| 47 | #include "xfs_trans_space.h" | 47 | #include "xfs_trans_space.h" |
| 48 | #include "xfs_utils.h" | 48 | #include "xfs_utils.h" |
| 49 | #include "xfs_iomap.h" | 49 | #include "xfs_iomap.h" |
| 50 | #include "xfs_trace.h" | ||
| 50 | 51 | ||
| 51 | #if defined(XFS_RW_TRACE) | ||
| 52 | void | ||
| 53 | xfs_iomap_enter_trace( | ||
| 54 | int tag, | ||
| 55 | xfs_inode_t *ip, | ||
| 56 | xfs_off_t offset, | ||
| 57 | ssize_t count) | ||
| 58 | { | ||
| 59 | if (!ip->i_rwtrace) | ||
| 60 | return; | ||
| 61 | |||
| 62 | ktrace_enter(ip->i_rwtrace, | ||
| 63 | (void *)((unsigned long)tag), | ||
| 64 | (void *)ip, | ||
| 65 | (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)), | ||
| 66 | (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)), | ||
| 67 | (void *)((unsigned long)((offset >> 32) & 0xffffffff)), | ||
| 68 | (void *)((unsigned long)(offset & 0xffffffff)), | ||
| 69 | (void *)((unsigned long)count), | ||
| 70 | (void *)((unsigned long)((ip->i_new_size >> 32) & 0xffffffff)), | ||
| 71 | (void *)((unsigned long)(ip->i_new_size & 0xffffffff)), | ||
| 72 | (void *)((unsigned long)current_pid()), | ||
| 73 | (void *)NULL, | ||
| 74 | (void *)NULL, | ||
| 75 | (void *)NULL, | ||
| 76 | (void *)NULL, | ||
| 77 | (void *)NULL, | ||
| 78 | (void *)NULL); | ||
| 79 | } | ||
| 80 | |||
| 81 | void | ||
| 82 | xfs_iomap_map_trace( | ||
| 83 | int tag, | ||
| 84 | xfs_inode_t *ip, | ||
| 85 | xfs_off_t offset, | ||
| 86 | ssize_t count, | ||
| 87 | xfs_iomap_t *iomapp, | ||
| 88 | xfs_bmbt_irec_t *imapp, | ||
| 89 | int flags) | ||
| 90 | { | ||
| 91 | if (!ip->i_rwtrace) | ||
| 92 | return; | ||
| 93 | |||
| 94 | ktrace_enter(ip->i_rwtrace, | ||
| 95 | (void *)((unsigned long)tag), | ||
| 96 | (void *)ip, | ||
| 97 | (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)), | ||
| 98 | (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)), | ||
| 99 | (void *)((unsigned long)((offset >> 32) & 0xffffffff)), | ||
| 100 | (void *)((unsigned long)(offset & 0xffffffff)), | ||
| 101 | (void *)((unsigned long)count), | ||
| 102 | (void *)((unsigned long)flags), | ||
| 103 | (void *)((unsigned long)((iomapp->iomap_offset >> 32) & 0xffffffff)), | ||
| 104 | (void *)((unsigned long)(iomapp->iomap_offset & 0xffffffff)), | ||
| 105 | (void *)((unsigned long)(iomapp->iomap_delta)), | ||
| 106 | (void *)((unsigned long)(iomapp->iomap_bsize)), | ||
| 107 | (void *)((unsigned long)(iomapp->iomap_bn)), | ||
| 108 | (void *)(__psint_t)(imapp->br_startoff), | ||
| 109 | (void *)((unsigned long)(imapp->br_blockcount)), | ||
| 110 | (void *)(__psint_t)(imapp->br_startblock)); | ||
| 111 | } | ||
| 112 | #else | ||
| 113 | #define xfs_iomap_enter_trace(tag, io, offset, count) | ||
| 114 | #define xfs_iomap_map_trace(tag, io, offset, count, iomapp, imapp, flags) | ||
| 115 | #endif | ||
| 116 | 52 | ||
| 117 | #define XFS_WRITEIO_ALIGN(mp,off) (((off) >> mp->m_writeio_log) \ | 53 | #define XFS_WRITEIO_ALIGN(mp,off) (((off) >> mp->m_writeio_log) \ |
| 118 | << mp->m_writeio_log) | 54 | << mp->m_writeio_log) |
| @@ -187,21 +123,20 @@ xfs_iomap( | |||
| 187 | if (XFS_FORCED_SHUTDOWN(mp)) | 123 | if (XFS_FORCED_SHUTDOWN(mp)) |
| 188 | return XFS_ERROR(EIO); | 124 | return XFS_ERROR(EIO); |
| 189 | 125 | ||
| 126 | trace_xfs_iomap_enter(ip, offset, count, flags, NULL); | ||
| 127 | |||
| 190 | switch (flags & (BMAPI_READ | BMAPI_WRITE | BMAPI_ALLOCATE)) { | 128 | switch (flags & (BMAPI_READ | BMAPI_WRITE | BMAPI_ALLOCATE)) { |
| 191 | case BMAPI_READ: | 129 | case BMAPI_READ: |
| 192 | xfs_iomap_enter_trace(XFS_IOMAP_READ_ENTER, ip, offset, count); | ||
| 193 | lockmode = xfs_ilock_map_shared(ip); | 130 | lockmode = xfs_ilock_map_shared(ip); |
| 194 | bmapi_flags = XFS_BMAPI_ENTIRE; | 131 | bmapi_flags = XFS_BMAPI_ENTIRE; |
| 195 | break; | 132 | break; |
| 196 | case BMAPI_WRITE: | 133 | case BMAPI_WRITE: |
| 197 | xfs_iomap_enter_trace(XFS_IOMAP_WRITE_ENTER, ip, offset, count); | ||
| 198 | lockmode = XFS_ILOCK_EXCL; | 134 | lockmode = XFS_ILOCK_EXCL; |
| 199 | if (flags & BMAPI_IGNSTATE) | 135 | if (flags & BMAPI_IGNSTATE) |
| 200 | bmapi_flags |= XFS_BMAPI_IGSTATE|XFS_BMAPI_ENTIRE; | 136 | bmapi_flags |= XFS_BMAPI_IGSTATE|XFS_BMAPI_ENTIRE; |
| 201 | xfs_ilock(ip, lockmode); | 137 | xfs_ilock(ip, lockmode); |
| 202 | break; | 138 | break; |
| 203 | case BMAPI_ALLOCATE: | 139 | case BMAPI_ALLOCATE: |
| 204 | xfs_iomap_enter_trace(XFS_IOMAP_ALLOC_ENTER, ip, offset, count); | ||
| 205 | lockmode = XFS_ILOCK_SHARED; | 140 | lockmode = XFS_ILOCK_SHARED; |
| 206 | bmapi_flags = XFS_BMAPI_ENTIRE; | 141 | bmapi_flags = XFS_BMAPI_ENTIRE; |
| 207 | 142 | ||
| @@ -237,8 +172,7 @@ xfs_iomap( | |||
| 237 | if (nimaps && | 172 | if (nimaps && |
| 238 | (imap.br_startblock != HOLESTARTBLOCK) && | 173 | (imap.br_startblock != HOLESTARTBLOCK) && |
| 239 | (imap.br_startblock != DELAYSTARTBLOCK)) { | 174 | (imap.br_startblock != DELAYSTARTBLOCK)) { |
| 240 | xfs_iomap_map_trace(XFS_IOMAP_WRITE_MAP, ip, | 175 | trace_xfs_iomap_found(ip, offset, count, flags, &imap); |
| 241 | offset, count, iomapp, &imap, flags); | ||
| 242 | break; | 176 | break; |
| 243 | } | 177 | } |
| 244 | 178 | ||
| @@ -250,8 +184,7 @@ xfs_iomap( | |||
| 250 | &imap, &nimaps); | 184 | &imap, &nimaps); |
| 251 | } | 185 | } |
| 252 | if (!error) { | 186 | if (!error) { |
| 253 | xfs_iomap_map_trace(XFS_IOMAP_ALLOC_MAP, ip, | 187 | trace_xfs_iomap_alloc(ip, offset, count, flags, &imap); |
| 254 | offset, count, iomapp, &imap, flags); | ||
| 255 | } | 188 | } |
| 256 | iomap_flags = IOMAP_NEW; | 189 | iomap_flags = IOMAP_NEW; |
| 257 | break; | 190 | break; |
| @@ -261,8 +194,7 @@ xfs_iomap( | |||
| 261 | lockmode = 0; | 194 | lockmode = 0; |
| 262 | 195 | ||
| 263 | if (nimaps && !isnullstartblock(imap.br_startblock)) { | 196 | if (nimaps && !isnullstartblock(imap.br_startblock)) { |
| 264 | xfs_iomap_map_trace(XFS_IOMAP_WRITE_MAP, ip, | 197 | trace_xfs_iomap_found(ip, offset, count, flags, &imap); |
| 265 | offset, count, iomapp, &imap, flags); | ||
| 266 | break; | 198 | break; |
| 267 | } | 199 | } |
| 268 | 200 | ||
| @@ -623,8 +555,7 @@ retry: | |||
| 623 | * delalloc blocks and retry without EOF preallocation. | 555 | * delalloc blocks and retry without EOF preallocation. |
| 624 | */ | 556 | */ |
| 625 | if (nimaps == 0) { | 557 | if (nimaps == 0) { |
| 626 | xfs_iomap_enter_trace(XFS_IOMAP_WRITE_NOSPACE, | 558 | trace_xfs_delalloc_enospc(ip, offset, count); |
| 627 | ip, offset, count); | ||
| 628 | if (flushed) | 559 | if (flushed) |
| 629 | return XFS_ERROR(ENOSPC); | 560 | return XFS_ERROR(ENOSPC); |
| 630 | 561 | ||
| @@ -837,7 +768,7 @@ xfs_iomap_write_unwritten( | |||
| 837 | int committed; | 768 | int committed; |
| 838 | int error; | 769 | int error; |
| 839 | 770 | ||
| 840 | xfs_iomap_enter_trace(XFS_IOMAP_UNWRITTEN, ip, offset, count); | 771 | trace_xfs_unwritten_convert(ip, offset, count); |
| 841 | 772 | ||
| 842 | offset_fsb = XFS_B_TO_FSBT(mp, offset); | 773 | offset_fsb = XFS_B_TO_FSBT(mp, offset); |
| 843 | count_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count); | 774 | count_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count); |
diff --git a/fs/xfs/xfs_iomap.h b/fs/xfs/xfs_iomap.h index fdcf7b82747f..174f29990991 100644 --- a/fs/xfs/xfs_iomap.h +++ b/fs/xfs/xfs_iomap.h | |||
| @@ -43,6 +43,14 @@ typedef enum { | |||
| 43 | BMAPI_TRYLOCK = (1 << 7), /* non-blocking request */ | 43 | BMAPI_TRYLOCK = (1 << 7), /* non-blocking request */ |
| 44 | } bmapi_flags_t; | 44 | } bmapi_flags_t; |
| 45 | 45 | ||
| 46 | #define BMAPI_FLAGS \ | ||
| 47 | { BMAPI_READ, "READ" }, \ | ||
| 48 | { BMAPI_WRITE, "WRITE" }, \ | ||
| 49 | { BMAPI_ALLOCATE, "ALLOCATE" }, \ | ||
| 50 | { BMAPI_IGNSTATE, "IGNSTATE" }, \ | ||
| 51 | { BMAPI_DIRECT, "DIRECT" }, \ | ||
| 52 | { BMAPI_MMAP, "MMAP" }, \ | ||
| 53 | { BMAPI_TRYLOCK, "TRYLOCK" } | ||
| 46 | 54 | ||
| 47 | /* | 55 | /* |
| 48 | * xfs_iomap_t: File system I/O map | 56 | * xfs_iomap_t: File system I/O map |
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 9dbdff3ea484..600b5b06aaeb 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
| @@ -40,6 +40,7 @@ | |||
| 40 | #include "xfs_dinode.h" | 40 | #include "xfs_dinode.h" |
| 41 | #include "xfs_inode.h" | 41 | #include "xfs_inode.h" |
| 42 | #include "xfs_rw.h" | 42 | #include "xfs_rw.h" |
| 43 | #include "xfs_trace.h" | ||
| 43 | 44 | ||
| 44 | kmem_zone_t *xfs_log_ticket_zone; | 45 | kmem_zone_t *xfs_log_ticket_zone; |
| 45 | 46 | ||
| @@ -122,85 +123,6 @@ STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog, | |||
| 122 | 123 | ||
| 123 | STATIC int xlog_iclogs_empty(xlog_t *log); | 124 | STATIC int xlog_iclogs_empty(xlog_t *log); |
| 124 | 125 | ||
| 125 | #if defined(XFS_LOG_TRACE) | ||
| 126 | |||
| 127 | #define XLOG_TRACE_LOGGRANT_SIZE 2048 | ||
| 128 | #define XLOG_TRACE_ICLOG_SIZE 256 | ||
| 129 | |||
| 130 | void | ||
| 131 | xlog_trace_loggrant_alloc(xlog_t *log) | ||
| 132 | { | ||
| 133 | log->l_grant_trace = ktrace_alloc(XLOG_TRACE_LOGGRANT_SIZE, KM_NOFS); | ||
| 134 | } | ||
| 135 | |||
| 136 | void | ||
| 137 | xlog_trace_loggrant_dealloc(xlog_t *log) | ||
| 138 | { | ||
| 139 | ktrace_free(log->l_grant_trace); | ||
| 140 | } | ||
| 141 | |||
| 142 | void | ||
| 143 | xlog_trace_loggrant(xlog_t *log, xlog_ticket_t *tic, xfs_caddr_t string) | ||
| 144 | { | ||
| 145 | unsigned long cnts; | ||
| 146 | |||
| 147 | /* ticket counts are 1 byte each */ | ||
| 148 | cnts = ((unsigned long)tic->t_ocnt) | ((unsigned long)tic->t_cnt) << 8; | ||
| 149 | |||
| 150 | ktrace_enter(log->l_grant_trace, | ||
| 151 | (void *)tic, | ||
| 152 | (void *)log->l_reserve_headq, | ||
| 153 | (void *)log->l_write_headq, | ||
| 154 | (void *)((unsigned long)log->l_grant_reserve_cycle), | ||
| 155 | (void *)((unsigned long)log->l_grant_reserve_bytes), | ||
| 156 | (void *)((unsigned long)log->l_grant_write_cycle), | ||
| 157 | (void *)((unsigned long)log->l_grant_write_bytes), | ||
| 158 | (void *)((unsigned long)log->l_curr_cycle), | ||
| 159 | (void *)((unsigned long)log->l_curr_block), | ||
| 160 | (void *)((unsigned long)CYCLE_LSN(log->l_tail_lsn)), | ||
| 161 | (void *)((unsigned long)BLOCK_LSN(log->l_tail_lsn)), | ||
| 162 | (void *)string, | ||
| 163 | (void *)((unsigned long)tic->t_trans_type), | ||
| 164 | (void *)cnts, | ||
| 165 | (void *)((unsigned long)tic->t_curr_res), | ||
| 166 | (void *)((unsigned long)tic->t_unit_res)); | ||
| 167 | } | ||
| 168 | |||
| 169 | void | ||
| 170 | xlog_trace_iclog_alloc(xlog_in_core_t *iclog) | ||
| 171 | { | ||
| 172 | iclog->ic_trace = ktrace_alloc(XLOG_TRACE_ICLOG_SIZE, KM_NOFS); | ||
| 173 | } | ||
| 174 | |||
| 175 | void | ||
| 176 | xlog_trace_iclog_dealloc(xlog_in_core_t *iclog) | ||
| 177 | { | ||
| 178 | ktrace_free(iclog->ic_trace); | ||
| 179 | } | ||
| 180 | |||
| 181 | void | ||
| 182 | xlog_trace_iclog(xlog_in_core_t *iclog, uint state) | ||
| 183 | { | ||
| 184 | ktrace_enter(iclog->ic_trace, | ||
| 185 | (void *)((unsigned long)state), | ||
| 186 | (void *)((unsigned long)current_pid()), | ||
| 187 | (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, | ||
| 188 | (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, | ||
| 189 | (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, | ||
| 190 | (void *)NULL, (void *)NULL); | ||
| 191 | } | ||
| 192 | #else | ||
| 193 | |||
| 194 | #define xlog_trace_loggrant_alloc(log) | ||
| 195 | #define xlog_trace_loggrant_dealloc(log) | ||
| 196 | #define xlog_trace_loggrant(log,tic,string) | ||
| 197 | |||
| 198 | #define xlog_trace_iclog_alloc(iclog) | ||
| 199 | #define xlog_trace_iclog_dealloc(iclog) | ||
| 200 | #define xlog_trace_iclog(iclog,state) | ||
| 201 | |||
| 202 | #endif /* XFS_LOG_TRACE */ | ||
| 203 | |||
| 204 | 126 | ||
| 205 | static void | 127 | static void |
| 206 | xlog_ins_ticketq(struct xlog_ticket **qp, struct xlog_ticket *tic) | 128 | xlog_ins_ticketq(struct xlog_ticket **qp, struct xlog_ticket *tic) |
| @@ -353,15 +275,17 @@ xfs_log_done(xfs_mount_t *mp, | |||
| 353 | 275 | ||
| 354 | if ((ticket->t_flags & XLOG_TIC_PERM_RESERV) == 0 || | 276 | if ((ticket->t_flags & XLOG_TIC_PERM_RESERV) == 0 || |
| 355 | (flags & XFS_LOG_REL_PERM_RESERV)) { | 277 | (flags & XFS_LOG_REL_PERM_RESERV)) { |
| 278 | trace_xfs_log_done_nonperm(log, ticket); | ||
| 279 | |||
| 356 | /* | 280 | /* |
| 357 | * Release ticket if not permanent reservation or a specific | 281 | * Release ticket if not permanent reservation or a specific |
| 358 | * request has been made to release a permanent reservation. | 282 | * request has been made to release a permanent reservation. |
| 359 | */ | 283 | */ |
| 360 | xlog_trace_loggrant(log, ticket, "xfs_log_done: (non-permanent)"); | ||
| 361 | xlog_ungrant_log_space(log, ticket); | 284 | xlog_ungrant_log_space(log, ticket); |
| 362 | xfs_log_ticket_put(ticket); | 285 | xfs_log_ticket_put(ticket); |
| 363 | } else { | 286 | } else { |
| 364 | xlog_trace_loggrant(log, ticket, "xfs_log_done: (permanent)"); | 287 | trace_xfs_log_done_perm(log, ticket); |
| 288 | |||
| 365 | xlog_regrant_reserve_log_space(log, ticket); | 289 | xlog_regrant_reserve_log_space(log, ticket); |
| 366 | /* If this ticket was a permanent reservation and we aren't | 290 | /* If this ticket was a permanent reservation and we aren't |
| 367 | * trying to release it, reset the inited flags; so next time | 291 | * trying to release it, reset the inited flags; so next time |
| @@ -505,10 +429,13 @@ xfs_log_reserve(xfs_mount_t *mp, | |||
| 505 | 429 | ||
| 506 | XFS_STATS_INC(xs_try_logspace); | 430 | XFS_STATS_INC(xs_try_logspace); |
| 507 | 431 | ||
| 432 | |||
| 508 | if (*ticket != NULL) { | 433 | if (*ticket != NULL) { |
| 509 | ASSERT(flags & XFS_LOG_PERM_RESERV); | 434 | ASSERT(flags & XFS_LOG_PERM_RESERV); |
| 510 | internal_ticket = (xlog_ticket_t *)*ticket; | 435 | internal_ticket = (xlog_ticket_t *)*ticket; |
| 511 | xlog_trace_loggrant(log, internal_ticket, "xfs_log_reserve: existing ticket (permanent trans)"); | 436 | |
| 437 | trace_xfs_log_reserve(log, internal_ticket); | ||
| 438 | |||
| 512 | xlog_grant_push_ail(mp, internal_ticket->t_unit_res); | 439 | xlog_grant_push_ail(mp, internal_ticket->t_unit_res); |
| 513 | retval = xlog_regrant_write_log_space(log, internal_ticket); | 440 | retval = xlog_regrant_write_log_space(log, internal_ticket); |
| 514 | } else { | 441 | } else { |
| @@ -519,10 +446,9 @@ xfs_log_reserve(xfs_mount_t *mp, | |||
| 519 | return XFS_ERROR(ENOMEM); | 446 | return XFS_ERROR(ENOMEM); |
| 520 | internal_ticket->t_trans_type = t_type; | 447 | internal_ticket->t_trans_type = t_type; |
| 521 | *ticket = internal_ticket; | 448 | *ticket = internal_ticket; |
| 522 | xlog_trace_loggrant(log, internal_ticket, | 449 | |
| 523 | (internal_ticket->t_flags & XLOG_TIC_PERM_RESERV) ? | 450 | trace_xfs_log_reserve(log, internal_ticket); |
| 524 | "xfs_log_reserve: create new ticket (permanent trans)" : | 451 | |
| 525 | "xfs_log_reserve: create new ticket"); | ||
| 526 | xlog_grant_push_ail(mp, | 452 | xlog_grant_push_ail(mp, |
| 527 | (internal_ticket->t_unit_res * | 453 | (internal_ticket->t_unit_res * |
| 528 | internal_ticket->t_cnt)); | 454 | internal_ticket->t_cnt)); |
| @@ -734,7 +660,7 @@ xfs_log_unmount_write(xfs_mount_t *mp) | |||
| 734 | spin_unlock(&log->l_icloglock); | 660 | spin_unlock(&log->l_icloglock); |
| 735 | } | 661 | } |
| 736 | if (tic) { | 662 | if (tic) { |
| 737 | xlog_trace_loggrant(log, tic, "unmount rec"); | 663 | trace_xfs_log_umount_write(log, tic); |
| 738 | xlog_ungrant_log_space(log, tic); | 664 | xlog_ungrant_log_space(log, tic); |
| 739 | xfs_log_ticket_put(tic); | 665 | xfs_log_ticket_put(tic); |
| 740 | } | 666 | } |
| @@ -1030,7 +956,6 @@ xlog_iodone(xfs_buf_t *bp) | |||
| 1030 | xfs_fs_cmn_err(CE_WARN, l->l_mp, | 956 | xfs_fs_cmn_err(CE_WARN, l->l_mp, |
| 1031 | "xlog_iodone: Barriers are no longer supported" | 957 | "xlog_iodone: Barriers are no longer supported" |
| 1032 | " by device. Disabling barriers\n"); | 958 | " by device. Disabling barriers\n"); |
| 1033 | xfs_buftrace("XLOG_IODONE BARRIERS OFF", bp); | ||
| 1034 | } | 959 | } |
| 1035 | 960 | ||
| 1036 | /* | 961 | /* |
| @@ -1085,13 +1010,10 @@ xlog_bdstrat_cb(struct xfs_buf *bp) | |||
| 1085 | return 0; | 1010 | return 0; |
| 1086 | } | 1011 | } |
| 1087 | 1012 | ||
| 1088 | xfs_buftrace("XLOG__BDSTRAT IOERROR", bp); | ||
| 1089 | XFS_BUF_ERROR(bp, EIO); | 1013 | XFS_BUF_ERROR(bp, EIO); |
| 1090 | XFS_BUF_STALE(bp); | 1014 | XFS_BUF_STALE(bp); |
| 1091 | xfs_biodone(bp); | 1015 | xfs_biodone(bp); |
| 1092 | return XFS_ERROR(EIO); | 1016 | return XFS_ERROR(EIO); |
| 1093 | |||
| 1094 | |||
| 1095 | } | 1017 | } |
| 1096 | 1018 | ||
| 1097 | /* | 1019 | /* |
| @@ -1246,7 +1168,6 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
| 1246 | spin_lock_init(&log->l_grant_lock); | 1168 | spin_lock_init(&log->l_grant_lock); |
| 1247 | sv_init(&log->l_flush_wait, 0, "flush_wait"); | 1169 | sv_init(&log->l_flush_wait, 0, "flush_wait"); |
| 1248 | 1170 | ||
| 1249 | xlog_trace_loggrant_alloc(log); | ||
| 1250 | /* log record size must be multiple of BBSIZE; see xlog_rec_header_t */ | 1171 | /* log record size must be multiple of BBSIZE; see xlog_rec_header_t */ |
| 1251 | ASSERT((XFS_BUF_SIZE(bp) & BBMASK) == 0); | 1172 | ASSERT((XFS_BUF_SIZE(bp) & BBMASK) == 0); |
| 1252 | 1173 | ||
| @@ -1305,8 +1226,6 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
| 1305 | sv_init(&iclog->ic_force_wait, SV_DEFAULT, "iclog-force"); | 1226 | sv_init(&iclog->ic_force_wait, SV_DEFAULT, "iclog-force"); |
| 1306 | sv_init(&iclog->ic_write_wait, SV_DEFAULT, "iclog-write"); | 1227 | sv_init(&iclog->ic_write_wait, SV_DEFAULT, "iclog-write"); |
| 1307 | 1228 | ||
| 1308 | xlog_trace_iclog_alloc(iclog); | ||
| 1309 | |||
| 1310 | iclogp = &iclog->ic_next; | 1229 | iclogp = &iclog->ic_next; |
| 1311 | } | 1230 | } |
| 1312 | *iclogp = log->l_iclog; /* complete ring */ | 1231 | *iclogp = log->l_iclog; /* complete ring */ |
| @@ -1321,13 +1240,11 @@ out_free_iclog: | |||
| 1321 | sv_destroy(&iclog->ic_force_wait); | 1240 | sv_destroy(&iclog->ic_force_wait); |
| 1322 | sv_destroy(&iclog->ic_write_wait); | 1241 | sv_destroy(&iclog->ic_write_wait); |
| 1323 | xfs_buf_free(iclog->ic_bp); | 1242 | xfs_buf_free(iclog->ic_bp); |
| 1324 | xlog_trace_iclog_dealloc(iclog); | ||
| 1325 | } | 1243 | } |
| 1326 | kmem_free(iclog); | 1244 | kmem_free(iclog); |
| 1327 | } | 1245 | } |
| 1328 | spinlock_destroy(&log->l_icloglock); | 1246 | spinlock_destroy(&log->l_icloglock); |
| 1329 | spinlock_destroy(&log->l_grant_lock); | 1247 | spinlock_destroy(&log->l_grant_lock); |
| 1330 | xlog_trace_loggrant_dealloc(log); | ||
| 1331 | xfs_buf_free(log->l_xbuf); | 1248 | xfs_buf_free(log->l_xbuf); |
| 1332 | out_free_log: | 1249 | out_free_log: |
| 1333 | kmem_free(log); | 1250 | kmem_free(log); |
| @@ -1524,6 +1441,7 @@ xlog_sync(xlog_t *log, | |||
| 1524 | XFS_BUF_ZEROFLAGS(bp); | 1441 | XFS_BUF_ZEROFLAGS(bp); |
| 1525 | XFS_BUF_BUSY(bp); | 1442 | XFS_BUF_BUSY(bp); |
| 1526 | XFS_BUF_ASYNC(bp); | 1443 | XFS_BUF_ASYNC(bp); |
| 1444 | bp->b_flags |= XBF_LOG_BUFFER; | ||
| 1527 | /* | 1445 | /* |
| 1528 | * Do an ordered write for the log block. | 1446 | * Do an ordered write for the log block. |
| 1529 | * Its unnecessary to flush the first split block in the log wrap case. | 1447 | * Its unnecessary to flush the first split block in the log wrap case. |
| @@ -1561,6 +1479,7 @@ xlog_sync(xlog_t *log, | |||
| 1561 | XFS_BUF_ZEROFLAGS(bp); | 1479 | XFS_BUF_ZEROFLAGS(bp); |
| 1562 | XFS_BUF_BUSY(bp); | 1480 | XFS_BUF_BUSY(bp); |
| 1563 | XFS_BUF_ASYNC(bp); | 1481 | XFS_BUF_ASYNC(bp); |
| 1482 | bp->b_flags |= XBF_LOG_BUFFER; | ||
| 1564 | if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) | 1483 | if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) |
| 1565 | XFS_BUF_ORDERED(bp); | 1484 | XFS_BUF_ORDERED(bp); |
| 1566 | dptr = XFS_BUF_PTR(bp); | 1485 | dptr = XFS_BUF_PTR(bp); |
| @@ -1607,7 +1526,6 @@ xlog_dealloc_log(xlog_t *log) | |||
| 1607 | sv_destroy(&iclog->ic_force_wait); | 1526 | sv_destroy(&iclog->ic_force_wait); |
| 1608 | sv_destroy(&iclog->ic_write_wait); | 1527 | sv_destroy(&iclog->ic_write_wait); |
| 1609 | xfs_buf_free(iclog->ic_bp); | 1528 | xfs_buf_free(iclog->ic_bp); |
| 1610 | xlog_trace_iclog_dealloc(iclog); | ||
| 1611 | next_iclog = iclog->ic_next; | 1529 | next_iclog = iclog->ic_next; |
| 1612 | kmem_free(iclog); | 1530 | kmem_free(iclog); |
| 1613 | iclog = next_iclog; | 1531 | iclog = next_iclog; |
| @@ -1616,7 +1534,6 @@ xlog_dealloc_log(xlog_t *log) | |||
| 1616 | spinlock_destroy(&log->l_grant_lock); | 1534 | spinlock_destroy(&log->l_grant_lock); |
| 1617 | 1535 | ||
| 1618 | xfs_buf_free(log->l_xbuf); | 1536 | xfs_buf_free(log->l_xbuf); |
| 1619 | xlog_trace_loggrant_dealloc(log); | ||
| 1620 | log->l_mp->m_log = NULL; | 1537 | log->l_mp->m_log = NULL; |
| 1621 | kmem_free(log); | 1538 | kmem_free(log); |
| 1622 | } /* xlog_dealloc_log */ | 1539 | } /* xlog_dealloc_log */ |
| @@ -2414,7 +2331,6 @@ restart: | |||
| 2414 | 2331 | ||
| 2415 | iclog = log->l_iclog; | 2332 | iclog = log->l_iclog; |
| 2416 | if (iclog->ic_state != XLOG_STATE_ACTIVE) { | 2333 | if (iclog->ic_state != XLOG_STATE_ACTIVE) { |
| 2417 | xlog_trace_iclog(iclog, XLOG_TRACE_SLEEP_FLUSH); | ||
| 2418 | XFS_STATS_INC(xs_log_noiclogs); | 2334 | XFS_STATS_INC(xs_log_noiclogs); |
| 2419 | 2335 | ||
| 2420 | /* Wait for log writes to have flushed */ | 2336 | /* Wait for log writes to have flushed */ |
| @@ -2520,13 +2436,15 @@ xlog_grant_log_space(xlog_t *log, | |||
| 2520 | 2436 | ||
| 2521 | /* Is there space or do we need to sleep? */ | 2437 | /* Is there space or do we need to sleep? */ |
| 2522 | spin_lock(&log->l_grant_lock); | 2438 | spin_lock(&log->l_grant_lock); |
| 2523 | xlog_trace_loggrant(log, tic, "xlog_grant_log_space: enter"); | 2439 | |
| 2440 | trace_xfs_log_grant_enter(log, tic); | ||
| 2524 | 2441 | ||
| 2525 | /* something is already sleeping; insert new transaction at end */ | 2442 | /* something is already sleeping; insert new transaction at end */ |
| 2526 | if (log->l_reserve_headq) { | 2443 | if (log->l_reserve_headq) { |
| 2527 | xlog_ins_ticketq(&log->l_reserve_headq, tic); | 2444 | xlog_ins_ticketq(&log->l_reserve_headq, tic); |
| 2528 | xlog_trace_loggrant(log, tic, | 2445 | |
| 2529 | "xlog_grant_log_space: sleep 1"); | 2446 | trace_xfs_log_grant_sleep1(log, tic); |
| 2447 | |||
| 2530 | /* | 2448 | /* |
| 2531 | * Gotta check this before going to sleep, while we're | 2449 | * Gotta check this before going to sleep, while we're |
| 2532 | * holding the grant lock. | 2450 | * holding the grant lock. |
| @@ -2540,8 +2458,7 @@ xlog_grant_log_space(xlog_t *log, | |||
| 2540 | * If we got an error, and the filesystem is shutting down, | 2458 | * If we got an error, and the filesystem is shutting down, |
| 2541 | * we'll catch it down below. So just continue... | 2459 | * we'll catch it down below. So just continue... |
| 2542 | */ | 2460 | */ |
| 2543 | xlog_trace_loggrant(log, tic, | 2461 | trace_xfs_log_grant_wake1(log, tic); |
| 2544 | "xlog_grant_log_space: wake 1"); | ||
| 2545 | spin_lock(&log->l_grant_lock); | 2462 | spin_lock(&log->l_grant_lock); |
| 2546 | } | 2463 | } |
| 2547 | if (tic->t_flags & XFS_LOG_PERM_RESERV) | 2464 | if (tic->t_flags & XFS_LOG_PERM_RESERV) |
| @@ -2558,8 +2475,9 @@ redo: | |||
| 2558 | if (free_bytes < need_bytes) { | 2475 | if (free_bytes < need_bytes) { |
| 2559 | if ((tic->t_flags & XLOG_TIC_IN_Q) == 0) | 2476 | if ((tic->t_flags & XLOG_TIC_IN_Q) == 0) |
| 2560 | xlog_ins_ticketq(&log->l_reserve_headq, tic); | 2477 | xlog_ins_ticketq(&log->l_reserve_headq, tic); |
| 2561 | xlog_trace_loggrant(log, tic, | 2478 | |
| 2562 | "xlog_grant_log_space: sleep 2"); | 2479 | trace_xfs_log_grant_sleep2(log, tic); |
| 2480 | |||
| 2563 | spin_unlock(&log->l_grant_lock); | 2481 | spin_unlock(&log->l_grant_lock); |
| 2564 | xlog_grant_push_ail(log->l_mp, need_bytes); | 2482 | xlog_grant_push_ail(log->l_mp, need_bytes); |
| 2565 | spin_lock(&log->l_grant_lock); | 2483 | spin_lock(&log->l_grant_lock); |
| @@ -2571,8 +2489,8 @@ redo: | |||
| 2571 | if (XLOG_FORCED_SHUTDOWN(log)) | 2489 | if (XLOG_FORCED_SHUTDOWN(log)) |
| 2572 | goto error_return; | 2490 | goto error_return; |
| 2573 | 2491 | ||
| 2574 | xlog_trace_loggrant(log, tic, | 2492 | trace_xfs_log_grant_wake2(log, tic); |
| 2575 | "xlog_grant_log_space: wake 2"); | 2493 | |
| 2576 | goto redo; | 2494 | goto redo; |
| 2577 | } else if (tic->t_flags & XLOG_TIC_IN_Q) | 2495 | } else if (tic->t_flags & XLOG_TIC_IN_Q) |
| 2578 | xlog_del_ticketq(&log->l_reserve_headq, tic); | 2496 | xlog_del_ticketq(&log->l_reserve_headq, tic); |
| @@ -2592,7 +2510,7 @@ redo: | |||
| 2592 | ASSERT(log->l_grant_write_bytes <= BBTOB(BLOCK_LSN(tail_lsn))); | 2510 | ASSERT(log->l_grant_write_bytes <= BBTOB(BLOCK_LSN(tail_lsn))); |
| 2593 | } | 2511 | } |
| 2594 | #endif | 2512 | #endif |
| 2595 | xlog_trace_loggrant(log, tic, "xlog_grant_log_space: exit"); | 2513 | trace_xfs_log_grant_exit(log, tic); |
| 2596 | xlog_verify_grant_head(log, 1); | 2514 | xlog_verify_grant_head(log, 1); |
| 2597 | spin_unlock(&log->l_grant_lock); | 2515 | spin_unlock(&log->l_grant_lock); |
| 2598 | return 0; | 2516 | return 0; |
| @@ -2600,7 +2518,9 @@ redo: | |||
| 2600 | error_return: | 2518 | error_return: |
| 2601 | if (tic->t_flags & XLOG_TIC_IN_Q) | 2519 | if (tic->t_flags & XLOG_TIC_IN_Q) |
| 2602 | xlog_del_ticketq(&log->l_reserve_headq, tic); | 2520 | xlog_del_ticketq(&log->l_reserve_headq, tic); |
| 2603 | xlog_trace_loggrant(log, tic, "xlog_grant_log_space: err_ret"); | 2521 | |
| 2522 | trace_xfs_log_grant_error(log, tic); | ||
| 2523 | |||
| 2604 | /* | 2524 | /* |
| 2605 | * If we are failing, make sure the ticket doesn't have any | 2525 | * If we are failing, make sure the ticket doesn't have any |
| 2606 | * current reservations. We don't want to add this back when | 2526 | * current reservations. We don't want to add this back when |
| @@ -2640,7 +2560,8 @@ xlog_regrant_write_log_space(xlog_t *log, | |||
| 2640 | #endif | 2560 | #endif |
| 2641 | 2561 | ||
| 2642 | spin_lock(&log->l_grant_lock); | 2562 | spin_lock(&log->l_grant_lock); |
| 2643 | xlog_trace_loggrant(log, tic, "xlog_regrant_write_log_space: enter"); | 2563 | |
| 2564 | trace_xfs_log_regrant_write_enter(log, tic); | ||
| 2644 | 2565 | ||
| 2645 | if (XLOG_FORCED_SHUTDOWN(log)) | 2566 | if (XLOG_FORCED_SHUTDOWN(log)) |
| 2646 | goto error_return; | 2567 | goto error_return; |
| @@ -2669,8 +2590,8 @@ xlog_regrant_write_log_space(xlog_t *log, | |||
| 2669 | if ((tic->t_flags & XLOG_TIC_IN_Q) == 0) | 2590 | if ((tic->t_flags & XLOG_TIC_IN_Q) == 0) |
| 2670 | xlog_ins_ticketq(&log->l_write_headq, tic); | 2591 | xlog_ins_ticketq(&log->l_write_headq, tic); |
| 2671 | 2592 | ||
| 2672 | xlog_trace_loggrant(log, tic, | 2593 | trace_xfs_log_regrant_write_sleep1(log, tic); |
| 2673 | "xlog_regrant_write_log_space: sleep 1"); | 2594 | |
| 2674 | spin_unlock(&log->l_grant_lock); | 2595 | spin_unlock(&log->l_grant_lock); |
| 2675 | xlog_grant_push_ail(log->l_mp, need_bytes); | 2596 | xlog_grant_push_ail(log->l_mp, need_bytes); |
| 2676 | spin_lock(&log->l_grant_lock); | 2597 | spin_lock(&log->l_grant_lock); |
| @@ -2685,8 +2606,7 @@ xlog_regrant_write_log_space(xlog_t *log, | |||
| 2685 | if (XLOG_FORCED_SHUTDOWN(log)) | 2606 | if (XLOG_FORCED_SHUTDOWN(log)) |
| 2686 | goto error_return; | 2607 | goto error_return; |
| 2687 | 2608 | ||
| 2688 | xlog_trace_loggrant(log, tic, | 2609 | trace_xfs_log_regrant_write_wake1(log, tic); |
| 2689 | "xlog_regrant_write_log_space: wake 1"); | ||
| 2690 | } | 2610 | } |
| 2691 | } | 2611 | } |
| 2692 | 2612 | ||
| @@ -2704,6 +2624,8 @@ redo: | |||
| 2704 | spin_lock(&log->l_grant_lock); | 2624 | spin_lock(&log->l_grant_lock); |
| 2705 | 2625 | ||
| 2706 | XFS_STATS_INC(xs_sleep_logspace); | 2626 | XFS_STATS_INC(xs_sleep_logspace); |
| 2627 | trace_xfs_log_regrant_write_sleep2(log, tic); | ||
| 2628 | |||
| 2707 | sv_wait(&tic->t_wait, PINOD|PLTWAIT, &log->l_grant_lock, s); | 2629 | sv_wait(&tic->t_wait, PINOD|PLTWAIT, &log->l_grant_lock, s); |
| 2708 | 2630 | ||
| 2709 | /* If we're shutting down, this tic is already off the queue */ | 2631 | /* If we're shutting down, this tic is already off the queue */ |
| @@ -2711,8 +2633,7 @@ redo: | |||
| 2711 | if (XLOG_FORCED_SHUTDOWN(log)) | 2633 | if (XLOG_FORCED_SHUTDOWN(log)) |
| 2712 | goto error_return; | 2634 | goto error_return; |
| 2713 | 2635 | ||
| 2714 | xlog_trace_loggrant(log, tic, | 2636 | trace_xfs_log_regrant_write_wake2(log, tic); |
| 2715 | "xlog_regrant_write_log_space: wake 2"); | ||
| 2716 | goto redo; | 2637 | goto redo; |
| 2717 | } else if (tic->t_flags & XLOG_TIC_IN_Q) | 2638 | } else if (tic->t_flags & XLOG_TIC_IN_Q) |
| 2718 | xlog_del_ticketq(&log->l_write_headq, tic); | 2639 | xlog_del_ticketq(&log->l_write_headq, tic); |
| @@ -2727,7 +2648,8 @@ redo: | |||
| 2727 | } | 2648 | } |
| 2728 | #endif | 2649 | #endif |
| 2729 | 2650 | ||
| 2730 | xlog_trace_loggrant(log, tic, "xlog_regrant_write_log_space: exit"); | 2651 | trace_xfs_log_regrant_write_exit(log, tic); |
| 2652 | |||
| 2731 | xlog_verify_grant_head(log, 1); | 2653 | xlog_verify_grant_head(log, 1); |
| 2732 | spin_unlock(&log->l_grant_lock); | 2654 | spin_unlock(&log->l_grant_lock); |
| 2733 | return 0; | 2655 | return 0; |
| @@ -2736,7 +2658,9 @@ redo: | |||
| 2736 | error_return: | 2658 | error_return: |
| 2737 | if (tic->t_flags & XLOG_TIC_IN_Q) | 2659 | if (tic->t_flags & XLOG_TIC_IN_Q) |
| 2738 | xlog_del_ticketq(&log->l_reserve_headq, tic); | 2660 | xlog_del_ticketq(&log->l_reserve_headq, tic); |
| 2739 | xlog_trace_loggrant(log, tic, "xlog_regrant_write_log_space: err_ret"); | 2661 | |
| 2662 | trace_xfs_log_regrant_write_error(log, tic); | ||
| 2663 | |||
| 2740 | /* | 2664 | /* |
| 2741 | * If we are failing, make sure the ticket doesn't have any | 2665 | * If we are failing, make sure the ticket doesn't have any |
| 2742 | * current reservations. We don't want to add this back when | 2666 | * current reservations. We don't want to add this back when |
| @@ -2760,8 +2684,8 @@ STATIC void | |||
| 2760 | xlog_regrant_reserve_log_space(xlog_t *log, | 2684 | xlog_regrant_reserve_log_space(xlog_t *log, |
| 2761 | xlog_ticket_t *ticket) | 2685 | xlog_ticket_t *ticket) |
| 2762 | { | 2686 | { |
| 2763 | xlog_trace_loggrant(log, ticket, | 2687 | trace_xfs_log_regrant_reserve_enter(log, ticket); |
| 2764 | "xlog_regrant_reserve_log_space: enter"); | 2688 | |
| 2765 | if (ticket->t_cnt > 0) | 2689 | if (ticket->t_cnt > 0) |
| 2766 | ticket->t_cnt--; | 2690 | ticket->t_cnt--; |
| 2767 | 2691 | ||
| @@ -2769,8 +2693,9 @@ xlog_regrant_reserve_log_space(xlog_t *log, | |||
| 2769 | xlog_grant_sub_space(log, ticket->t_curr_res); | 2693 | xlog_grant_sub_space(log, ticket->t_curr_res); |
| 2770 | ticket->t_curr_res = ticket->t_unit_res; | 2694 | ticket->t_curr_res = ticket->t_unit_res; |
| 2771 | xlog_tic_reset_res(ticket); | 2695 | xlog_tic_reset_res(ticket); |
| 2772 | xlog_trace_loggrant(log, ticket, | 2696 | |
| 2773 | "xlog_regrant_reserve_log_space: sub current res"); | 2697 | trace_xfs_log_regrant_reserve_sub(log, ticket); |
| 2698 | |||
| 2774 | xlog_verify_grant_head(log, 1); | 2699 | xlog_verify_grant_head(log, 1); |
| 2775 | 2700 | ||
| 2776 | /* just return if we still have some of the pre-reserved space */ | 2701 | /* just return if we still have some of the pre-reserved space */ |
| @@ -2780,8 +2705,9 @@ xlog_regrant_reserve_log_space(xlog_t *log, | |||
| 2780 | } | 2705 | } |
| 2781 | 2706 | ||
| 2782 | xlog_grant_add_space_reserve(log, ticket->t_unit_res); | 2707 | xlog_grant_add_space_reserve(log, ticket->t_unit_res); |
| 2783 | xlog_trace_loggrant(log, ticket, | 2708 | |
| 2784 | "xlog_regrant_reserve_log_space: exit"); | 2709 | trace_xfs_log_regrant_reserve_exit(log, ticket); |
| 2710 | |||
| 2785 | xlog_verify_grant_head(log, 0); | 2711 | xlog_verify_grant_head(log, 0); |
| 2786 | spin_unlock(&log->l_grant_lock); | 2712 | spin_unlock(&log->l_grant_lock); |
| 2787 | ticket->t_curr_res = ticket->t_unit_res; | 2713 | ticket->t_curr_res = ticket->t_unit_res; |
| @@ -2811,11 +2737,11 @@ xlog_ungrant_log_space(xlog_t *log, | |||
| 2811 | ticket->t_cnt--; | 2737 | ticket->t_cnt--; |
| 2812 | 2738 | ||
| 2813 | spin_lock(&log->l_grant_lock); | 2739 | spin_lock(&log->l_grant_lock); |
| 2814 | xlog_trace_loggrant(log, ticket, "xlog_ungrant_log_space: enter"); | 2740 | trace_xfs_log_ungrant_enter(log, ticket); |
| 2815 | 2741 | ||
| 2816 | xlog_grant_sub_space(log, ticket->t_curr_res); | 2742 | xlog_grant_sub_space(log, ticket->t_curr_res); |
| 2817 | 2743 | ||
| 2818 | xlog_trace_loggrant(log, ticket, "xlog_ungrant_log_space: sub current"); | 2744 | trace_xfs_log_ungrant_sub(log, ticket); |
| 2819 | 2745 | ||
| 2820 | /* If this is a permanent reservation ticket, we may be able to free | 2746 | /* If this is a permanent reservation ticket, we may be able to free |
| 2821 | * up more space based on the remaining count. | 2747 | * up more space based on the remaining count. |
| @@ -2825,7 +2751,8 @@ xlog_ungrant_log_space(xlog_t *log, | |||
| 2825 | xlog_grant_sub_space(log, ticket->t_unit_res*ticket->t_cnt); | 2751 | xlog_grant_sub_space(log, ticket->t_unit_res*ticket->t_cnt); |
| 2826 | } | 2752 | } |
| 2827 | 2753 | ||
| 2828 | xlog_trace_loggrant(log, ticket, "xlog_ungrant_log_space: exit"); | 2754 | trace_xfs_log_ungrant_exit(log, ticket); |
| 2755 | |||
| 2829 | xlog_verify_grant_head(log, 1); | 2756 | xlog_verify_grant_head(log, 1); |
| 2830 | spin_unlock(&log->l_grant_lock); | 2757 | spin_unlock(&log->l_grant_lock); |
| 2831 | xfs_log_move_tail(log->l_mp, 1); | 2758 | xfs_log_move_tail(log->l_mp, 1); |
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h index 679c7c4926a2..d55662db7077 100644 --- a/fs/xfs/xfs_log_priv.h +++ b/fs/xfs/xfs_log_priv.h | |||
| @@ -19,7 +19,6 @@ | |||
| 19 | #define __XFS_LOG_PRIV_H__ | 19 | #define __XFS_LOG_PRIV_H__ |
| 20 | 20 | ||
| 21 | struct xfs_buf; | 21 | struct xfs_buf; |
| 22 | struct ktrace; | ||
| 23 | struct log; | 22 | struct log; |
| 24 | struct xlog_ticket; | 23 | struct xlog_ticket; |
| 25 | struct xfs_buf_cancel; | 24 | struct xfs_buf_cancel; |
| @@ -135,6 +134,12 @@ static inline uint xlog_get_client_id(__be32 i) | |||
| 135 | #define XLOG_TIC_INITED 0x1 /* has been initialized */ | 134 | #define XLOG_TIC_INITED 0x1 /* has been initialized */ |
| 136 | #define XLOG_TIC_PERM_RESERV 0x2 /* permanent reservation */ | 135 | #define XLOG_TIC_PERM_RESERV 0x2 /* permanent reservation */ |
| 137 | #define XLOG_TIC_IN_Q 0x4 | 136 | #define XLOG_TIC_IN_Q 0x4 |
| 137 | |||
| 138 | #define XLOG_TIC_FLAGS \ | ||
| 139 | { XLOG_TIC_INITED, "XLOG_TIC_INITED" }, \ | ||
| 140 | { XLOG_TIC_PERM_RESERV, "XLOG_TIC_PERM_RESERV" }, \ | ||
| 141 | { XLOG_TIC_IN_Q, "XLOG_TIC_IN_Q" } | ||
| 142 | |||
| 138 | #endif /* __KERNEL__ */ | 143 | #endif /* __KERNEL__ */ |
| 139 | 144 | ||
| 140 | #define XLOG_UNMOUNT_TYPE 0x556e /* Un for Unmount */ | 145 | #define XLOG_UNMOUNT_TYPE 0x556e /* Un for Unmount */ |
| @@ -361,9 +366,6 @@ typedef struct xlog_in_core { | |||
| 361 | int ic_bwritecnt; | 366 | int ic_bwritecnt; |
| 362 | unsigned short ic_state; | 367 | unsigned short ic_state; |
| 363 | char *ic_datap; /* pointer to iclog data */ | 368 | char *ic_datap; /* pointer to iclog data */ |
| 364 | #ifdef XFS_LOG_TRACE | ||
| 365 | struct ktrace *ic_trace; | ||
| 366 | #endif | ||
| 367 | 369 | ||
| 368 | /* Callback structures need their own cacheline */ | 370 | /* Callback structures need their own cacheline */ |
| 369 | spinlock_t ic_callback_lock ____cacheline_aligned_in_smp; | 371 | spinlock_t ic_callback_lock ____cacheline_aligned_in_smp; |
| @@ -429,10 +431,6 @@ typedef struct log { | |||
| 429 | int l_grant_write_cycle; | 431 | int l_grant_write_cycle; |
| 430 | int l_grant_write_bytes; | 432 | int l_grant_write_bytes; |
| 431 | 433 | ||
| 432 | #ifdef XFS_LOG_TRACE | ||
| 433 | struct ktrace *l_grant_trace; | ||
| 434 | #endif | ||
| 435 | |||
| 436 | /* The following field are used for debugging; need to hold icloglock */ | 434 | /* The following field are used for debugging; need to hold icloglock */ |
| 437 | #ifdef DEBUG | 435 | #ifdef DEBUG |
| 438 | char *l_iclog_bak[XLOG_MAX_ICLOGS]; | 436 | char *l_iclog_bak[XLOG_MAX_ICLOGS]; |
| @@ -456,12 +454,6 @@ extern void xlog_put_bp(struct xfs_buf *); | |||
| 456 | 454 | ||
| 457 | extern kmem_zone_t *xfs_log_ticket_zone; | 455 | extern kmem_zone_t *xfs_log_ticket_zone; |
| 458 | 456 | ||
| 459 | /* iclog tracing */ | ||
| 460 | #define XLOG_TRACE_GRAB_FLUSH 1 | ||
| 461 | #define XLOG_TRACE_REL_FLUSH 2 | ||
| 462 | #define XLOG_TRACE_SLEEP_FLUSH 3 | ||
| 463 | #define XLOG_TRACE_WAKE_FLUSH 4 | ||
| 464 | |||
| 465 | /* | 457 | /* |
| 466 | * Unmount record type is used as a pseudo transaction type for the ticket. | 458 | * Unmount record type is used as a pseudo transaction type for the ticket. |
| 467 | * It's value must be outside the range of XFS_TRANS_* values. | 459 | * It's value must be outside the range of XFS_TRANS_* values. |
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 1ec98ed914d4..69ac2e5ef20c 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
| @@ -46,6 +46,7 @@ | |||
| 46 | #include "xfs_quota.h" | 46 | #include "xfs_quota.h" |
| 47 | #include "xfs_rw.h" | 47 | #include "xfs_rw.h" |
| 48 | #include "xfs_utils.h" | 48 | #include "xfs_utils.h" |
| 49 | #include "xfs_trace.h" | ||
| 49 | 50 | ||
| 50 | STATIC int xlog_find_zeroed(xlog_t *, xfs_daddr_t *); | 51 | STATIC int xlog_find_zeroed(xlog_t *, xfs_daddr_t *); |
| 51 | STATIC int xlog_clear_stale_blocks(xlog_t *, xfs_lsn_t); | 52 | STATIC int xlog_clear_stale_blocks(xlog_t *, xfs_lsn_t); |
| @@ -225,16 +226,10 @@ xlog_header_check_dump( | |||
| 225 | xfs_mount_t *mp, | 226 | xfs_mount_t *mp, |
| 226 | xlog_rec_header_t *head) | 227 | xlog_rec_header_t *head) |
| 227 | { | 228 | { |
| 228 | int b; | 229 | cmn_err(CE_DEBUG, "%s: SB : uuid = %pU, fmt = %d\n", |
| 229 | 230 | __func__, &mp->m_sb.sb_uuid, XLOG_FMT); | |
| 230 | cmn_err(CE_DEBUG, "%s: SB : uuid = ", __func__); | 231 | cmn_err(CE_DEBUG, " log : uuid = %pU, fmt = %d\n", |
| 231 | for (b = 0; b < 16; b++) | 232 | &head->h_fs_uuid, be32_to_cpu(head->h_fmt)); |
| 232 | cmn_err(CE_DEBUG, "%02x", ((__uint8_t *)&mp->m_sb.sb_uuid)[b]); | ||
| 233 | cmn_err(CE_DEBUG, ", fmt = %d\n", XLOG_FMT); | ||
| 234 | cmn_err(CE_DEBUG, " log : uuid = "); | ||
| 235 | for (b = 0; b < 16; b++) | ||
| 236 | cmn_err(CE_DEBUG, "%02x", ((__uint8_t *)&head->h_fs_uuid)[b]); | ||
| 237 | cmn_err(CE_DEBUG, ", fmt = %d\n", be32_to_cpu(head->h_fmt)); | ||
| 238 | } | 233 | } |
| 239 | #else | 234 | #else |
| 240 | #define xlog_header_check_dump(mp, head) | 235 | #define xlog_header_check_dump(mp, head) |
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 66a888a9ad6f..eb403b40e120 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
| @@ -44,6 +44,8 @@ | |||
| 44 | #include "xfs_quota.h" | 44 | #include "xfs_quota.h" |
| 45 | #include "xfs_fsops.h" | 45 | #include "xfs_fsops.h" |
| 46 | #include "xfs_utils.h" | 46 | #include "xfs_utils.h" |
| 47 | #include "xfs_trace.h" | ||
| 48 | |||
| 47 | 49 | ||
| 48 | STATIC void xfs_unmountfs_wait(xfs_mount_t *); | 50 | STATIC void xfs_unmountfs_wait(xfs_mount_t *); |
| 49 | 51 | ||
| @@ -2389,12 +2391,12 @@ xfs_icsb_modify_counters( | |||
| 2389 | { | 2391 | { |
| 2390 | xfs_icsb_cnts_t *icsbp; | 2392 | xfs_icsb_cnts_t *icsbp; |
| 2391 | long long lcounter; /* long counter for 64 bit fields */ | 2393 | long long lcounter; /* long counter for 64 bit fields */ |
| 2392 | int cpu, ret = 0; | 2394 | int ret = 0; |
| 2393 | 2395 | ||
| 2394 | might_sleep(); | 2396 | might_sleep(); |
| 2395 | again: | 2397 | again: |
| 2396 | cpu = get_cpu(); | 2398 | preempt_disable(); |
| 2397 | icsbp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, cpu); | 2399 | icsbp = this_cpu_ptr(mp->m_sb_cnts); |
| 2398 | 2400 | ||
| 2399 | /* | 2401 | /* |
| 2400 | * if the counter is disabled, go to slow path | 2402 | * if the counter is disabled, go to slow path |
| @@ -2438,11 +2440,11 @@ again: | |||
| 2438 | break; | 2440 | break; |
| 2439 | } | 2441 | } |
| 2440 | xfs_icsb_unlock_cntr(icsbp); | 2442 | xfs_icsb_unlock_cntr(icsbp); |
| 2441 | put_cpu(); | 2443 | preempt_enable(); |
| 2442 | return 0; | 2444 | return 0; |
| 2443 | 2445 | ||
| 2444 | slow_path: | 2446 | slow_path: |
| 2445 | put_cpu(); | 2447 | preempt_enable(); |
| 2446 | 2448 | ||
| 2447 | /* | 2449 | /* |
| 2448 | * serialise with a mutex so we don't burn lots of cpu on | 2450 | * serialise with a mutex so we don't burn lots of cpu on |
| @@ -2490,7 +2492,7 @@ slow_path: | |||
| 2490 | 2492 | ||
| 2491 | balance_counter: | 2493 | balance_counter: |
| 2492 | xfs_icsb_unlock_cntr(icsbp); | 2494 | xfs_icsb_unlock_cntr(icsbp); |
| 2493 | put_cpu(); | 2495 | preempt_enable(); |
| 2494 | 2496 | ||
| 2495 | /* | 2497 | /* |
| 2496 | * We may have multiple threads here if multiple per-cpu | 2498 | * We may have multiple threads here if multiple per-cpu |
diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h index 3ec91ac74c2a..91bfd60f4c74 100644 --- a/fs/xfs/xfs_quota.h +++ b/fs/xfs/xfs_quota.h | |||
| @@ -92,6 +92,14 @@ typedef struct xfs_dqblk { | |||
| 92 | 92 | ||
| 93 | #define XFS_DQ_ALLTYPES (XFS_DQ_USER|XFS_DQ_PROJ|XFS_DQ_GROUP) | 93 | #define XFS_DQ_ALLTYPES (XFS_DQ_USER|XFS_DQ_PROJ|XFS_DQ_GROUP) |
| 94 | 94 | ||
| 95 | #define XFS_DQ_FLAGS \ | ||
| 96 | { XFS_DQ_USER, "USER" }, \ | ||
| 97 | { XFS_DQ_PROJ, "PROJ" }, \ | ||
| 98 | { XFS_DQ_GROUP, "GROUP" }, \ | ||
| 99 | { XFS_DQ_DIRTY, "DIRTY" }, \ | ||
| 100 | { XFS_DQ_WANT, "WANT" }, \ | ||
| 101 | { XFS_DQ_INACTIVE, "INACTIVE" } | ||
| 102 | |||
| 95 | /* | 103 | /* |
| 96 | * In the worst case, when both user and group quotas are on, | 104 | * In the worst case, when both user and group quotas are on, |
| 97 | * we can have a max of three dquots changing in a single transaction. | 105 | * we can have a max of three dquots changing in a single transaction. |
diff --git a/fs/xfs/xfs_rename.c b/fs/xfs/xfs_rename.c index b81deea0ce19..fc1cda23b817 100644 --- a/fs/xfs/xfs_rename.c +++ b/fs/xfs/xfs_rename.c | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | #include "xfs_utils.h" | 39 | #include "xfs_utils.h" |
| 40 | #include "xfs_trans_space.h" | 40 | #include "xfs_trans_space.h" |
| 41 | #include "xfs_vnodeops.h" | 41 | #include "xfs_vnodeops.h" |
| 42 | #include "xfs_trace.h" | ||
| 42 | 43 | ||
| 43 | 44 | ||
| 44 | /* | 45 | /* |
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 385f6dceba5d..9e15a1185362 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c | |||
| @@ -45,6 +45,7 @@ | |||
| 45 | #include "xfs_inode_item.h" | 45 | #include "xfs_inode_item.h" |
| 46 | #include "xfs_trans_space.h" | 46 | #include "xfs_trans_space.h" |
| 47 | #include "xfs_utils.h" | 47 | #include "xfs_utils.h" |
| 48 | #include "xfs_trace.h" | ||
| 48 | 49 | ||
| 49 | 50 | ||
| 50 | /* | 51 | /* |
diff --git a/fs/xfs/xfs_rw.c b/fs/xfs/xfs_rw.c index 4c199d18f850..5aa07caea5f1 100644 --- a/fs/xfs/xfs_rw.c +++ b/fs/xfs/xfs_rw.c | |||
| @@ -44,6 +44,7 @@ | |||
| 44 | #include "xfs_error.h" | 44 | #include "xfs_error.h" |
| 45 | #include "xfs_buf_item.h" | 45 | #include "xfs_buf_item.h" |
| 46 | #include "xfs_rw.h" | 46 | #include "xfs_rw.h" |
| 47 | #include "xfs_trace.h" | ||
| 47 | 48 | ||
| 48 | /* | 49 | /* |
| 49 | * This is a subroutine for xfs_write() and other writers (xfs_ioctl) | 50 | * This is a subroutine for xfs_write() and other writers (xfs_ioctl) |
| @@ -171,7 +172,6 @@ xfs_bioerror( | |||
| 171 | * No need to wait until the buffer is unpinned. | 172 | * No need to wait until the buffer is unpinned. |
| 172 | * We aren't flushing it. | 173 | * We aren't flushing it. |
| 173 | */ | 174 | */ |
| 174 | xfs_buftrace("XFS IOERROR", bp); | ||
| 175 | XFS_BUF_ERROR(bp, EIO); | 175 | XFS_BUF_ERROR(bp, EIO); |
| 176 | /* | 176 | /* |
| 177 | * We're calling biodone, so delete B_DONE flag. Either way | 177 | * We're calling biodone, so delete B_DONE flag. Either way |
| @@ -205,7 +205,6 @@ xfs_bioerror_relse( | |||
| 205 | ASSERT(XFS_BUF_IODONE_FUNC(bp) != xfs_buf_iodone_callbacks); | 205 | ASSERT(XFS_BUF_IODONE_FUNC(bp) != xfs_buf_iodone_callbacks); |
| 206 | ASSERT(XFS_BUF_IODONE_FUNC(bp) != xlog_iodone); | 206 | ASSERT(XFS_BUF_IODONE_FUNC(bp) != xlog_iodone); |
| 207 | 207 | ||
| 208 | xfs_buftrace("XFS IOERRELSE", bp); | ||
| 209 | fl = XFS_BUF_BFLAGS(bp); | 208 | fl = XFS_BUF_BFLAGS(bp); |
| 210 | /* | 209 | /* |
| 211 | * No need to wait until the buffer is unpinned. | 210 | * No need to wait until the buffer is unpinned. |
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index a0574f593f52..ca64f33c63a3 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h | |||
| @@ -100,6 +100,49 @@ typedef struct xfs_trans_header { | |||
| 100 | #define XFS_TRANS_TYPE_MAX 41 | 100 | #define XFS_TRANS_TYPE_MAX 41 |
| 101 | /* new transaction types need to be reflected in xfs_logprint(8) */ | 101 | /* new transaction types need to be reflected in xfs_logprint(8) */ |
| 102 | 102 | ||
| 103 | #define XFS_TRANS_TYPES \ | ||
| 104 | { XFS_TRANS_SETATTR_NOT_SIZE, "SETATTR_NOT_SIZE" }, \ | ||
| 105 | { XFS_TRANS_SETATTR_SIZE, "SETATTR_SIZE" }, \ | ||
| 106 | { XFS_TRANS_INACTIVE, "INACTIVE" }, \ | ||
| 107 | { XFS_TRANS_CREATE, "CREATE" }, \ | ||
| 108 | { XFS_TRANS_CREATE_TRUNC, "CREATE_TRUNC" }, \ | ||
| 109 | { XFS_TRANS_TRUNCATE_FILE, "TRUNCATE_FILE" }, \ | ||
| 110 | { XFS_TRANS_REMOVE, "REMOVE" }, \ | ||
| 111 | { XFS_TRANS_LINK, "LINK" }, \ | ||
| 112 | { XFS_TRANS_RENAME, "RENAME" }, \ | ||
| 113 | { XFS_TRANS_MKDIR, "MKDIR" }, \ | ||
| 114 | { XFS_TRANS_RMDIR, "RMDIR" }, \ | ||
| 115 | { XFS_TRANS_SYMLINK, "SYMLINK" }, \ | ||
| 116 | { XFS_TRANS_SET_DMATTRS, "SET_DMATTRS" }, \ | ||
| 117 | { XFS_TRANS_GROWFS, "GROWFS" }, \ | ||
| 118 | { XFS_TRANS_STRAT_WRITE, "STRAT_WRITE" }, \ | ||
| 119 | { XFS_TRANS_DIOSTRAT, "DIOSTRAT" }, \ | ||
| 120 | { XFS_TRANS_WRITEID, "WRITEID" }, \ | ||
| 121 | { XFS_TRANS_ADDAFORK, "ADDAFORK" }, \ | ||
| 122 | { XFS_TRANS_ATTRINVAL, "ATTRINVAL" }, \ | ||
| 123 | { XFS_TRANS_ATRUNCATE, "ATRUNCATE" }, \ | ||
| 124 | { XFS_TRANS_ATTR_SET, "ATTR_SET" }, \ | ||
| 125 | { XFS_TRANS_ATTR_RM, "ATTR_RM" }, \ | ||
| 126 | { XFS_TRANS_ATTR_FLAG, "ATTR_FLAG" }, \ | ||
| 127 | { XFS_TRANS_CLEAR_AGI_BUCKET, "CLEAR_AGI_BUCKET" }, \ | ||
| 128 | { XFS_TRANS_QM_SBCHANGE, "QM_SBCHANGE" }, \ | ||
| 129 | { XFS_TRANS_QM_QUOTAOFF, "QM_QUOTAOFF" }, \ | ||
| 130 | { XFS_TRANS_QM_DQALLOC, "QM_DQALLOC" }, \ | ||
| 131 | { XFS_TRANS_QM_SETQLIM, "QM_SETQLIM" }, \ | ||
| 132 | { XFS_TRANS_QM_DQCLUSTER, "QM_DQCLUSTER" }, \ | ||
| 133 | { XFS_TRANS_QM_QINOCREATE, "QM_QINOCREATE" }, \ | ||
| 134 | { XFS_TRANS_QM_QUOTAOFF_END, "QM_QOFF_END" }, \ | ||
| 135 | { XFS_TRANS_SB_UNIT, "SB_UNIT" }, \ | ||
| 136 | { XFS_TRANS_FSYNC_TS, "FSYNC_TS" }, \ | ||
| 137 | { XFS_TRANS_GROWFSRT_ALLOC, "GROWFSRT_ALLOC" }, \ | ||
| 138 | { XFS_TRANS_GROWFSRT_ZERO, "GROWFSRT_ZERO" }, \ | ||
| 139 | { XFS_TRANS_GROWFSRT_FREE, "GROWFSRT_FREE" }, \ | ||
| 140 | { XFS_TRANS_SWAPEXT, "SWAPEXT" }, \ | ||
| 141 | { XFS_TRANS_SB_COUNT, "SB_COUNT" }, \ | ||
| 142 | { XFS_TRANS_DUMMY1, "DUMMY1" }, \ | ||
| 143 | { XFS_TRANS_DUMMY2, "DUMMY2" }, \ | ||
| 144 | { XLOG_UNMOUNT_REC_TYPE, "UNMOUNT" } | ||
| 145 | |||
| 103 | /* | 146 | /* |
| 104 | * This structure is used to track log items associated with | 147 | * This structure is used to track log items associated with |
| 105 | * a transaction. It points to the log item and keeps some | 148 | * a transaction. It points to the log item and keeps some |
| @@ -782,6 +825,10 @@ typedef struct xfs_log_item { | |||
| 782 | #define XFS_LI_IN_AIL 0x1 | 825 | #define XFS_LI_IN_AIL 0x1 |
| 783 | #define XFS_LI_ABORTED 0x2 | 826 | #define XFS_LI_ABORTED 0x2 |
| 784 | 827 | ||
| 828 | #define XFS_LI_FLAGS \ | ||
| 829 | { XFS_LI_IN_AIL, "IN_AIL" }, \ | ||
| 830 | { XFS_LI_ABORTED, "ABORTED" } | ||
| 831 | |||
| 785 | typedef struct xfs_item_ops { | 832 | typedef struct xfs_item_ops { |
| 786 | uint (*iop_size)(xfs_log_item_t *); | 833 | uint (*iop_size)(xfs_log_item_t *); |
| 787 | void (*iop_format)(xfs_log_item_t *, struct xfs_log_iovec *); | 834 | void (*iop_format)(xfs_log_item_t *, struct xfs_log_iovec *); |
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c index 03a1f701fea8..49130628d5ef 100644 --- a/fs/xfs/xfs_trans_buf.c +++ b/fs/xfs/xfs_trans_buf.c | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | #include "xfs_trans_priv.h" | 38 | #include "xfs_trans_priv.h" |
| 39 | #include "xfs_error.h" | 39 | #include "xfs_error.h" |
| 40 | #include "xfs_rw.h" | 40 | #include "xfs_rw.h" |
| 41 | #include "xfs_trace.h" | ||
| 41 | 42 | ||
| 42 | 43 | ||
| 43 | STATIC xfs_buf_t *xfs_trans_buf_item_match(xfs_trans_t *, xfs_buftarg_t *, | 44 | STATIC xfs_buf_t *xfs_trans_buf_item_match(xfs_trans_t *, xfs_buftarg_t *, |
| @@ -95,26 +96,23 @@ xfs_trans_get_buf(xfs_trans_t *tp, | |||
| 95 | } | 96 | } |
| 96 | if (bp != NULL) { | 97 | if (bp != NULL) { |
| 97 | ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); | 98 | ASSERT(XFS_BUF_VALUSEMA(bp) <= 0); |
| 98 | if (XFS_FORCED_SHUTDOWN(tp->t_mountp)) { | 99 | if (XFS_FORCED_SHUTDOWN(tp->t_mountp)) |
| 99 | xfs_buftrace("TRANS GET RECUR SHUT", bp); | ||
| 100 | XFS_BUF_SUPER_STALE(bp); | 100 | XFS_BUF_SUPER_STALE(bp); |
| 101 | } | 101 | |
| 102 | /* | 102 | /* |
| 103 | * If the buffer is stale then it was binval'ed | 103 | * If the buffer is stale then it was binval'ed |
| 104 | * since last read. This doesn't matter since the | 104 | * since last read. This doesn't matter since the |
| 105 | * caller isn't allowed to use the data anyway. | 105 | * caller isn't allowed to use the data anyway. |
| 106 | */ | 106 | */ |
| 107 | else if (XFS_BUF_ISSTALE(bp)) { | 107 | else if (XFS_BUF_ISSTALE(bp)) |
| 108 | xfs_buftrace("TRANS GET RECUR STALE", bp); | ||
| 109 | ASSERT(!XFS_BUF_ISDELAYWRITE(bp)); | 108 | ASSERT(!XFS_BUF_ISDELAYWRITE(bp)); |
| 110 | } | 109 | |
| 111 | ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp); | 110 | ASSERT(XFS_BUF_FSPRIVATE2(bp, xfs_trans_t *) == tp); |
| 112 | bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *); | 111 | bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *); |
| 113 | ASSERT(bip != NULL); | 112 | ASSERT(bip != NULL); |
| 114 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 113 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
| 115 | bip->bli_recur++; | 114 | bip->bli_recur++; |
| 116 | xfs_buftrace("TRANS GET RECUR", bp); | 115 | trace_xfs_trans_get_buf_recur(bip); |
| 117 | xfs_buf_item_trace("GET RECUR", bip); | ||
| 118 | return (bp); | 116 | return (bp); |
| 119 | } | 117 | } |
| 120 | 118 | ||
| @@ -166,8 +164,7 @@ xfs_trans_get_buf(xfs_trans_t *tp, | |||
| 166 | */ | 164 | */ |
| 167 | XFS_BUF_SET_FSPRIVATE2(bp, tp); | 165 | XFS_BUF_SET_FSPRIVATE2(bp, tp); |
| 168 | 166 | ||
| 169 | xfs_buftrace("TRANS GET", bp); | 167 | trace_xfs_trans_get_buf(bip); |
| 170 | xfs_buf_item_trace("GET", bip); | ||
| 171 | return (bp); | 168 | return (bp); |
| 172 | } | 169 | } |
| 173 | 170 | ||
| @@ -207,7 +204,7 @@ xfs_trans_getsb(xfs_trans_t *tp, | |||
| 207 | ASSERT(bip != NULL); | 204 | ASSERT(bip != NULL); |
| 208 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 205 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
| 209 | bip->bli_recur++; | 206 | bip->bli_recur++; |
| 210 | xfs_buf_item_trace("GETSB RECUR", bip); | 207 | trace_xfs_trans_getsb_recur(bip); |
| 211 | return (bp); | 208 | return (bp); |
| 212 | } | 209 | } |
| 213 | 210 | ||
| @@ -249,7 +246,7 @@ xfs_trans_getsb(xfs_trans_t *tp, | |||
| 249 | */ | 246 | */ |
| 250 | XFS_BUF_SET_FSPRIVATE2(bp, tp); | 247 | XFS_BUF_SET_FSPRIVATE2(bp, tp); |
| 251 | 248 | ||
| 252 | xfs_buf_item_trace("GETSB", bip); | 249 | trace_xfs_trans_getsb(bip); |
| 253 | return (bp); | 250 | return (bp); |
| 254 | } | 251 | } |
| 255 | 252 | ||
| @@ -347,7 +344,7 @@ xfs_trans_read_buf( | |||
| 347 | ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL); | 344 | ASSERT(XFS_BUF_FSPRIVATE(bp, void *) != NULL); |
| 348 | ASSERT((XFS_BUF_ISERROR(bp)) == 0); | 345 | ASSERT((XFS_BUF_ISERROR(bp)) == 0); |
| 349 | if (!(XFS_BUF_ISDONE(bp))) { | 346 | if (!(XFS_BUF_ISDONE(bp))) { |
| 350 | xfs_buftrace("READ_BUF_INCORE !DONE", bp); | 347 | trace_xfs_trans_read_buf_io(bp, _RET_IP_); |
| 351 | ASSERT(!XFS_BUF_ISASYNC(bp)); | 348 | ASSERT(!XFS_BUF_ISASYNC(bp)); |
| 352 | XFS_BUF_READ(bp); | 349 | XFS_BUF_READ(bp); |
| 353 | xfsbdstrat(tp->t_mountp, bp); | 350 | xfsbdstrat(tp->t_mountp, bp); |
| @@ -372,7 +369,7 @@ xfs_trans_read_buf( | |||
| 372 | * brelse it either. Just get out. | 369 | * brelse it either. Just get out. |
| 373 | */ | 370 | */ |
| 374 | if (XFS_FORCED_SHUTDOWN(mp)) { | 371 | if (XFS_FORCED_SHUTDOWN(mp)) { |
| 375 | xfs_buftrace("READ_BUF_INCORE XFSSHUTDN", bp); | 372 | trace_xfs_trans_read_buf_shut(bp, _RET_IP_); |
| 376 | *bpp = NULL; | 373 | *bpp = NULL; |
| 377 | return XFS_ERROR(EIO); | 374 | return XFS_ERROR(EIO); |
| 378 | } | 375 | } |
| @@ -382,7 +379,7 @@ xfs_trans_read_buf( | |||
| 382 | bip->bli_recur++; | 379 | bip->bli_recur++; |
| 383 | 380 | ||
| 384 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 381 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
| 385 | xfs_buf_item_trace("READ RECUR", bip); | 382 | trace_xfs_trans_read_buf_recur(bip); |
| 386 | *bpp = bp; | 383 | *bpp = bp; |
| 387 | return 0; | 384 | return 0; |
| 388 | } | 385 | } |
| @@ -402,7 +399,6 @@ xfs_trans_read_buf( | |||
| 402 | } | 399 | } |
| 403 | if (XFS_BUF_GETERROR(bp) != 0) { | 400 | if (XFS_BUF_GETERROR(bp) != 0) { |
| 404 | XFS_BUF_SUPER_STALE(bp); | 401 | XFS_BUF_SUPER_STALE(bp); |
| 405 | xfs_buftrace("READ ERROR", bp); | ||
| 406 | error = XFS_BUF_GETERROR(bp); | 402 | error = XFS_BUF_GETERROR(bp); |
| 407 | 403 | ||
| 408 | xfs_ioerror_alert("xfs_trans_read_buf", mp, | 404 | xfs_ioerror_alert("xfs_trans_read_buf", mp, |
| @@ -461,8 +457,7 @@ xfs_trans_read_buf( | |||
| 461 | */ | 457 | */ |
| 462 | XFS_BUF_SET_FSPRIVATE2(bp, tp); | 458 | XFS_BUF_SET_FSPRIVATE2(bp, tp); |
| 463 | 459 | ||
| 464 | xfs_buftrace("TRANS READ", bp); | 460 | trace_xfs_trans_read_buf(bip); |
| 465 | xfs_buf_item_trace("READ", bip); | ||
| 466 | *bpp = bp; | 461 | *bpp = bp; |
| 467 | return 0; | 462 | return 0; |
| 468 | 463 | ||
| @@ -480,7 +475,7 @@ shutdown_abort: | |||
| 480 | ASSERT((XFS_BUF_BFLAGS(bp) & (XFS_B_STALE|XFS_B_DELWRI)) != | 475 | ASSERT((XFS_BUF_BFLAGS(bp) & (XFS_B_STALE|XFS_B_DELWRI)) != |
| 481 | (XFS_B_STALE|XFS_B_DELWRI)); | 476 | (XFS_B_STALE|XFS_B_DELWRI)); |
| 482 | 477 | ||
| 483 | xfs_buftrace("READ_BUF XFSSHUTDN", bp); | 478 | trace_xfs_trans_read_buf_shut(bp, _RET_IP_); |
| 484 | xfs_buf_relse(bp); | 479 | xfs_buf_relse(bp); |
| 485 | *bpp = NULL; | 480 | *bpp = NULL; |
| 486 | return XFS_ERROR(EIO); | 481 | return XFS_ERROR(EIO); |
| @@ -546,13 +541,14 @@ xfs_trans_brelse(xfs_trans_t *tp, | |||
| 546 | lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)bip); | 541 | lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)bip); |
| 547 | ASSERT(lidp != NULL); | 542 | ASSERT(lidp != NULL); |
| 548 | 543 | ||
| 544 | trace_xfs_trans_brelse(bip); | ||
| 545 | |||
| 549 | /* | 546 | /* |
| 550 | * If the release is just for a recursive lock, | 547 | * If the release is just for a recursive lock, |
| 551 | * then decrement the count and return. | 548 | * then decrement the count and return. |
| 552 | */ | 549 | */ |
| 553 | if (bip->bli_recur > 0) { | 550 | if (bip->bli_recur > 0) { |
| 554 | bip->bli_recur--; | 551 | bip->bli_recur--; |
| 555 | xfs_buf_item_trace("RELSE RECUR", bip); | ||
| 556 | return; | 552 | return; |
| 557 | } | 553 | } |
| 558 | 554 | ||
| @@ -560,10 +556,8 @@ xfs_trans_brelse(xfs_trans_t *tp, | |||
| 560 | * If the buffer is dirty within this transaction, we can't | 556 | * If the buffer is dirty within this transaction, we can't |
| 561 | * release it until we commit. | 557 | * release it until we commit. |
| 562 | */ | 558 | */ |
| 563 | if (lidp->lid_flags & XFS_LID_DIRTY) { | 559 | if (lidp->lid_flags & XFS_LID_DIRTY) |
| 564 | xfs_buf_item_trace("RELSE DIRTY", bip); | ||
| 565 | return; | 560 | return; |
| 566 | } | ||
| 567 | 561 | ||
| 568 | /* | 562 | /* |
| 569 | * If the buffer has been invalidated, then we can't release | 563 | * If the buffer has been invalidated, then we can't release |
| @@ -571,13 +565,10 @@ xfs_trans_brelse(xfs_trans_t *tp, | |||
| 571 | * as part of this transaction. This prevents us from pulling | 565 | * as part of this transaction. This prevents us from pulling |
| 572 | * the item from the AIL before we should. | 566 | * the item from the AIL before we should. |
| 573 | */ | 567 | */ |
| 574 | if (bip->bli_flags & XFS_BLI_STALE) { | 568 | if (bip->bli_flags & XFS_BLI_STALE) |
| 575 | xfs_buf_item_trace("RELSE STALE", bip); | ||
| 576 | return; | 569 | return; |
| 577 | } | ||
| 578 | 570 | ||
| 579 | ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED)); | 571 | ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED)); |
| 580 | xfs_buf_item_trace("RELSE", bip); | ||
| 581 | 572 | ||
| 582 | /* | 573 | /* |
| 583 | * Free up the log item descriptor tracking the released item. | 574 | * Free up the log item descriptor tracking the released item. |
| @@ -674,7 +665,7 @@ xfs_trans_bjoin(xfs_trans_t *tp, | |||
| 674 | */ | 665 | */ |
| 675 | XFS_BUF_SET_FSPRIVATE2(bp, tp); | 666 | XFS_BUF_SET_FSPRIVATE2(bp, tp); |
| 676 | 667 | ||
| 677 | xfs_buf_item_trace("BJOIN", bip); | 668 | trace_xfs_trans_bjoin(bip); |
| 678 | } | 669 | } |
| 679 | 670 | ||
| 680 | /* | 671 | /* |
| @@ -698,7 +689,7 @@ xfs_trans_bhold(xfs_trans_t *tp, | |||
| 698 | ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL)); | 689 | ASSERT(!(bip->bli_format.blf_flags & XFS_BLI_CANCEL)); |
| 699 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 690 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
| 700 | bip->bli_flags |= XFS_BLI_HOLD; | 691 | bip->bli_flags |= XFS_BLI_HOLD; |
| 701 | xfs_buf_item_trace("BHOLD", bip); | 692 | trace_xfs_trans_bhold(bip); |
| 702 | } | 693 | } |
| 703 | 694 | ||
| 704 | /* | 695 | /* |
| @@ -721,7 +712,8 @@ xfs_trans_bhold_release(xfs_trans_t *tp, | |||
| 721 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 712 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
| 722 | ASSERT(bip->bli_flags & XFS_BLI_HOLD); | 713 | ASSERT(bip->bli_flags & XFS_BLI_HOLD); |
| 723 | bip->bli_flags &= ~XFS_BLI_HOLD; | 714 | bip->bli_flags &= ~XFS_BLI_HOLD; |
| 724 | xfs_buf_item_trace("BHOLD RELEASE", bip); | 715 | |
| 716 | trace_xfs_trans_bhold_release(bip); | ||
| 725 | } | 717 | } |
| 726 | 718 | ||
| 727 | /* | 719 | /* |
| @@ -767,6 +759,8 @@ xfs_trans_log_buf(xfs_trans_t *tp, | |||
| 767 | XFS_BUF_SET_IODONE_FUNC(bp, xfs_buf_iodone_callbacks); | 759 | XFS_BUF_SET_IODONE_FUNC(bp, xfs_buf_iodone_callbacks); |
| 768 | bip->bli_item.li_cb = (void(*)(xfs_buf_t*,xfs_log_item_t*))xfs_buf_iodone; | 760 | bip->bli_item.li_cb = (void(*)(xfs_buf_t*,xfs_log_item_t*))xfs_buf_iodone; |
| 769 | 761 | ||
| 762 | trace_xfs_trans_log_buf(bip); | ||
| 763 | |||
| 770 | /* | 764 | /* |
| 771 | * If we invalidated the buffer within this transaction, then | 765 | * If we invalidated the buffer within this transaction, then |
| 772 | * cancel the invalidation now that we're dirtying the buffer | 766 | * cancel the invalidation now that we're dirtying the buffer |
| @@ -774,7 +768,6 @@ xfs_trans_log_buf(xfs_trans_t *tp, | |||
| 774 | * because we have a reference to the buffer this entire time. | 768 | * because we have a reference to the buffer this entire time. |
| 775 | */ | 769 | */ |
| 776 | if (bip->bli_flags & XFS_BLI_STALE) { | 770 | if (bip->bli_flags & XFS_BLI_STALE) { |
| 777 | xfs_buf_item_trace("BLOG UNSTALE", bip); | ||
| 778 | bip->bli_flags &= ~XFS_BLI_STALE; | 771 | bip->bli_flags &= ~XFS_BLI_STALE; |
| 779 | ASSERT(XFS_BUF_ISSTALE(bp)); | 772 | ASSERT(XFS_BUF_ISSTALE(bp)); |
| 780 | XFS_BUF_UNSTALE(bp); | 773 | XFS_BUF_UNSTALE(bp); |
| @@ -789,7 +782,6 @@ xfs_trans_log_buf(xfs_trans_t *tp, | |||
| 789 | lidp->lid_flags &= ~XFS_LID_BUF_STALE; | 782 | lidp->lid_flags &= ~XFS_LID_BUF_STALE; |
| 790 | bip->bli_flags |= XFS_BLI_LOGGED; | 783 | bip->bli_flags |= XFS_BLI_LOGGED; |
| 791 | xfs_buf_item_log(bip, first, last); | 784 | xfs_buf_item_log(bip, first, last); |
| 792 | xfs_buf_item_trace("BLOG", bip); | ||
| 793 | } | 785 | } |
| 794 | 786 | ||
| 795 | 787 | ||
| @@ -828,6 +820,8 @@ xfs_trans_binval( | |||
| 828 | ASSERT(lidp != NULL); | 820 | ASSERT(lidp != NULL); |
| 829 | ASSERT(atomic_read(&bip->bli_refcount) > 0); | 821 | ASSERT(atomic_read(&bip->bli_refcount) > 0); |
| 830 | 822 | ||
| 823 | trace_xfs_trans_binval(bip); | ||
| 824 | |||
| 831 | if (bip->bli_flags & XFS_BLI_STALE) { | 825 | if (bip->bli_flags & XFS_BLI_STALE) { |
| 832 | /* | 826 | /* |
| 833 | * If the buffer is already invalidated, then | 827 | * If the buffer is already invalidated, then |
| @@ -840,8 +834,6 @@ xfs_trans_binval( | |||
| 840 | ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL); | 834 | ASSERT(bip->bli_format.blf_flags & XFS_BLI_CANCEL); |
| 841 | ASSERT(lidp->lid_flags & XFS_LID_DIRTY); | 835 | ASSERT(lidp->lid_flags & XFS_LID_DIRTY); |
| 842 | ASSERT(tp->t_flags & XFS_TRANS_DIRTY); | 836 | ASSERT(tp->t_flags & XFS_TRANS_DIRTY); |
| 843 | xfs_buftrace("XFS_BINVAL RECUR", bp); | ||
| 844 | xfs_buf_item_trace("BINVAL RECUR", bip); | ||
| 845 | return; | 837 | return; |
| 846 | } | 838 | } |
| 847 | 839 | ||
| @@ -875,8 +867,6 @@ xfs_trans_binval( | |||
| 875 | (bip->bli_format.blf_map_size * sizeof(uint))); | 867 | (bip->bli_format.blf_map_size * sizeof(uint))); |
| 876 | lidp->lid_flags |= XFS_LID_DIRTY|XFS_LID_BUF_STALE; | 868 | lidp->lid_flags |= XFS_LID_DIRTY|XFS_LID_BUF_STALE; |
| 877 | tp->t_flags |= XFS_TRANS_DIRTY; | 869 | tp->t_flags |= XFS_TRANS_DIRTY; |
| 878 | xfs_buftrace("XFS_BINVAL", bp); | ||
| 879 | xfs_buf_item_trace("BINVAL", bip); | ||
| 880 | } | 870 | } |
| 881 | 871 | ||
| 882 | /* | 872 | /* |
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c index 578f3f59b789..6558ffd8d140 100644 --- a/fs/xfs/xfs_vnodeops.c +++ b/fs/xfs/xfs_vnodeops.c | |||
| @@ -53,6 +53,7 @@ | |||
| 53 | #include "xfs_log_priv.h" | 53 | #include "xfs_log_priv.h" |
| 54 | #include "xfs_filestream.h" | 54 | #include "xfs_filestream.h" |
| 55 | #include "xfs_vnodeops.h" | 55 | #include "xfs_vnodeops.h" |
| 56 | #include "xfs_trace.h" | ||
| 56 | 57 | ||
| 57 | int | 58 | int |
| 58 | xfs_setattr( | 59 | xfs_setattr( |
| @@ -1397,7 +1398,6 @@ xfs_lookup( | |||
| 1397 | if (error) | 1398 | if (error) |
| 1398 | goto out_free_name; | 1399 | goto out_free_name; |
| 1399 | 1400 | ||
| 1400 | xfs_itrace_ref(*ipp); | ||
| 1401 | return 0; | 1401 | return 0; |
| 1402 | 1402 | ||
| 1403 | out_free_name: | 1403 | out_free_name: |
| @@ -1543,7 +1543,6 @@ xfs_create( | |||
| 1543 | * At this point, we've gotten a newly allocated inode. | 1543 | * At this point, we've gotten a newly allocated inode. |
| 1544 | * It is locked (and joined to the transaction). | 1544 | * It is locked (and joined to the transaction). |
| 1545 | */ | 1545 | */ |
| 1546 | xfs_itrace_ref(ip); | ||
| 1547 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 1546 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
| 1548 | 1547 | ||
| 1549 | /* | 1548 | /* |
| @@ -2003,9 +2002,6 @@ xfs_remove( | |||
| 2003 | if (!is_dir && link_zero && xfs_inode_is_filestream(ip)) | 2002 | if (!is_dir && link_zero && xfs_inode_is_filestream(ip)) |
| 2004 | xfs_filestream_deassociate(ip); | 2003 | xfs_filestream_deassociate(ip); |
| 2005 | 2004 | ||
| 2006 | xfs_itrace_exit(ip); | ||
| 2007 | xfs_itrace_exit(dp); | ||
| 2008 | |||
| 2009 | std_return: | 2005 | std_return: |
| 2010 | if (DM_EVENT_ENABLED(dp, DM_EVENT_POSTREMOVE)) { | 2006 | if (DM_EVENT_ENABLED(dp, DM_EVENT_POSTREMOVE)) { |
| 2011 | XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE, dp, DM_RIGHT_NULL, | 2007 | XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE, dp, DM_RIGHT_NULL, |
| @@ -2302,7 +2298,6 @@ xfs_symlink( | |||
| 2302 | goto error_return; | 2298 | goto error_return; |
| 2303 | goto error1; | 2299 | goto error1; |
| 2304 | } | 2300 | } |
| 2305 | xfs_itrace_ref(ip); | ||
| 2306 | 2301 | ||
| 2307 | /* | 2302 | /* |
| 2308 | * An error after we've joined dp to the transaction will result in the | 2303 | * An error after we've joined dp to the transaction will result in the |
| @@ -2845,7 +2840,6 @@ xfs_free_file_space( | |||
| 2845 | ioffset = offset & ~(rounding - 1); | 2840 | ioffset = offset & ~(rounding - 1); |
| 2846 | 2841 | ||
| 2847 | if (VN_CACHED(VFS_I(ip)) != 0) { | 2842 | if (VN_CACHED(VFS_I(ip)) != 0) { |
| 2848 | xfs_inval_cached_trace(ip, ioffset, -1, ioffset, -1); | ||
| 2849 | error = xfs_flushinval_pages(ip, ioffset, -1, FI_REMAPF_LOCKED); | 2843 | error = xfs_flushinval_pages(ip, ioffset, -1, FI_REMAPF_LOCKED); |
| 2850 | if (error) | 2844 | if (error) |
| 2851 | goto out_unlock_iolock; | 2845 | goto out_unlock_iolock; |
