linux/fs/dlm/user.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2006-2010 Red Hat, Inc.  All rights reserved.
 */

#include <linux/miscdevice.h>
#include <linux/init.h>
#include <linux/wait.h>
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/poll.h>
#include <linux/signal.h>
#include <linux/spinlock.h>
#include <linux/dlm.h>
#include <linux/dlm_device.h>
#include <linux/slab.h>
#include <linux/sched/signal.h>

#include <trace/events/dlm.h>

#include "dlm_internal.h"
#include "lockspace.h"
#include "lock.h"
#include "lvb_table.h"
#include "user.h"
#include "ast.h"
#include "config.h"
#include "memory.h"

static const char name_prefix[] =;
static const struct file_operations device_fops;
static atomic_t dlm_monitor_opened;
static int dlm_monitor_unused =;

#ifdef CONFIG_COMPAT

struct dlm_lock_params32 {};

struct dlm_write_request32 {};

struct dlm_lksb32 {};

struct dlm_lock_result32 {};

static void compat_input(struct dlm_write_request *kb,
			 struct dlm_write_request32 *kb32,
			 int namelen)
{}

static void compat_output(struct dlm_lock_result *res,
			  struct dlm_lock_result32 *res32)
{}
#endif

/* Figure out if this lock is at the end of its life and no longer
   available for the application to use.  The lkb still exists until
   the final ast is read.  A lock becomes EOL in three situations:
     1. a noqueue request fails with EAGAIN
     2. an unlock completes with EUNLOCK
     3. a cancel of a waiting request completes with ECANCEL/EDEADLK
   An EOL lock needs to be removed from the process's list of locks.
   And we can't allow any new operation on an EOL lock.  This is
   not related to the lifetime of the lkb struct which is managed
   entirely by refcount. */

static int lkb_is_endoflife(int mode, int status)
{}

/* we could possibly check if the cancel of an orphan has resulted in the lkb
   being removed and then remove that lkb from the orphans list and free it */

void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode,
		      int status, uint32_t sbflags)
{}

static int device_user_lock(struct dlm_user_proc *proc,
			    struct dlm_lock_params *params)
{}

static int device_user_unlock(struct dlm_user_proc *proc,
			      struct dlm_lock_params *params)
{}

static int device_user_deadlock(struct dlm_user_proc *proc,
				struct dlm_lock_params *params)
{}

static int dlm_device_register(struct dlm_ls *ls, char *name)
{}

int dlm_device_deregister(struct dlm_ls *ls)
{}

static int device_user_purge(struct dlm_user_proc *proc,
			     struct dlm_purge_params *params)
{}

static int device_create_lockspace(struct dlm_lspace_params *params)
{}

static int device_remove_lockspace(struct dlm_lspace_params *params)
{}

/* Check the user's version matches ours */
static int check_version(struct dlm_write_request *req)
{}

/*
 * device_write
 *
 *   device_user_lock
 *     dlm_user_request -> request_lock
 *     dlm_user_convert -> convert_lock
 *
 *   device_user_unlock
 *     dlm_user_unlock -> unlock_lock
 *     dlm_user_cancel -> cancel_lock
 *
 *   device_create_lockspace
 *     dlm_new_lockspace
 *
 *   device_remove_lockspace
 *     dlm_release_lockspace
 */

/* a write to a lockspace device is a lock or unlock request, a write
   to the control device is to create/remove a lockspace */

static ssize_t device_write(struct file *file, const char __user *buf,
			    size_t count, loff_t *ppos)
{}

/* Every process that opens the lockspace device has its own "proc" structure
   hanging off the open file that's used to keep track of locks owned by the
   process and asts that need to be delivered to the process. */

static int device_open(struct inode *inode, struct file *file)
{}

static int device_close(struct inode *inode, struct file *file)
{}

static int copy_result_to_user(struct dlm_user_args *ua, int compat,
			       uint32_t flags, int mode, int copy_lvb,
			       char __user *buf, size_t count)
{}

static int copy_version_to_user(char __user *buf, size_t count)
{}

/* a read returns a single ast described in a struct dlm_lock_result */

static ssize_t device_read(struct file *file, char __user *buf, size_t count,
			   loff_t *ppos)
{}

static __poll_t device_poll(struct file *file, poll_table *wait)
{}

int dlm_user_daemon_available(void)
{}

static int ctl_device_open(struct inode *inode, struct file *file)
{}

static int ctl_device_close(struct inode *inode, struct file *file)
{}

static int monitor_device_open(struct inode *inode, struct file *file)
{}

static int monitor_device_close(struct inode *inode, struct file *file)
{}

static const struct file_operations device_fops =;

static const struct file_operations ctl_device_fops =;

static struct miscdevice ctl_device =;

static const struct file_operations monitor_device_fops =;

static struct miscdevice monitor_device =;

int __init dlm_user_init(void)
{}

void dlm_user_exit(void)
{}