super.h 34.8 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
S
Sage Weil 已提交
2 3 4
#ifndef _FS_CEPH_SUPER_H
#define _FS_CEPH_SUPER_H

5
#include <linux/ceph/ceph_debug.h>
S
Sage Weil 已提交
6 7 8 9 10 11 12 13 14

#include <asm/unaligned.h>
#include <linux/backing-dev.h>
#include <linux/completion.h>
#include <linux/exportfs.h>
#include <linux/fs.h>
#include <linux/mempool.h>
#include <linux/pagemap.h>
#include <linux/wait.h>
15
#include <linux/writeback.h>
16
#include <linux/slab.h>
17
#include <linux/posix_acl.h>
18
#include <linux/refcount.h>
S
Sage Weil 已提交
19

20
#include <linux/ceph/libceph.h>
S
Sage Weil 已提交
21

22 23 24 25
#ifdef CONFIG_CEPH_FSCACHE
#include <linux/fscache.h>
#endif

S
Sage Weil 已提交
26 27 28 29 30
/* f_type in struct statfs */
#define CEPH_SUPER_MAGIC 0x00c36400

/* large granularity for statfs utilization stats to facilitate
 * large volume sizes on 32-bit machines. */
S
Sage Weil 已提交
31
#define CEPH_BLOCK_SHIFT   22  /* 4 MB */
S
Sage Weil 已提交
32 33
#define CEPH_BLOCK         (1 << CEPH_BLOCK_SHIFT)

34 35 36
#define CEPH_MOUNT_OPT_DIRSTAT         (1<<4) /* `cat dirname` for stats */
#define CEPH_MOUNT_OPT_RBYTES          (1<<5) /* dir st_bytes = rbytes */
#define CEPH_MOUNT_OPT_NOASYNCREADDIR  (1<<7) /* no dcache readdir */
37
#define CEPH_MOUNT_OPT_INO32           (1<<8) /* 32 bit inos */
38
#define CEPH_MOUNT_OPT_DCACHE          (1<<9) /* use dcache for readdir etc */
39
#define CEPH_MOUNT_OPT_FSCACHE         (1<<10) /* use fscache */
40
#define CEPH_MOUNT_OPT_NOPOOLPERM      (1<<11) /* no pool permission check */
41
#define CEPH_MOUNT_OPT_MOUNTWAIT       (1<<12) /* mount waits if no mds is up */
42
#define CEPH_MOUNT_OPT_NOQUOTADF       (1<<13) /* no root dir quota in statfs */
43
#define CEPH_MOUNT_OPT_NOCOPYFROM      (1<<14) /* don't use RADOS 'copy-from' op */
44

45 46 47
#define CEPH_MOUNT_OPT_DEFAULT			\
	(CEPH_MOUNT_OPT_DCACHE |		\
	 CEPH_MOUNT_OPT_NOCOPYFROM)
S
Sage Weil 已提交
48

49 50 51 52
#define ceph_set_mount_opt(fsc, opt) \
	(fsc)->mount_options->flags |= CEPH_MOUNT_OPT_##opt;
#define ceph_test_mount_opt(fsc, opt) \
	(!!((fsc)->mount_options->flags & CEPH_MOUNT_OPT_##opt))
S
Sage Weil 已提交
53

54 55
/* max size of osd read request, limited by libceph */
#define CEPH_MAX_READ_SIZE              CEPH_MSG_MAX_DATA_LEN
Y
Yan, Zheng 已提交
56 57 58
/* osd has a configurable limitaion of max write size.
 * CEPH_MSG_MAX_DATA_LEN should be small enough. */
#define CEPH_MAX_WRITE_SIZE		CEPH_MSG_MAX_DATA_LEN
59
#define CEPH_RASIZE_DEFAULT             (8192*1024)    /* max readahead */
60 61 62
#define CEPH_MAX_READDIR_DEFAULT        1024
#define CEPH_MAX_READDIR_BYTES_DEFAULT  (512*1024)
#define CEPH_SNAPDIRNAME_DEFAULT        ".snap"
S
Sage Weil 已提交
63

64 65 66 67 68 69 70 71 72
/*
 * Delay telling the MDS we no longer want caps, in case we reopen
 * the file.  Delay a minimum amount of time, even if we send a cap
 * message for some other reason.  Otherwise, take the oppotunity to
 * update the mds to avoid sending another message later.
 */
#define CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT      5  /* cap release delay */
#define CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT     60  /* cap release delay */

73
struct ceph_mount_options {
74
	int flags;
75 76
	int sb_flags;

S
Sage Weil 已提交
77 78 79
	int wsize;            /* max write size */
	int rsize;            /* max read size */
	int rasize;           /* max readahead */
80 81
	int congestion_kb;    /* max writeback in flight */
	int caps_wanted_delay_min, caps_wanted_delay_max;
82 83
	int max_readdir;       /* max readdir result (entires) */
	int max_readdir_bytes; /* max readdir result (bytes) */
S
Sage Weil 已提交
84

85 86 87 88
	/*
	 * everything above this point can be memcmp'd; everything below
	 * is handled in compare_mount_options()
	 */
S
Sage Weil 已提交
89

90
	char *snapdir_name;   /* default ".snap" */
91
	char *mds_namespace;  /* default NULL */
92
	char *server_path;    /* default  "/" */
93
	char *fscache_uniq;   /* default NULL */
94
};
S
Sage Weil 已提交
95

96
struct ceph_fs_client {
S
Sage Weil 已提交
97 98
	struct super_block *sb;

99 100
	struct ceph_mount_options *mount_options;
	struct ceph_client *client;
S
Sage Weil 已提交
101

102
	unsigned long mount_state;
103
	int min_caps;                  /* min caps i added */
104
	loff_t max_file_size;
105

106
	struct ceph_mds_client *mdsc;
S
Sage Weil 已提交
107 108 109

	/* writeback */
	mempool_t *wb_pagevec_pool;
110 111
	atomic_long_t writeback_count;

S
Sage Weil 已提交
112 113 114
	struct workqueue_struct *wb_wq;
	struct workqueue_struct *pg_inv_wq;
	struct workqueue_struct *trunc_wq;
115
	struct workqueue_struct *cap_wq;
S
Sage Weil 已提交
116

117
#ifdef CONFIG_DEBUG_FS
118
	struct dentry *debugfs_dentry_lru, *debugfs_caps;
119
	struct dentry *debugfs_congestion_kb;
120
	struct dentry *debugfs_bdi;
121
	struct dentry *debugfs_mdsc, *debugfs_mdsmap;
122
	struct dentry *debugfs_mds_sessions;
123
#endif
124 125 126 127

#ifdef CONFIG_CEPH_FSCACHE
	struct fscache_cookie *fscache;
#endif
S
Sage Weil 已提交
128 129
};

130

S
Sage Weil 已提交
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
/*
 * File i/o capability.  This tracks shared state with the metadata
 * server that allows us to cache or writeback attributes or to read
 * and write data.  For any given inode, we should have one or more
 * capabilities, one issued by each metadata server, and our
 * cumulative access is the OR of all issued capabilities.
 *
 * Each cap is referenced by the inode's i_caps rbtree and by per-mds
 * session capability lists.
 */
struct ceph_cap {
	struct ceph_inode_info *ci;
	struct rb_node ci_node;          /* per-ci cap tree */
	struct ceph_mds_session *session;
	struct list_head session_caps;   /* per-session caplist */
	u64 cap_id;       /* unique cap id (mds provided) */
147 148 149 150 151 152 153 154 155 156 157 158 159 160
	union {
		/* in-use caps */
		struct {
			int issued;       /* latest, from the mds */
			int implemented;  /* implemented superset of
					     issued (for revocation) */
			int mds, mds_wanted;
		};
		/* caps to release */
		struct {
			u64 cap_ino;
			int queue_release;
		};
	};
161 162
	u32 seq, issue_seq, mseq;
	u32 cap_gen;      /* active/stale cycle */
S
Sage Weil 已提交
163 164 165 166 167 168 169 170
	unsigned long last_used;
	struct list_head caps_item;
};

#define CHECK_CAPS_NODELAY    1  /* do not delay any further */
#define CHECK_CAPS_AUTHONLY   2  /* only check auth cap */
#define CHECK_CAPS_FLUSH      4  /* flush any dirty caps */

171 172 173
struct ceph_cap_flush {
	u64 tid;
	int caps; /* 0 means capsnap */
174
	bool wake; /* wake up flush waiters when finish ? */
175 176 177 178
	struct list_head g_list; // global
	struct list_head i_list; // per inode
};

S
Sage Weil 已提交
179 180 181 182 183 184
/*
 * Snapped cap state that is pending flush to mds.  When a snapshot occurs,
 * we first complete any in-process sync writes and writeback any dirty
 * data before flushing the snapped state (tracked here) back to the MDS.
 */
struct ceph_cap_snap {
185
	refcount_t nref;
186
	struct list_head ci_item;
S
Sage Weil 已提交
187

188 189 190
	struct ceph_cap_flush cap_flush;

	u64 follows;
S
Sage Weil 已提交
191 192 193
	int issued, dirty;
	struct ceph_snap_context *context;

A
Al Viro 已提交
194
	umode_t mode;
195 196
	kuid_t uid;
	kgid_t gid;
S
Sage Weil 已提交
197

198
	struct ceph_buffer *xattr_blob;
S
Sage Weil 已提交
199 200 201
	u64 xattr_version;

	u64 size;
202
	struct timespec64 mtime, atime, ctime;
S
Sage Weil 已提交
203
	u64 time_warp_seq;
204 205
	u64 truncate_size;
	u32 truncate_seq;
S
Sage Weil 已提交
206 207
	int writing;   /* a sync write is still in progress */
	int dirty_pages;     /* dirty pages awaiting writeback */
Y
Yan, Zheng 已提交
208
	bool inline_data;
209
	bool need_flush;
S
Sage Weil 已提交
210 211 212 213
};

static inline void ceph_put_cap_snap(struct ceph_cap_snap *capsnap)
{
214
	if (refcount_dec_and_test(&capsnap->nref)) {
215 216
		if (capsnap->xattr_blob)
			ceph_buffer_put(capsnap->xattr_blob);
S
Sage Weil 已提交
217
		kfree(capsnap);
218
	}
S
Sage Weil 已提交
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
}

/*
 * The frag tree describes how a directory is fragmented, potentially across
 * multiple metadata servers.  It is also used to indicate points where
 * metadata authority is delegated, and whether/where metadata is replicated.
 *
 * A _leaf_ frag will be present in the i_fragtree IFF there is
 * delegation info.  That is, if mds >= 0 || ndist > 0.
 */
#define CEPH_MAX_DIRFRAG_REP 4

struct ceph_inode_frag {
	struct rb_node node;

	/* fragtree state */
	u32 frag;
	int split_by;         /* i.e. 2^(split_by) children */

	/* delegation and replication info */
	int mds;              /* -1 if same authority as parent */
	int ndist;            /* >0 if replicated */
	int dist[CEPH_MAX_DIRFRAG_REP];
};

/*
 * We cache inode xattrs as an encoded blob until they are first used,
 * at which point we parse them into an rbtree.
 */
struct ceph_inode_xattr {
	struct rb_node node;

	const char *name;
	int name_len;
	const char *val;
	int val_len;
	int dirty;

	int should_free_name;
	int should_free_val;
};

261 262 263 264 265
/*
 * Ceph dentry state
 */
struct ceph_dentry_info {
	struct ceph_mds_session *lease_session;
266 267
	int lease_shared_gen;
	u32 lease_gen;
268 269 270 271
	u32 lease_seq;
	unsigned long lease_renew_after, lease_renew_from;
	struct list_head lru;
	struct dentry *dentry;
272
	unsigned long time;
273 274 275
	u64 offset;
};

S
Sage Weil 已提交
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
struct ceph_inode_xattrs_info {
	/*
	 * (still encoded) xattr blob. we avoid the overhead of parsing
	 * this until someone actually calls getxattr, etc.
	 *
	 * blob->vec.iov_len == 4 implies there are no xattrs; blob ==
	 * NULL means we don't know.
	*/
	struct ceph_buffer *blob, *prealloc_blob;

	struct rb_root index;
	bool dirty;
	int count;
	int names_size;
	int vals_size;
	u64 version, index_version;
};

/*
 * Ceph inode.
 */
struct ceph_inode_info {
	struct ceph_vino i_vino;   /* ceph ino + snap */

300 301
	spinlock_t i_ceph_lock;

S
Sage Weil 已提交
302
	u64 i_version;
303
	u64 i_inline_version;
S
Sage Weil 已提交
304 305 306
	u32 i_time_warp_seq;

	unsigned i_ceph_flags;
307 308 309
	atomic64_t i_release_count;
	atomic64_t i_ordered_count;
	atomic64_t i_complete_seq[2];
S
Sage Weil 已提交
310

S
Sage Weil 已提交
311
	struct ceph_dir_layout i_dir_layout;
S
Sage Weil 已提交
312 313 314 315
	struct ceph_file_layout i_layout;
	char *i_symlink;

	/* for dirs */
316
	struct timespec64 i_rctime;
S
Sage Weil 已提交
317 318 319
	u64 i_rbytes, i_rfiles, i_rsubdirs;
	u64 i_files, i_subdirs;

320 321 322
	/* quotas */
	u64 i_max_bytes, i_max_files;

323 324
	s32 i_dir_pin;

S
Sage Weil 已提交
325
	struct rb_root i_fragtree;
326
	int i_fragtree_nsplits;
S
Sage Weil 已提交
327 328 329 330
	struct mutex i_fragtree_mutex;

	struct ceph_inode_xattrs_info i_xattrs;

331
	/* capabilities.  protected _both_ by i_ceph_lock and cap->session's
S
Sage Weil 已提交
332 333 334 335 336 337 338 339
	 * s_mutex. */
	struct rb_root i_caps;           /* cap list */
	struct ceph_cap *i_auth_cap;     /* authoritative cap, if any */
	unsigned i_dirty_caps, i_flushing_caps;     /* mask of dirtied fields */
	struct list_head i_dirty_item, i_flushing_item;
	/* we need to track cap writeback on a per-cap-bit basis, to allow
	 * overlapping, pipelined cap flushes to the mds.  we can probably
	 * reduce the tid to 8 bits if we're concerned about inode size. */
340
	struct ceph_cap_flush *i_prealloc_cap_flush;
341
	struct list_head i_cap_flush_list;
S
Sage Weil 已提交
342 343 344 345 346 347
	wait_queue_head_t i_cap_wq;      /* threads waiting on a capability */
	unsigned long i_hold_caps_min; /* jiffies */
	unsigned long i_hold_caps_max; /* jiffies */
	struct list_head i_cap_delay_list;  /* for delayed cap release to mds */
	struct ceph_cap_reservation i_cap_migration_resv;
	struct list_head i_cap_snaps;   /* snapped state pending flush to mds */
348 349
	struct ceph_snap_context *i_head_snapc;  /* set if wr_buffer_head > 0 or
						    dirty|flushing caps */
S
Sage Weil 已提交
350 351
	unsigned i_snap_caps;           /* cap bits for snapped files */

352
	int i_nr_by_mode[CEPH_FILE_MODE_BITS];  /* open file counts */
S
Sage Weil 已提交
353

354
	struct mutex i_truncate_mutex;
S
Sage Weil 已提交
355 356 357 358 359 360 361 362 363 364 365
	u32 i_truncate_seq;        /* last truncate to smaller size */
	u64 i_truncate_size;       /*  and the size we last truncated down to */
	int i_truncate_pending;    /*  still need to call vmtruncate */

	u64 i_max_size;            /* max file size authorized by mds */
	u64 i_reported_size; /* (max_)size reported to or requested of mds */
	u64 i_wanted_max_size;     /* offset we'd like to write too */
	u64 i_requested_max_size;  /* max_size we've requested */

	/* held references to caps */
	int i_pin_ref;
366
	int i_rd_ref, i_rdcache_ref, i_wr_ref, i_wb_ref;
S
Sage Weil 已提交
367
	int i_wrbuffer_ref, i_wrbuffer_ref_head;
368
	atomic_t i_filelock_ref;
369
	atomic_t i_shared_gen;       /* increment each time we get FILE_SHARED */
370
	u32 i_rdcache_gen;      /* incremented each time we get FILE_CACHE. */
S
Sage Weil 已提交
371 372 373
	u32 i_rdcache_revoking; /* RDCACHE gen to async invalidate, if any */

	struct list_head i_unsafe_dirops; /* uncommitted mds dir ops */
374
	struct list_head i_unsafe_iops;   /* uncommitted mds inode ops */
S
Sage Weil 已提交
375 376
	spinlock_t i_unsafe_lock;

377 378 379 380
	union {
		struct ceph_snap_realm *i_snap_realm; /* snap realm (if caps) */
		struct ceph_snapid_map *i_snapid_map; /* snapid -> dev_t */
	};
S
Sage Weil 已提交
381 382 383 384 385 386 387 388 389
	int i_snap_realm_counter; /* snap realm (if caps) */
	struct list_head i_snap_realm_item;
	struct list_head i_snap_flush_item;

	struct work_struct i_wb_work;  /* writeback work */
	struct work_struct i_pg_inv_work;  /* page invalidation work */

	struct work_struct i_vmtruncate_work;

390 391
#ifdef CONFIG_CEPH_FSCACHE
	struct fscache_cookie *fscache;
392
	u32 i_fscache_gen;
393
#endif
S
Sage Weil 已提交
394 395 396 397 398
	struct inode vfs_inode; /* at end */
};

static inline struct ceph_inode_info *ceph_inode(struct inode *inode)
{
399
	return container_of(inode, struct ceph_inode_info, vfs_inode);
S
Sage Weil 已提交
400 401
}

402 403 404 405 406 407 408 409 410 411
static inline struct ceph_fs_client *ceph_inode_to_client(struct inode *inode)
{
	return (struct ceph_fs_client *)inode->i_sb->s_fs_info;
}

static inline struct ceph_fs_client *ceph_sb_to_client(struct super_block *sb)
{
	return (struct ceph_fs_client *)sb->s_fs_info;
}

412 413 414 415 416 417 418 419
static inline struct ceph_vino ceph_vino(struct inode *inode)
{
	return ceph_inode(inode)->i_vino;
}

/*
 * ino_t is <64 bits on many architectures, blech.
 *
420 421 422 423 424
 *               i_ino (kernel inode)   st_ino (userspace)
 * i386          32                     32
 * x86_64+ino32  64                     32
 * x86_64        64                     64
 */
A
Amon Ott 已提交
425
static inline u32 ceph_ino_to_ino32(__u64 vino)
426
{
A
Amon Ott 已提交
427 428
	u32 ino = vino & 0xffffffff;
	ino ^= vino >> 32;
429
	if (!ino)
430
		ino = 2;
431 432 433 434 435
	return ino;
}

/*
 * kernel i_ino value
436 437 438 439
 */
static inline ino_t ceph_vino_to_ino(struct ceph_vino vino)
{
#if BITS_PER_LONG == 32
A
Amon Ott 已提交
440 441 442
	return ceph_ino_to_ino32(vino.ino);
#else
	return (ino_t)vino.ino;
443 444 445
#endif
}

446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463
/*
 * user-visible ino (stat, filldir)
 */
#if BITS_PER_LONG == 32
static inline ino_t ceph_translate_ino(struct super_block *sb, ino_t ino)
{
	return ino;
}
#else
static inline ino_t ceph_translate_ino(struct super_block *sb, ino_t ino)
{
	if (ceph_test_mount_opt(ceph_sb_to_client(sb), INO32))
		ino = ceph_ino_to_ino32(ino);
	return ino;
}
#endif


464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494
/* for printf-style formatting */
#define ceph_vinop(i) ceph_inode(i)->i_vino.ino, ceph_inode(i)->i_vino.snap

static inline u64 ceph_ino(struct inode *inode)
{
	return ceph_inode(inode)->i_vino.ino;
}
static inline u64 ceph_snap(struct inode *inode)
{
	return ceph_inode(inode)->i_vino.snap;
}

static inline int ceph_ino_compare(struct inode *inode, void *data)
{
	struct ceph_vino *pvino = (struct ceph_vino *)data;
	struct ceph_inode_info *ci = ceph_inode(inode);
	return ci->i_vino.ino == pvino->ino &&
		ci->i_vino.snap == pvino->snap;
}

static inline struct inode *ceph_find_inode(struct super_block *sb,
					    struct ceph_vino vino)
{
	ino_t t = ceph_vino_to_ino(vino);
	return ilookup5(sb, t, ceph_ino_compare, &vino);
}


/*
 * Ceph inode.
 */
495 496 497 498 499 500 501
#define CEPH_I_DIR_ORDERED	(1 << 0)  /* dentries in dir are ordered */
#define CEPH_I_NODELAY		(1 << 1)  /* do not delay cap release */
#define CEPH_I_FLUSH		(1 << 2)  /* do not delay flush of dirty metadata */
#define CEPH_I_NOFLUSH		(1 << 3)  /* do not flush dirty caps */
#define CEPH_I_POOL_PERM	(1 << 4)  /* pool rd/wr bits are valid */
#define CEPH_I_POOL_RD		(1 << 5)  /* can read from pool */
#define CEPH_I_POOL_WR		(1 << 6)  /* can write to pool */
502
#define CEPH_I_SEC_INITED	(1 << 7)  /* security initialized */
503
#define CEPH_I_CAP_DROPPED	(1 << 8)  /* caps were forcibly dropped */
504
#define CEPH_I_KICK_FLUSH	(1 << 9)  /* kick flushing caps */
505
#define CEPH_I_FLUSH_SNAPS	(1 << 10) /* need flush snapss */
506
#define CEPH_I_ERROR_WRITE	(1 << 11) /* have seen write errors */
507 508
#define CEPH_I_ERROR_FILELOCK	(1 << 12) /* have seen file lock errors */

509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533

/*
 * We set the ERROR_WRITE bit when we start seeing write errors on an inode
 * and then clear it when they start succeeding. Note that we do a lockless
 * check first, and only take the lock if it looks like it needs to be changed.
 * The write submission code just takes this as a hint, so we're not too
 * worried if a few slip through in either direction.
 */
static inline void ceph_set_error_write(struct ceph_inode_info *ci)
{
	if (!(READ_ONCE(ci->i_ceph_flags) & CEPH_I_ERROR_WRITE)) {
		spin_lock(&ci->i_ceph_lock);
		ci->i_ceph_flags |= CEPH_I_ERROR_WRITE;
		spin_unlock(&ci->i_ceph_lock);
	}
}

static inline void ceph_clear_error_write(struct ceph_inode_info *ci)
{
	if (READ_ONCE(ci->i_ceph_flags) & CEPH_I_ERROR_WRITE) {
		spin_lock(&ci->i_ceph_lock);
		ci->i_ceph_flags &= ~CEPH_I_ERROR_WRITE;
		spin_unlock(&ci->i_ceph_lock);
	}
}
534

535
static inline void __ceph_dir_set_complete(struct ceph_inode_info *ci,
536 537
					   long long release_count,
					   long long ordered_count)
S
Sage Weil 已提交
538
{
539 540 541
	smp_mb__before_atomic();
	atomic64_set(&ci->i_complete_seq[0], release_count);
	atomic64_set(&ci->i_complete_seq[1], ordered_count);
S
Sage Weil 已提交
542 543
}

544
static inline void __ceph_dir_clear_complete(struct ceph_inode_info *ci)
S
Sage Weil 已提交
545
{
546 547 548 549 550 551
	atomic64_inc(&ci->i_release_count);
}

static inline void __ceph_dir_clear_ordered(struct ceph_inode_info *ci)
{
	atomic64_inc(&ci->i_ordered_count);
552
}
S
Sage Weil 已提交
553

554 555
static inline bool __ceph_dir_is_complete(struct ceph_inode_info *ci)
{
556 557
	return atomic64_read(&ci->i_complete_seq[0]) ==
		atomic64_read(&ci->i_release_count);
S
Sage Weil 已提交
558 559
}

560 561
static inline bool __ceph_dir_is_complete_ordered(struct ceph_inode_info *ci)
{
562 563 564 565
	return  atomic64_read(&ci->i_complete_seq[0]) ==
		atomic64_read(&ci->i_release_count) &&
		atomic64_read(&ci->i_complete_seq[1]) ==
		atomic64_read(&ci->i_ordered_count);
566 567
}

568
static inline void ceph_dir_clear_complete(struct inode *inode)
S
Sage Weil 已提交
569
{
570 571
	__ceph_dir_clear_complete(ceph_inode(inode));
}
S
Sage Weil 已提交
572

573
static inline void ceph_dir_clear_ordered(struct inode *inode)
574
{
575
	__ceph_dir_clear_ordered(ceph_inode(inode));
S
Sage Weil 已提交
576 577
}

578 579
static inline bool ceph_dir_is_complete_ordered(struct inode *inode)
{
580 581
	bool ret = __ceph_dir_is_complete_ordered(ceph_inode(inode));
	smp_rmb();
582 583
	return ret;
}
S
Sage Weil 已提交
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617

/* find a specific frag @f */
extern struct ceph_inode_frag *__ceph_find_frag(struct ceph_inode_info *ci,
						u32 f);

/*
 * choose fragment for value @v.  copy frag content to pfrag, if leaf
 * exists
 */
extern u32 ceph_choose_frag(struct ceph_inode_info *ci, u32 v,
			    struct ceph_inode_frag *pfrag,
			    int *found);

static inline struct ceph_dentry_info *ceph_dentry(struct dentry *dentry)
{
	return (struct ceph_dentry_info *)dentry->d_fsdata;
}

/*
 * caps helpers
 */
static inline bool __ceph_is_any_real_caps(struct ceph_inode_info *ci)
{
	return !RB_EMPTY_ROOT(&ci->i_caps);
}

extern int __ceph_caps_issued(struct ceph_inode_info *ci, int *implemented);
extern int __ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask, int t);
extern int __ceph_caps_issued_other(struct ceph_inode_info *ci,
				    struct ceph_cap *cap);

static inline int ceph_caps_issued(struct ceph_inode_info *ci)
{
	int issued;
618
	spin_lock(&ci->i_ceph_lock);
S
Sage Weil 已提交
619
	issued = __ceph_caps_issued(ci, NULL);
620
	spin_unlock(&ci->i_ceph_lock);
S
Sage Weil 已提交
621 622 623 624 625 626 627
	return issued;
}

static inline int ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask,
					int touch)
{
	int r;
628
	spin_lock(&ci->i_ceph_lock);
S
Sage Weil 已提交
629
	r = __ceph_caps_issued_mask(ci, mask, touch);
630
	spin_unlock(&ci->i_ceph_lock);
S
Sage Weil 已提交
631 632 633 634 635 636 637
	return r;
}

static inline int __ceph_caps_dirty(struct ceph_inode_info *ci)
{
	return ci->i_dirty_caps | ci->i_flushing_caps;
}
638 639 640 641
extern struct ceph_cap_flush *ceph_alloc_cap_flush(void);
extern void ceph_free_cap_flush(struct ceph_cap_flush *cf);
extern int __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask,
				  struct ceph_cap_flush **pcf);
S
Sage Weil 已提交
642

Y
Yan, Zheng 已提交
643 644
extern int __ceph_caps_revoking_other(struct ceph_inode_info *ci,
				      struct ceph_cap *ocap, int mask);
S
Sage Weil 已提交
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
extern int ceph_caps_revoking(struct ceph_inode_info *ci, int mask);
extern int __ceph_caps_used(struct ceph_inode_info *ci);

extern int __ceph_caps_file_wanted(struct ceph_inode_info *ci);

/*
 * wanted, by virtue of open file modes AND cap refs (buffered/cached data)
 */
static inline int __ceph_caps_wanted(struct ceph_inode_info *ci)
{
	int w = __ceph_caps_file_wanted(ci) | __ceph_caps_used(ci);
	if (w & CEPH_CAP_FILE_BUFFER)
		w |= CEPH_CAP_FILE_EXCL;  /* we want EXCL if dirty data */
	return w;
}

/* what the mds thinks we want */
662
extern int __ceph_caps_mds_wanted(struct ceph_inode_info *ci, bool check);
S
Sage Weil 已提交
663

664 665 666
extern void ceph_caps_init(struct ceph_mds_client *mdsc);
extern void ceph_caps_finalize(struct ceph_mds_client *mdsc);
extern void ceph_adjust_min_caps(struct ceph_mds_client *mdsc, int delta);
667
extern int ceph_reserve_caps(struct ceph_mds_client *mdsc,
668
			     struct ceph_cap_reservation *ctx, int need);
669
extern void ceph_unreserve_caps(struct ceph_mds_client *mdsc,
670
			       struct ceph_cap_reservation *ctx);
671
extern void ceph_reservation_status(struct ceph_fs_client *client,
S
Sage Weil 已提交
672
				    int *total, int *avail, int *used,
673
				    int *reserved, int *min);
S
Sage Weil 已提交
674 675 676 677 678 679



/*
 * we keep buffered readdir results attached to file->private_data
 */
680
#define CEPH_F_SYNC     1
681
#define CEPH_F_ATEND    2
682

S
Sage Weil 已提交
683
struct ceph_file_info {
684 685
	short fmode;     /* initialized on open */
	short flags;     /* CEPH_F_* */
S
Sage Weil 已提交
686

687 688
	spinlock_t rw_contexts_lock;
	struct list_head rw_contexts;
689 690 691 692
};

struct ceph_dir_file_info {
	struct ceph_file_info file_info;
693

S
Sage Weil 已提交
694 695 696 697 698
	/* readdir: position within the dir */
	u32 frag;
	struct ceph_mds_request *last_readdir;

	/* readdir: position within a frag */
Y
Yan, Zheng 已提交
699
	unsigned next_offset;  /* offset of next chunk (last_name's + 1) */
S
Sage Weil 已提交
700
	char *last_name;       /* last entry in previous chunk */
701 702 703
	long long dir_release_count;
	long long dir_ordered_count;
	int readdir_cache_idx;
S
Sage Weil 已提交
704 705 706 707 708 709

	/* used for -o dirstat read() on directory thing */
	char *dir_info;
	int dir_info_len;
};

710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752
struct ceph_rw_context {
	struct list_head list;
	struct task_struct *thread;
	int caps;
};

#define CEPH_DEFINE_RW_CONTEXT(_name, _caps)	\
	struct ceph_rw_context _name = {	\
		.thread = current,		\
		.caps = _caps,			\
	}

static inline void ceph_add_rw_context(struct ceph_file_info *cf,
				       struct ceph_rw_context *ctx)
{
	spin_lock(&cf->rw_contexts_lock);
	list_add(&ctx->list, &cf->rw_contexts);
	spin_unlock(&cf->rw_contexts_lock);
}

static inline void ceph_del_rw_context(struct ceph_file_info *cf,
				       struct ceph_rw_context *ctx)
{
	spin_lock(&cf->rw_contexts_lock);
	list_del(&ctx->list);
	spin_unlock(&cf->rw_contexts_lock);
}

static inline struct ceph_rw_context*
ceph_find_rw_context(struct ceph_file_info *cf)
{
	struct ceph_rw_context *ctx, *found = NULL;
	spin_lock(&cf->rw_contexts_lock);
	list_for_each_entry(ctx, &cf->rw_contexts, list) {
		if (ctx->thread == current) {
			found = ctx;
			break;
		}
	}
	spin_unlock(&cf->rw_contexts_lock);
	return found;
}

753 754 755 756 757
struct ceph_readdir_cache_control {
	struct page  *page;
	struct dentry **dentries;
	int index;
};
S
Sage Weil 已提交
758 759 760 761 762 763 764 765 766 767 768 769

/*
 * A "snap realm" describes a subset of the file hierarchy sharing
 * the same set of snapshots that apply to it.  The realms themselves
 * are organized into a hierarchy, such that children inherit (some of)
 * the snapshots of their parents.
 *
 * All inodes within the realm that have capabilities are linked into a
 * per-realm list.
 */
struct ceph_snap_realm {
	u64 ino;
770
	struct inode *inode;
S
Sage Weil 已提交
771
	atomic_t nref;
772 773
	struct rb_node node;

S
Sage Weil 已提交
774 775 776 777 778
	u64 created, seq;
	u64 parent_ino;
	u64 parent_since;   /* snapid when our current parent became so */

	u64 *prior_parent_snaps;      /* snaps inherited from any parents we */
779
	u32 num_prior_parent_snaps;   /*  had prior to parent_since */
S
Sage Weil 已提交
780
	u64 *snaps;                   /* snaps specific to this realm */
781
	u32 num_snaps;
S
Sage Weil 已提交
782 783 784 785 786 787 788

	struct ceph_snap_realm *parent;
	struct list_head children;       /* list of child realms */
	struct list_head child_item;

	struct list_head empty_item;     /* if i have ref==0 */

789 790
	struct list_head dirty_item;     /* if realm needs new context */

S
Sage Weil 已提交
791 792 793 794 795 796 797
	/* the current set of snaps for this realm */
	struct ceph_snap_context *cached_context;

	struct list_head inodes_with_caps;
	spinlock_t inodes_with_caps_lock;
};

798
static inline int default_congestion_kb(void)
S
Sage Weil 已提交
799
{
800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819
	int congestion_kb;

	/*
	 * Copied from NFS
	 *
	 * congestion size, scale with available memory.
	 *
	 *  64MB:    8192k
	 * 128MB:   11585k
	 * 256MB:   16384k
	 * 512MB:   23170k
	 *   1GB:   32768k
	 *   2GB:   46340k
	 *   4GB:   65536k
	 *   8GB:   92681k
	 *  16GB:  131072k
	 *
	 * This allows larger machines to have larger/more transfers.
	 * Limit the default to 256M
	 */
820
	congestion_kb = (16*int_sqrt(totalram_pages())) << (PAGE_SHIFT-10);
821 822 823 824
	if (congestion_kb > 256*1024)
		congestion_kb = 256*1024;

	return congestion_kb;
S
Sage Weil 已提交
825 826 827 828 829 830 831 832 833 834 835 836
}



/* snap.c */
struct ceph_snap_realm *ceph_lookup_snap_realm(struct ceph_mds_client *mdsc,
					       u64 ino);
extern void ceph_get_snap_realm(struct ceph_mds_client *mdsc,
				struct ceph_snap_realm *realm);
extern void ceph_put_snap_realm(struct ceph_mds_client *mdsc,
				struct ceph_snap_realm *realm);
extern int ceph_update_snap_trace(struct ceph_mds_client *m,
837 838
				  void *p, void *e, bool deletion,
				  struct ceph_snap_realm **realm_ret);
S
Sage Weil 已提交
839
extern void ceph_handle_snap(struct ceph_mds_client *mdsc,
840
			     struct ceph_mds_session *session,
S
Sage Weil 已提交
841
			     struct ceph_msg *msg);
842
extern void ceph_queue_cap_snap(struct ceph_inode_info *ci);
S
Sage Weil 已提交
843 844 845 846
extern int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
				  struct ceph_cap_snap *capsnap);
extern void ceph_cleanup_empty_realms(struct ceph_mds_client *mdsc);

847 848 849 850 851 852 853 854
extern struct ceph_snapid_map *ceph_get_snapid_map(struct ceph_mds_client *mdsc,
						   u64 snap);
extern void ceph_put_snapid_map(struct ceph_mds_client* mdsc,
				struct ceph_snapid_map *sm);
extern void ceph_trim_snapid_map(struct ceph_mds_client *mdsc);
extern void ceph_cleanup_snapid_map(struct ceph_mds_client *mdsc);


S
Sage Weil 已提交
855 856 857 858 859 860 861
/*
 * a cap_snap is "pending" if it is still awaiting an in-progress
 * sync write (that may/may not still update size, mtime, etc.).
 */
static inline bool __ceph_have_pending_cap_snap(struct ceph_inode_info *ci)
{
	return !list_empty(&ci->i_cap_snaps) &&
862 863
	       list_last_entry(&ci->i_cap_snaps, struct ceph_cap_snap,
			       ci_item)->writing;
S
Sage Weil 已提交
864 865 866 867 868 869 870
}

/* inode.c */
extern const struct inode_operations ceph_file_iops;

extern struct inode *ceph_alloc_inode(struct super_block *sb);
extern void ceph_destroy_inode(struct inode *inode);
871
extern int ceph_drop_inode(struct inode *inode);
S
Sage Weil 已提交
872 873 874 875 876 877 878

extern struct inode *ceph_get_inode(struct super_block *sb,
				    struct ceph_vino vino);
extern struct inode *ceph_get_snapdir(struct inode *parent);
extern int ceph_fill_file_size(struct inode *inode, int issued,
			       u32 truncate_seq, u64 truncate_size, u64 size);
extern void ceph_fill_file_time(struct inode *inode, int issued,
879 880 881
				u64 time_warp_seq, struct timespec64 *ctime,
				struct timespec64 *mtime,
				struct timespec64 *atime);
S
Sage Weil 已提交
882
extern int ceph_fill_trace(struct super_block *sb,
883
			   struct ceph_mds_request *req);
S
Sage Weil 已提交
884 885 886 887 888
extern int ceph_readdir_prepopulate(struct ceph_mds_request *req,
				    struct ceph_mds_session *session);

extern int ceph_inode_holds_cap(struct inode *inode, int mask);

889
extern bool ceph_inode_set_size(struct inode *inode, loff_t size);
890
extern void __ceph_do_pending_vmtruncate(struct inode *inode);
891 892 893 894
extern void ceph_queue_vmtruncate(struct inode *inode);

extern void ceph_queue_invalidate(struct inode *inode);
extern void ceph_queue_writeback(struct inode *inode);
S
Sage Weil 已提交
895

896 897 898 899 900 901
extern int __ceph_do_getattr(struct inode *inode, struct page *locked_page,
			     int mask, bool force);
static inline int ceph_do_getattr(struct inode *inode, int mask, bool force)
{
	return __ceph_do_getattr(inode, NULL, mask, force);
}
902
extern int ceph_permission(struct inode *inode, int mask);
903
extern int __ceph_setattr(struct inode *inode, struct iattr *attr);
S
Sage Weil 已提交
904
extern int ceph_setattr(struct dentry *dentry, struct iattr *attr);
905 906
extern int ceph_getattr(const struct path *path, struct kstat *stat,
			u32 request_mask, unsigned int flags);
S
Sage Weil 已提交
907 908

/* xattr.c */
909
int __ceph_setxattr(struct inode *, const char *, const void *, size_t, int);
910
ssize_t __ceph_getxattr(struct inode *, const char *, void *, size_t);
S
Sage Weil 已提交
911 912 913
extern ssize_t ceph_listxattr(struct dentry *, char *, size_t);
extern void __ceph_build_xattrs_blob(struct ceph_inode_info *ci);
extern void __ceph_destroy_xattrs(struct ceph_inode_info *ci);
914 915
extern void __init ceph_xattr_init(void);
extern void ceph_xattr_exit(void);
916
extern const struct xattr_handler *ceph_xattr_handlers[];
S
Sage Weil 已提交
917

918 919 920 921 922 923 924 925 926 927 928 929 930 931
#ifdef CONFIG_SECURITY
extern bool ceph_security_xattr_deadlock(struct inode *in);
extern bool ceph_security_xattr_wanted(struct inode *in);
#else
static inline bool ceph_security_xattr_deadlock(struct inode *in)
{
	return false;
}
static inline bool ceph_security_xattr_wanted(struct inode *in)
{
	return false;
}
#endif

932
/* acl.c */
933 934 935 936 937
struct ceph_acls_info {
	void *default_acl;
	void *acl;
	struct ceph_pagelist *pagelist;
};
938 939 940 941

#ifdef CONFIG_CEPH_FS_POSIX_ACL

struct posix_acl *ceph_get_acl(struct inode *, int);
S
Sage Weil 已提交
942
int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type);
943 944 945 946
int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
		       struct ceph_acls_info *info);
void ceph_init_inode_acls(struct inode *inode, struct ceph_acls_info *info);
void ceph_release_acls_info(struct ceph_acls_info *info);
947 948 949 950 951

static inline void ceph_forget_all_cached_acls(struct inode *inode)
{
       forget_all_cached_acls(inode);
}
952 953 954 955

#else

#define ceph_get_acl NULL
S
Sage Weil 已提交
956
#define ceph_set_acl NULL
957

958 959
static inline int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
				     struct ceph_acls_info *info)
960 961 962
{
	return 0;
}
963 964 965 966 967 968 969
static inline void ceph_init_inode_acls(struct inode *inode,
					struct ceph_acls_info *info)
{
}
static inline void ceph_release_acls_info(struct ceph_acls_info *info)
{
}
970 971 972 973 974 975 976 977 978 979 980
static inline int ceph_acl_chmod(struct dentry *dentry, struct inode *inode)
{
	return 0;
}

static inline void ceph_forget_all_cached_acls(struct inode *inode)
{
}

#endif

S
Sage Weil 已提交
981 982 983 984
/* caps.c */
extern const char *ceph_cap_string(int c);
extern void ceph_handle_caps(struct ceph_mds_session *session,
			     struct ceph_msg *msg);
985 986 987 988 989 990 991
extern struct ceph_cap *ceph_get_cap(struct ceph_mds_client *mdsc,
				     struct ceph_cap_reservation *ctx);
extern void ceph_add_cap(struct inode *inode,
			 struct ceph_mds_session *session, u64 cap_id,
			 int fmode, unsigned issued, unsigned wanted,
			 unsigned cap, unsigned seq, u64 realmino, int flags,
			 struct ceph_cap **new_cap);
992
extern void __ceph_remove_cap(struct ceph_cap *cap, bool queue_release);
993
extern void __ceph_remove_caps(struct inode* inode);
994 995
extern void ceph_put_cap(struct ceph_mds_client *mdsc,
			 struct ceph_cap *cap);
996
extern int ceph_is_any_caps(struct inode *inode);
S
Sage Weil 已提交
997

998
extern int ceph_write_inode(struct inode *inode, struct writeback_control *wbc);
999 1000
extern int ceph_fsync(struct file *file, loff_t start, loff_t end,
		      int datasync);
1001 1002
extern void ceph_early_kick_flushing_caps(struct ceph_mds_client *mdsc,
					  struct ceph_mds_session *session);
S
Sage Weil 已提交
1003 1004
extern void ceph_kick_flushing_caps(struct ceph_mds_client *mdsc,
				    struct ceph_mds_session *session);
1005 1006
extern struct ceph_cap *ceph_get_cap_for_mds(struct ceph_inode_info *ci,
					     int mds);
S
Sage Weil 已提交
1007 1008 1009 1010 1011
extern int ceph_get_cap_mds(struct inode *inode);
extern void ceph_get_cap_refs(struct ceph_inode_info *ci, int caps);
extern void ceph_put_cap_refs(struct ceph_inode_info *ci, int had);
extern void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr,
				       struct ceph_snap_context *snapc);
1012 1013
extern void ceph_flush_snaps(struct ceph_inode_info *ci,
			     struct ceph_mds_session **psession);
1014
extern bool __ceph_should_report_size(struct ceph_inode_info *ci);
S
Sage Weil 已提交
1015 1016
extern void ceph_check_caps(struct ceph_inode_info *ci, int flags,
			    struct ceph_mds_session *session);
1017 1018
extern void ceph_check_delayed_caps(struct ceph_mds_client *mdsc);
extern void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc);
1019
extern int  ceph_drop_caps_for_unlink(struct inode *inode);
S
Sage Weil 已提交
1020 1021 1022
extern int ceph_encode_inode_release(void **p, struct inode *inode,
				     int mds, int drop, int unless, int force);
extern int ceph_encode_dentry_release(void **p, struct dentry *dn,
1023
				      struct inode *dir,
S
Sage Weil 已提交
1024 1025 1026
				      int mds, int drop, int unless);

extern int ceph_get_caps(struct ceph_inode_info *ci, int need, int want,
1027
			 loff_t endoff, int *got, struct page **pinned_page);
1028
extern int ceph_try_get_caps(struct ceph_inode_info *ci,
1029
			     int need, int want, bool nonblock, int *got);
S
Sage Weil 已提交
1030 1031

/* for counting open files by mode */
1032
extern void __ceph_get_fmode(struct ceph_inode_info *ci, int mode);
S
Sage Weil 已提交
1033 1034 1035 1036 1037
extern void ceph_put_fmode(struct ceph_inode_info *ci, int mode);

/* addr.c */
extern const struct address_space_operations ceph_aops;
extern int ceph_mmap(struct file *file, struct vm_area_struct *vma);
1038 1039 1040
extern int ceph_uninline_data(struct file *filp, struct page *locked_page);
extern int ceph_pool_perm_check(struct ceph_inode_info *ci, int need);
extern void ceph_pool_perm_destroy(struct ceph_mds_client* mdsc);
S
Sage Weil 已提交
1041 1042 1043

/* file.c */
extern const struct file_operations ceph_file_fops;
1044

1045
extern int ceph_renew_caps(struct inode *inode);
S
Sage Weil 已提交
1046
extern int ceph_open(struct inode *inode, struct file *file);
1047
extern int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
1048
			    struct file *file, unsigned flags, umode_t mode);
S
Sage Weil 已提交
1049
extern int ceph_release(struct inode *inode, struct file *filp);
1050 1051
extern void ceph_fill_inline_data(struct inode *inode, struct page *locked_page,
				  char *data, size_t len);
1052

S
Sage Weil 已提交
1053 1054
/* dir.c */
extern const struct file_operations ceph_dir_fops;
1055
extern const struct file_operations ceph_snapdir_fops;
S
Sage Weil 已提交
1056
extern const struct inode_operations ceph_dir_iops;
1057
extern const struct inode_operations ceph_snapdir_iops;
1058
extern const struct dentry_operations ceph_dentry_ops;
S
Sage Weil 已提交
1059

1060
extern loff_t ceph_make_fpos(unsigned high, unsigned off, bool hash_order);
S
Sage Weil 已提交
1061
extern int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry);
1062 1063
extern int ceph_handle_snapdir(struct ceph_mds_request *req,
			       struct dentry *dentry, int err);
S
Sage Weil 已提交
1064 1065 1066 1067 1068 1069
extern struct dentry *ceph_finish_lookup(struct ceph_mds_request *req,
					 struct dentry *dentry, int err);

extern void ceph_dentry_lru_add(struct dentry *dn);
extern void ceph_dentry_lru_touch(struct dentry *dn);
extern void ceph_dentry_lru_del(struct dentry *dn);
1070
extern void ceph_invalidate_dentry_lease(struct dentry *dentry);
1071
extern unsigned ceph_dentry_hash(struct inode *dir, struct dentry *dn);
1072
extern void ceph_readdir_cache_release(struct ceph_readdir_cache_control *ctl);
S
Sage Weil 已提交
1073 1074 1075 1076 1077 1078 1079

/* ioctl.c */
extern long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg);

/* export.c */
extern const struct export_operations ceph_export_ops;

1080
/* locks.c */
1081
extern __init void ceph_flock_init(void);
1082 1083 1084
extern int ceph_lock(struct file *file, int cmd, struct file_lock *fl);
extern int ceph_flock(struct file *file, int cmd, struct file_lock *fl);
extern void ceph_count_locks(struct inode *inode, int *p_num, int *f_num);
1085 1086 1087 1088 1089 1090 1091
extern int ceph_encode_locks_to_buffer(struct inode *inode,
				       struct ceph_filelock *flocks,
				       int num_fcntl_locks,
				       int num_flock_locks);
extern int ceph_locks_to_pagelist(struct ceph_filelock *flocks,
				  struct ceph_pagelist *pagelist,
				  int num_fcntl_locks, int num_flock_locks);
1092

1093 1094 1095 1096
/* debugfs.c */
extern int ceph_fs_debugfs_init(struct ceph_fs_client *client);
extern void ceph_fs_debugfs_cleanup(struct ceph_fs_client *client);

1097
/* quota.c */
1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117
static inline bool __ceph_has_any_quota(struct ceph_inode_info *ci)
{
	return ci->i_max_files || ci->i_max_bytes;
}

extern void ceph_adjust_quota_realms_count(struct inode *inode, bool inc);

static inline void __ceph_update_quota(struct ceph_inode_info *ci,
				       u64 max_bytes, u64 max_files)
{
	bool had_quota, has_quota;
	had_quota = __ceph_has_any_quota(ci);
	ci->i_max_bytes = max_bytes;
	ci->i_max_files = max_files;
	has_quota = __ceph_has_any_quota(ci);

	if (had_quota != has_quota)
		ceph_adjust_quota_realms_count(&ci->vfs_inode, has_quota);
}

1118 1119 1120
extern void ceph_handle_quota(struct ceph_mds_client *mdsc,
			      struct ceph_mds_session *session,
			      struct ceph_msg *msg);
1121
extern bool ceph_quota_is_max_files_exceeded(struct inode *inode);
1122
extern bool ceph_quota_is_same_realm(struct inode *old, struct inode *new);
1123 1124
extern bool ceph_quota_is_max_bytes_exceeded(struct inode *inode,
					     loff_t newlen);
1125 1126
extern bool ceph_quota_is_max_bytes_approaching(struct inode *inode,
						loff_t newlen);
1127 1128
extern bool ceph_quota_update_statfs(struct ceph_fs_client *fsc,
				     struct kstatfs *buf);
1129

S
Sage Weil 已提交
1130
#endif /* _FS_CEPH_SUPER_H */
新手
引导
客服 返回
顶部