/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 only,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is included
* in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
* http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
* Copyright (c) 2010, 2015, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
* Lustre is a trademark of Sun Microsystems, Inc.
*/
/** \defgroup LDLM Lustre Distributed Lock Manager
*
* Lustre DLM is based on VAX DLM.
* Its two main roles are:
* - To provide locking assuring consistency of data on all Lustre nodes.
* - To allow clients to cache state protected by a lock by holding the
* lock until a conflicting lock is requested or it is expired by the LRU.
*
* @{
*/
#ifndef _LUSTRE_DLM_H__
#define _LUSTRE_DLM_H__
#include "lustre_lib.h"
#include "lustre_net.h"
#include "lustre_import.h"
#include "lustre_handles.h"
#include "interval_tree.h" /* for interval_node{}, ldlm_extent */
#include "lu_ref.h"
#include "lustre_dlm_flags.h"
struct obd_ops;
struct obd_device;
#define OBD_LDLM_DEVICENAME "ldlm"
#define LDLM_DEFAULT_LRU_SIZE (100 * num_online_cpus())
#define LDLM_DEFAULT_MAX_ALIVE (cfs_time_seconds(3900)) /* 65 min */
#define LDLM_DEFAULT_PARALLEL_AST_LIMIT 1024
/**
* LDLM non-error return states
*/
enum ldlm_error {
ELDLM_OK = 0,
ELDLM_LOCK_MATCHED = 1,
ELDLM_LOCK_CHANGED = 300,
ELDLM_LOCK_ABORTED = 301,
ELDLM_LOCK_REPLACED = 302,
ELDLM_NO_LOCK_DATA = 303,
ELDLM_LOCK_WOULDBLOCK = 304,
ELDLM_NAMESPACE_EXISTS = 400,
ELDLM_BAD_NAMESPACE = 401
};
/**
* LDLM namespace type.
* The "client" type is actually an indication that this is a narrow local view
* into complete namespace on the server. Such namespaces cannot make any
* decisions about lack of conflicts or do any autonomous lock granting without
* first speaking to a server.
*/
typedef enum {
LDLM_NAMESPACE_SERVER = 1 << 0,
LDLM_NAMESPACE_CLIENT = 1 << 1
} ldlm_side_t;
/**
* The blocking callback is overloaded to perform two functions. These flags
* indicate which operation should be performed.
*/
#define LDLM_CB_BLOCKING 1
#define LDLM_CB_CANCELING 2
/**
* \name Lock Compatibility Matrix.
*
* A lock has both a type (extent, flock, inode bits, or plain) and a mode.
* Lock types are described in their respective implementation files:
* ldlm_{extent,flock,inodebits,plain}.c.
*
* There are six lock modes along with a compatibility matrix to indicate if
* two locks are compatible.
*
* - EX: Exclusive mode. Before a new file is created, MDS requests EX lock
* on the parent.
* - PW: Protective Write (normal write) mode. When a client requests a write
* lock from an OST, a lock with PW mode will be issued.
* - PR: Protective Read (normal read) mode. When a client requests a read from
* an OST, a lock with PR mode will be issued. Also, if the client opens a
* file for execution, it is granted a lock with PR mode.
* - CW: Concurrent Write mode. The type of lock that the MDS grants if a client
* requests a write lock during a file open operation.
* - CR Concurrent Read mode. When a client performs a path lookup, MDS grants
* an inodebit lock with the CR mode on the intermediate path component.
* - NL Null mode.
*
* <PRE>
* NL CR CW PR PW EX
* NL 1 1 1 1 1 1
* CR 1 1 1 1 1 0
* CW 1 1 1 0 0 0
* PR 1 1 0 1 0 0
* PW 1 1 0 0 0 0
* EX 1 0 0 0 0 0
* </PRE>
*/
/** @{ */
#define LCK_COMPAT_EX LCK_NL
#define LCK_COMPAT_PW (LCK_COMPAT_EX | LCK_CR)