3 #include <include/fs_types.h>
4 #include <mds/mdstypes.h>
5 #include <include/cephfs/libcephfs.h>
7 #define MAX_CEPH_FILES 1000
8 #define DIRNAME "ino_release_cb"
10 static std::atomic
<bool> cb_done
= false;
12 static void cb(void *hdl
, vinodeno_t vino
)
17 int main(int argc
, char *argv
[])
19 inodeno_t inos
[MAX_CEPH_FILES
];
20 struct ceph_mount_info
*cmount
= NULL
;
22 ceph_create(&cmount
, "admin");
23 ceph_conf_read_file(cmount
, NULL
);
26 [[maybe_unused
]] int ret
= ceph_mount(cmount
, NULL
);
28 ret
= ceph_mkdir(cmount
, DIRNAME
, 0755);
30 ret
= ceph_chdir(cmount
, DIRNAME
);
33 /* Create a bunch of files, get their inode numbers and close them */
35 for (i
= 0; i
< MAX_CEPH_FILES
; ++i
) {
37 struct ceph_statx stx
;
39 string name
= std::to_string(i
);
41 fd
= ceph_open(cmount
, name
.c_str(), O_RDWR
|O_CREAT
, 0644);
44 ret
= ceph_fstatx(cmount
, fd
, &stx
, CEPH_STATX_INO
, 0);
47 inos
[i
] = stx
.stx_ino
;
48 ceph_close(cmount
, fd
);
54 ceph_create(&cmount
, "admin");
55 ceph_conf_read_file(cmount
, NULL
);
58 struct ceph_client_callback_args args
= { 0 };
59 args
.ino_release_cb
= cb
;
60 ceph_ll_register_callbacks(cmount
, &args
);
62 ret
= ceph_mount(cmount
, NULL
);
65 Inode
*inodes
[MAX_CEPH_FILES
];
67 for (i
= 0; i
< MAX_CEPH_FILES
; ++i
) {
68 /* We can stop if we got a callback */
72 ret
= ceph_ll_lookup_inode(cmount
, inos
[i
], &inodes
[i
]);