mirror of
https://github.com/versity/scoutfs.git
synced 2026-06-01 09:16:21 +00:00
scoutfs: Tidy some enum usage
Prefer named to anonymous enums. This helps readability a little. Use enum as param type if possible (a couple spots). Remove unused enum in lock_server.c. Define enum spbm_flags using shift notation for consistency. Rename get_file_block()'s "gfb" parameter to "flags" for consistency. Signed-off-by: Andy Grover <agrover@versity.com>
This commit is contained in:
@@ -58,7 +58,7 @@ struct block_info {
|
||||
#define DECLARE_BLOCK_INFO(sb, name) \
|
||||
struct block_info *name = SCOUTFS_SB(sb)->block_info
|
||||
|
||||
enum {
|
||||
enum block_status_bits {
|
||||
BLOCK_BIT_UPTODATE = 0, /* contents consistent with media */
|
||||
BLOCK_BIT_NEW, /* newly allocated, contents undefined */
|
||||
BLOCK_BIT_DIRTY, /* dirty, writer will write */
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
*/
|
||||
|
||||
/* btree walking has a bunch of behavioural bit flags */
|
||||
enum {
|
||||
enum btree_walk_flags {
|
||||
BTW_NEXT = (1 << 0), /* return >= key */
|
||||
BTW_PREV = (1 << 1), /* return <= key */
|
||||
BTW_DIRTY = (1 << 2), /* cow stable blocks */
|
||||
|
||||
@@ -78,7 +78,7 @@ static unsigned int mode_to_type(umode_t mode)
|
||||
#undef S_SHIFT
|
||||
}
|
||||
|
||||
static unsigned int dentry_type(unsigned int type)
|
||||
static unsigned int dentry_type(enum scoutfs_dentry_type type)
|
||||
{
|
||||
static unsigned char types[] = {
|
||||
[SCOUTFS_DT_FIFO] = DT_FIFO,
|
||||
@@ -988,12 +988,12 @@ static void init_symlink_key(struct scoutfs_key *key, u64 ino, u8 nr)
|
||||
* The target name can be null for deletion when val isn't used. Size
|
||||
* still has to be provided to determine the number of items.
|
||||
*/
|
||||
enum {
|
||||
enum symlink_ops {
|
||||
SYM_CREATE = 0,
|
||||
SYM_LOOKUP,
|
||||
SYM_DELETE,
|
||||
};
|
||||
static int symlink_item_ops(struct super_block *sb, int op, u64 ino,
|
||||
static int symlink_item_ops(struct super_block *sb, enum symlink_ops op, u64 ino,
|
||||
struct scoutfs_lock *lock, const char *target,
|
||||
size_t size)
|
||||
{
|
||||
|
||||
@@ -708,7 +708,7 @@ struct scoutfs_dirent {
|
||||
/* getdents returns next pos with an entry, no entry at (f_pos)~0 */
|
||||
#define SCOUTFS_DIRENT_LAST_POS (U64_MAX - 1)
|
||||
|
||||
enum {
|
||||
enum scoutfs_dentry_type {
|
||||
SCOUTFS_DT_FIFO = 0,
|
||||
SCOUTFS_DT_CHR,
|
||||
SCOUTFS_DT_DIR,
|
||||
@@ -806,7 +806,7 @@ struct scoutfs_net_header {
|
||||
#define SCOUTFS_NET_FLAG_RESPONSE (1 << 0)
|
||||
#define SCOUTFS_NET_FLAGS_UNKNOWN (U8_MAX << 1)
|
||||
|
||||
enum {
|
||||
enum scoutfs_net_cmd {
|
||||
SCOUTFS_NET_CMD_GREETING = 0,
|
||||
SCOUTFS_NET_CMD_ALLOC_INODES,
|
||||
SCOUTFS_NET_CMD_GET_LOG_TREES,
|
||||
@@ -836,7 +836,7 @@ enum {
|
||||
|
||||
#undef EXPAND_NET_ERRNO
|
||||
#define EXPAND_NET_ERRNO(which) SCOUTFS_NET_ERR_##which,
|
||||
enum {
|
||||
enum scoutfs_net_errors {
|
||||
SCOUTFS_NET_ERR_NONE = 0,
|
||||
EXPAND_EACH_NET_ERRNO
|
||||
SCOUTFS_NET_ERR_UNKNOWN,
|
||||
@@ -884,7 +884,7 @@ struct scoutfs_net_lock_recover {
|
||||
sizeof(struct scoutfs_net_lock))
|
||||
|
||||
/* some enums for tracing */
|
||||
enum {
|
||||
enum scoutfs_lock_trace {
|
||||
SLT_CLIENT,
|
||||
SLT_SERVER,
|
||||
SLT_GRANT,
|
||||
@@ -928,7 +928,7 @@ struct scoutfs_fid {
|
||||
/*
|
||||
* Identifiers for sources of corruption that can generate messages.
|
||||
*/
|
||||
enum {
|
||||
enum scoutfs_corruption_sources {
|
||||
SC_DIRENT_NAME_LEN = 0,
|
||||
SC_DIRENT_BACKREF_NAME_LEN,
|
||||
SC_DIRENT_READDIR_NAME_LEN,
|
||||
|
||||
@@ -78,7 +78,7 @@ struct scoutfs_ioctl_walk_inodes {
|
||||
__u8 _pad[11]; /* padded to align walk_inodes_entry total size */
|
||||
};
|
||||
|
||||
enum {
|
||||
enum scoutfs_ino_walk_seq_type {
|
||||
SCOUTFS_IOC_WALK_INODES_META_SEQ = 0,
|
||||
SCOUTFS_IOC_WALK_INODES_DATA_SEQ,
|
||||
SCOUTFS_IOC_WALK_INODES_UNKNOWN,
|
||||
|
||||
@@ -715,7 +715,7 @@ static void move_page_items(struct super_block *sb,
|
||||
}
|
||||
}
|
||||
|
||||
enum {
|
||||
enum page_intersection_type {
|
||||
PGI_DISJOINT,
|
||||
PGI_INSIDE,
|
||||
PGI_START_OLAP,
|
||||
|
||||
@@ -118,12 +118,6 @@ struct server_lock_node {
|
||||
struct list_head invalidated;
|
||||
};
|
||||
|
||||
enum {
|
||||
CLE_GRANTED,
|
||||
CLE_REQUESTED,
|
||||
CLE_INVALIDATED,
|
||||
};
|
||||
|
||||
/*
|
||||
* Interactions with the client are tracked with these little mode
|
||||
* wrappers.
|
||||
|
||||
@@ -100,7 +100,7 @@ do { \
|
||||
} while (0)
|
||||
|
||||
/* listening and their accepting sockets have a fixed locking order */
|
||||
enum {
|
||||
enum spin_lock_subtype {
|
||||
CONN_LOCK_LISTENER,
|
||||
CONN_LOCK_ACCEPTED,
|
||||
};
|
||||
|
||||
@@ -76,7 +76,7 @@ struct scoutfs_net_connection {
|
||||
void *info;
|
||||
};
|
||||
|
||||
enum {
|
||||
enum conn_flags {
|
||||
CONN_FL_valid_greeting = (1UL << 0), /* other commands can proceed */
|
||||
CONN_FL_established = (1UL << 1), /* added sends queue send work */
|
||||
CONN_FL_shutting_down = (1UL << 2), /* shutdown work was queued */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <linux/in.h>
|
||||
#include "format.h"
|
||||
|
||||
enum {
|
||||
enum scoutfs_mount_options {
|
||||
Opt_server_addr,
|
||||
Opt_metadev_path,
|
||||
Opt_err,
|
||||
|
||||
@@ -47,9 +47,9 @@ bool scoutfs_spbm_empty(struct scoutfs_spbm *spbm)
|
||||
return RB_EMPTY_ROOT(&spbm->root);
|
||||
}
|
||||
|
||||
enum {
|
||||
enum spbm_flags {
|
||||
/* if a node isn't found then return an allocated new node */
|
||||
SPBM_FIND_ALLOC = 0x1,
|
||||
SPBM_FIND_ALLOC = (1 << 0),
|
||||
};
|
||||
static struct spbm_node *find_node(struct scoutfs_spbm *spbm, u64 index,
|
||||
int flags)
|
||||
|
||||
@@ -356,7 +356,7 @@ static int read_path_block(struct super_block *sb,
|
||||
* allocate new blocks, or return errors for missing blocks (files are
|
||||
* never sparse, this won't happen).
|
||||
*/
|
||||
enum {
|
||||
enum gfb_flags {
|
||||
GFB_INSERT = (1 << 0),
|
||||
GFB_DIRTY = (1 << 1),
|
||||
};
|
||||
@@ -364,7 +364,7 @@ static int get_file_block(struct super_block *sb,
|
||||
struct scoutfs_alloc *alloc,
|
||||
struct scoutfs_block_writer *wri,
|
||||
struct scoutfs_srch_file *sfl,
|
||||
int gfb, u64 blk, struct scoutfs_block **bl_ret)
|
||||
int flags, u64 blk, struct scoutfs_block **bl_ret)
|
||||
{
|
||||
struct scoutfs_block *parent = NULL;
|
||||
struct scoutfs_block_header *hdr;
|
||||
@@ -382,7 +382,7 @@ static int get_file_block(struct super_block *sb,
|
||||
/* see if we need to grow to insert a new largest blk */
|
||||
hei = height_for_blk(blk);
|
||||
while (sfl->height < hei) {
|
||||
if (!(gfb & GFB_INSERT)) {
|
||||
if (!(flags & GFB_INSERT)) {
|
||||
ret = -ENOENT;
|
||||
goto out;
|
||||
}
|
||||
@@ -419,8 +419,8 @@ static int get_file_block(struct super_block *sb,
|
||||
level = sfl->height;
|
||||
ref = &sfl->ref;
|
||||
while (level--) {
|
||||
/* searchin an unused part of the tree */
|
||||
if (!ref->blkno && !(gfb & GFB_INSERT)) {
|
||||
/* searching an unused part of the tree */
|
||||
if (!ref->blkno && !(flags & GFB_INSERT)) {
|
||||
ret = -ENOENT;
|
||||
goto out;
|
||||
}
|
||||
@@ -433,7 +433,7 @@ static int get_file_block(struct super_block *sb,
|
||||
}
|
||||
|
||||
/* allocate a new block if we need it */
|
||||
if (!ref->blkno || ((gfb & GFB_DIRTY) &&
|
||||
if (!ref->blkno || ((flags & GFB_DIRTY) &&
|
||||
!scoutfs_block_writer_is_dirty(sb, bl))) {
|
||||
ret = scoutfs_alloc_meta(sb, alloc, wri, &blkno);
|
||||
if (ret < 0)
|
||||
@@ -504,7 +504,7 @@ out:
|
||||
}
|
||||
|
||||
/* record that we successfully grew the file */
|
||||
if (ret == 0 && (gfb & GFB_INSERT) && blk >= le64_to_cpu(sfl->blocks))
|
||||
if (ret == 0 && (flags & GFB_INSERT) && blk >= le64_to_cpu(sfl->blocks))
|
||||
sfl->blocks = cpu_to_le64(blk + 1);
|
||||
|
||||
*bl_ret = bl;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef _SCOUTFS_TRIGGERS_H_
|
||||
#define _SCOUTFS_TRIGGERS_H_
|
||||
|
||||
enum {
|
||||
enum scoutfs_trigger {
|
||||
SCOUTFS_TRIGGER_BTREE_STALE_READ,
|
||||
SCOUTFS_TRIGGER_BTREE_ADVANCE_RING_HALF,
|
||||
SCOUTFS_TRIGGER_HARD_STALE_ERROR,
|
||||
|
||||
Reference in New Issue
Block a user