WIP: merge_config
[platform/kernel/linux-starfive.git] / fs / locks.c
index 607f94a..7dc129c 100644 (file)
@@ -2669,6 +2669,29 @@ int vfs_cancel_lock(struct file *filp, struct file_lock *fl)
 }
 EXPORT_SYMBOL_GPL(vfs_cancel_lock);
 
+/**
+ * vfs_inode_has_locks - are any file locks held on @inode?
+ * @inode: inode to check for locks
+ *
+ * Return true if there are any FL_POSIX or FL_FLOCK locks currently
+ * set on @inode.
+ */
+bool vfs_inode_has_locks(struct inode *inode)
+{
+       struct file_lock_context *ctx;
+       bool ret;
+
+       ctx = smp_load_acquire(&inode->i_flctx);
+       if (!ctx)
+               return false;
+
+       spin_lock(&ctx->flc_lock);
+       ret = !list_empty(&ctx->flc_posix) || !list_empty(&ctx->flc_flock);
+       spin_unlock(&ctx->flc_lock);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(vfs_inode_has_locks);
+
 #ifdef CONFIG_PROC_FS
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>