| .. | .. |
|---|
| 1339 | 1339 | out: |
|---|
| 1340 | 1340 | spin_unlock(&ctx->flc_lock); |
|---|
| 1341 | 1341 | percpu_up_read(&file_rwsem); |
|---|
| 1342 | + trace_posix_lock_inode(inode, request, error); |
|---|
| 1342 | 1343 | /* |
|---|
| 1343 | 1344 | * Free any unused locks. |
|---|
| 1344 | 1345 | */ |
|---|
| .. | .. |
|---|
| 1347 | 1348 | if (new_fl2) |
|---|
| 1348 | 1349 | locks_free_lock(new_fl2); |
|---|
| 1349 | 1350 | locks_dispose_list(&dispose); |
|---|
| 1350 | | - trace_posix_lock_inode(inode, request, error); |
|---|
| 1351 | 1351 | |
|---|
| 1352 | 1352 | return error; |
|---|
| 1353 | 1353 | } |
|---|
| .. | .. |
|---|
| 2813 | 2813 | } |
|---|
| 2814 | 2814 | EXPORT_SYMBOL_GPL(vfs_cancel_lock); |
|---|
| 2815 | 2815 | |
|---|
| 2816 | +/** |
|---|
| 2817 | + * vfs_inode_has_locks - are any file locks held on @inode? |
|---|
| 2818 | + * @inode: inode to check for locks |
|---|
| 2819 | + * |
|---|
| 2820 | + * Return true if there are any FL_POSIX or FL_FLOCK locks currently |
|---|
| 2821 | + * set on @inode. |
|---|
| 2822 | + */ |
|---|
| 2823 | +bool vfs_inode_has_locks(struct inode *inode) |
|---|
| 2824 | +{ |
|---|
| 2825 | + struct file_lock_context *ctx; |
|---|
| 2826 | + bool ret; |
|---|
| 2827 | + |
|---|
| 2828 | + ctx = smp_load_acquire(&inode->i_flctx); |
|---|
| 2829 | + if (!ctx) |
|---|
| 2830 | + return false; |
|---|
| 2831 | + |
|---|
| 2832 | + spin_lock(&ctx->flc_lock); |
|---|
| 2833 | + ret = !list_empty(&ctx->flc_posix) || !list_empty(&ctx->flc_flock); |
|---|
| 2834 | + spin_unlock(&ctx->flc_lock); |
|---|
| 2835 | + return ret; |
|---|
| 2836 | +} |
|---|
| 2837 | +EXPORT_SYMBOL_GPL(vfs_inode_has_locks); |
|---|
| 2838 | + |
|---|
| 2816 | 2839 | #ifdef CONFIG_PROC_FS |
|---|
| 2817 | 2840 | #include <linux/proc_fs.h> |
|---|
| 2818 | 2841 | #include <linux/seq_file.h> |
|---|