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"
12 static std::atomic
<bool> cb_done
= false;
14 static void cb(void *hdl
, vinodeno_t vino
)
19 int main(int argc
, char *argv
[])
21 inodeno_t inos
[MAX_CEPH_FILES
];
22 struct ceph_mount_info
*cmount
= NULL
;
24 ceph_create(&cmount
, "admin");
25 ceph_conf_read_file(cmount
, NULL
);
28 [[maybe_unused
]] int ret
= ceph_mount(cmount
, NULL
);
30 ret
= ceph_mkdir(cmount
, DIRNAME
, 0755);
32 ret
= ceph_chdir(cmount
, DIRNAME
);
35 /* Create a bunch of files, get their inode numbers and close them */
37 for (i
= 0; i
< MAX_CEPH_FILES
; ++i
) {
39 struct ceph_statx stx
;
41 string name
= std::to_string(i
);
43 fd
= ceph_open(cmount
, name
.c_str(), O_RDWR
|O_CREAT
, 0644);
46 ret
= ceph_fstatx(cmount
, fd
, &stx
, CEPH_STATX_INO
, 0);
49 inos
[i
] = stx
.stx_ino
;
50 ceph_close(cmount
, fd
);
56 ceph_create(&cmount
, "admin");
57 ceph_conf_read_file(cmount
, NULL
);
60 struct ceph_client_callback_args args
= { 0 };
61 args
.ino_release_cb
= cb
;
62 ret
= ceph_ll_register_callbacks2(cmount
, &args
);
65 ret
= ceph_mount(cmount
, NULL
);
68 Inode
*inodes
[MAX_CEPH_FILES
];
70 for (i
= 0; i
< MAX_CEPH_FILES
; ++i
) {
71 /* We can stop if we got a callback */
75 ret
= ceph_ll_lookup_inode(cmount
, inos
[i
], &inodes
[i
]);