0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/types.h>
0009 #include <linux/export.h>
0010 #include <linux/ceph/libceph.h>
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 struct ceph_snap_context *ceph_create_snap_context(u32 snap_count,
0028 gfp_t gfp_flags)
0029 {
0030 struct ceph_snap_context *snapc;
0031 size_t size;
0032
0033 size = sizeof (struct ceph_snap_context);
0034 size += snap_count * sizeof (snapc->snaps[0]);
0035 snapc = kzalloc(size, gfp_flags);
0036 if (!snapc)
0037 return NULL;
0038
0039 refcount_set(&snapc->nref, 1);
0040 snapc->num_snaps = snap_count;
0041
0042 return snapc;
0043 }
0044 EXPORT_SYMBOL(ceph_create_snap_context);
0045
0046 struct ceph_snap_context *ceph_get_snap_context(struct ceph_snap_context *sc)
0047 {
0048 if (sc)
0049 refcount_inc(&sc->nref);
0050 return sc;
0051 }
0052 EXPORT_SYMBOL(ceph_get_snap_context);
0053
0054 void ceph_put_snap_context(struct ceph_snap_context *sc)
0055 {
0056 if (!sc)
0057 return;
0058 if (refcount_dec_and_test(&sc->nref)) {
0059
0060 kfree(sc);
0061 }
0062 }
0063 EXPORT_SYMBOL(ceph_put_snap_context);