extern int llapi_get_obd_count(char *mnt, int *count, int is_mdt);
extern int parse_size(char *optarg, unsigned long long *size,
unsigned long long *size_units, int bytes_spec);
-extern int llapi_path2fid(const char *path, unsigned long long *seq,
- unsigned long *oid, unsigned long *ver);
+extern int llapi_path2fid(const char *path, lustre_fid *fid);
extern int llapi_search_fsname(const char *pathname, char *fsname);
extern void llapi_ping_target(char *obd_type, char *obd_name,
char *obd_uuid, void *args);
long long endrec);
extern int llapi_changelog_register(const char *mdtname);
extern int llapi_changelog_unregister(const char *mdtname, int id);
-extern int llapi_fid2path(char *device, char *fid, char *path, int pathlen,
- long long *recno, int *linkno);
+extern int llapi_fid2path(const char *device, const char *fidstr, char *path,
+ int pathlen, long long *recno, int *linkno);
#endif
* @{ */
/**
- * File identifier.
- *
- * Fid is a cluster-wide unique identifier of a file or an object
- * (stripe). Fids are never reused. Fids are transmitted across network (in
- * the sender byte-ordering), and stored on disk in a packed form (struct
- * lu_fid_pack) in a big-endian order.
- */
-struct lu_fid {
- /**
- * fid sequence. Sequence is a unit of migration: all files (objects)
- * with fids from a given sequence are stored on the same
- * server.
- *
- * Lustre should support 2 ^ 64 objects, thus even if one
- * sequence has one object we will never reach this value.
- */
- __u64 f_seq;
- /** fid number within sequence. */
- __u32 f_oid;
- /**
- * fid version, used to distinguish different versions (in the sense
- * of snapshots, etc.) of the same file system object. Not currently
- * used.
- */
- __u32 f_ver;
-};
-
-/**
* Following struct for MDT attributes, that will be kept inode's EA.
* Introduced in 2.0 release (please see b15993, for details)
*/
__u64 lma_som_sectors;
};
-
/**
* fid constants
*/
return fid_oid(fid);
}
-#define DFID "["LPX64":0x%x:0x%x]"
-#define SFID "0x%llx:0x%x:0x%x"
-
-#define PFID(fid) \
- fid_seq(fid), \
- fid_oid(fid), \
- fid_ver(fid)
-
+/*
+ * Fids are transmitted across network (in the sender byte-ordering),
+ * and stored on disk in big-endian order.
+ */
static inline void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src)
{
/* check that all fields are converted */
return (char *)(uuid->uuid);
}
+
+/**
+ * File IDentifier.
+ *
+ * FID is a cluster-wide unique identifier of a file or an object (stripe).
+ * FIDs are never reused.
+ */
+struct lu_fid {
+ /**
+ * FID sequence. Sequence is a unit of migration: all files (objects)
+ * with FIDs from a given sequence are stored on the same server.
+ * Lustre should support 2^64 objects, so even if each sequence
+ * has only a single object we can still enumerate 2^64 objects.
+ */
+ __u64 f_seq;
+ /** FID number within sequence. */
+ __u32 f_oid;
+ /**
+ * FID version, used to distinguish different versions (in the sense
+ * of snapshots, etc.) of the same file system object. Not currently
+ * used.
+ */
+ __u32 f_ver;
+};
+
+/* Userspace should treat lu_fid as opaque, and only use the following methods
+ to print or parse them. Other functions (e.g. compare, swab) could be moved
+ here from lustre_idl.h if needed. */
+typedef struct lu_fid lustre_fid;
+
+/* printf display format
+ e.g. printf("file FID is "DFID"\n", PFID(fid)); */
+#define DFID "["LPX64":0x%x:0x%x]"
+#define PFID(fid) \
+ (fid)->f_seq, \
+ (fid)->f_oid, \
+ (fid)->f_ver
+
+/* scanf input parse format -- strip '[' first.
+ e.g. sscanf(fidstr, SFID, RFID(&fid)); */
+#define SFID "0x%llx:0x%x:0x%x"
+#define RFID(fid) \
+ &((fid)->f_seq), \
+ &((fid)->f_oid), \
+ &((fid)->f_ver)
+
+
+/********* Quotas **********/
+
/* these must be explicitly translated into linux Q_* in ll_dir_ioctl */
#define LUSTRE_Q_QUOTAON 0x800002 /* turn quotas on */
#define LUSTRE_Q_QUOTAOFF 0x800003 /* turn quotas off */
while (*name == '[')
name++;
- sscanf(name, SFID, &(f->f_seq), &(f->f_oid),
- &(f->f_ver));
+ sscanf(name, SFID, RFID(f));
if (!fid_is_sane(f)) {
CWARN("bad FID format [%s], should be "DFID"\n", lname->ln_name,
(__u64)1, 2, 0);
static int lfs_path2fid(int argc, char **argv)
{
char *path;
- unsigned long long seq;
- unsigned long oid, ver;
+ lustre_fid fid;
int rc;
if (argc != 2)
return CMD_HELP;
path = argv[1];
- rc = llapi_path2fid(path, &seq, &oid, &ver);
+ rc = llapi_path2fid(path, &fid);
if (rc) {
fprintf(stderr, "can't get fid for %s: %s\n", path,
strerror(errno = -rc));
return rc;
}
- printf(DFID"\n", seq, (unsigned int)oid, (unsigned int)ver);
+ printf(DFID"\n", PFID(&fid));
return 0;
}
return rc;
}
-int llapi_fid2path(char *device, char *fidstr, char *buf, int buflen,
- long long *recno, int *linkno)
+int llapi_fid2path(const char *device, const char *fidstr, char *buf,
+ int buflen, long long *recno, int *linkno)
{
char path[PATH_MAX];
struct lu_fid fid;
while (*fidstr == '[')
fidstr++;
- sscanf(fidstr, "0x%llx:0x%x:0x%x", &(fid.f_seq), &(fid.f_oid),
- &(fid.f_ver));
+ sscanf(fidstr, SFID, RFID(&fid));
if (!fid_is_sane(&fid)) {
llapi_err(LLAPI_MSG_ERROR | LLAPI_MSG_NO_ERRNO,
"bad FID format [%s], should be "DFID"\n",
if (device[0] == '/') {
strcpy(path, device);
} else {
- rc = get_root_path(WANT_PATH, device, NULL, path);
+ rc = get_root_path(WANT_PATH, (char *)device, NULL, path);
if (rc < 0)
return rc;
}
return rc;
}
-int llapi_path2fid(const char *path, unsigned long long *seq,
- unsigned long *oid, unsigned long *ver)
+int llapi_path2fid(const char *path, lustre_fid *fid)
{
- struct lu_fid fid;
int fd, rc;
fd = open(path, O_RDONLY);
if (fd < 0)
return -errno;
- rc = ioctl(fd, LL_IOC_PATH2FID, &fid);
- *seq = fid_seq(&fid);
- *oid = fid_oid(&fid);
- *ver = fid_ver(&fid);
+ rc = ioctl(fd, LL_IOC_PATH2FID, fid);
close(fd);
return rc;