From: pschwan Date: Fri, 4 Oct 2002 21:32:56 +0000 (+0000) Subject: - Make lustre_lite.h userspace-include-safe X-Git-Tag: v1_7_100~4594 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=7a8a38eba98e14c5ac15a2b287841e992a1c1691;p=fs%2Flustre-release.git - Make lustre_lite.h userspace-include-safe - Make openclose.c do an ioctl a-la IOR for more testing --- diff --git a/lustre/include/linux/lustre_lite.h b/lustre/include/linux/lustre_lite.h index cee1737..8a1bc82 100644 --- a/lustre/include/linux/lustre_lite.h +++ b/lustre/include/linux/lustre_lite.h @@ -14,6 +14,8 @@ #ifndef _LL_H #define _LL_H +#ifdef __KERNEL__ + #include #include @@ -36,12 +38,6 @@ struct ll_read_inode2_cookie { struct lov_mds_md *lic_lmm; }; -#define LL_IOC_GETFLAGS _IOR ('f', 151, long) -#define LL_IOC_SETFLAGS _IOW ('f', 152, long) -#define LL_IOC_CLRFLAGS _IOW ('f', 153, long) - -#define LL_FILE_IGNORE_LOCK 0x00000001 - #define LL_INLINESZ 60 struct ll_inode_info { struct lov_stripe_md *lli_smd; @@ -77,10 +73,10 @@ struct ll_sb_info { __u32 ll_mount_epoch; }; -#define CHECK_MOUNT_EPOCH(i) \ -do { \ - if (ll_i2info(i)->lli_mount_epoch != ll_i2sbi(i)->ll_mount_epoch) \ - RETURN(-EIO); \ +#define CHECK_MOUNT_EPOCH(i) \ +do { \ + if (ll_i2info(i)->lli_mount_epoch != ll_i2sbi(i)->ll_mount_epoch) \ + RETURN(-EIO); \ } while(0) static inline struct ll_sb_info *ll_s2sbi(struct super_block *sb) @@ -180,4 +176,12 @@ extern struct inode_operations ll_symlink_inode_operations; void ll_sysctl_init(void); void ll_sysctl_clean(void); +#endif /* __KERNEL__ */ + +#define LL_IOC_GETFLAGS _IOR ('f', 151, long) +#define LL_IOC_SETFLAGS _IOW ('f', 152, long) +#define LL_IOC_CLRFLAGS _IOW ('f', 153, long) + +#define LL_FILE_IGNORE_LOCK 0x00000001 + #endif diff --git a/lustre/tests/openclose.c b/lustre/tests/openclose.c index 4fbae47..53bd20e 100644 --- a/lustre/tests/openclose.c +++ b/lustre/tests/openclose.c @@ -1,3 +1,7 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + */ + #include #include #include @@ -7,29 +11,32 @@ #include #include #include +#include + +#include #ifndef O_DIRECT -#define O_DIRECT 040000 /* direct disk access hint */ +# define O_DIRECT 040000 /* direct disk access hint */ #endif int main(int argc, char *argv[]) { char filename[1024]; unsigned long count, i; - int thread = 0; - int threads = 0; - int rc; - int fd; + int thread = 0; + int threads = 0; + int rc; + int fd, ioctl_flags = 0; if (argc < 3 || argc > 4) { fprintf(stderr, "usage: %s [threads]\n", - argv[0]); + argv[0]); exit(1); } count = strtoul(argv[2], NULL, 0); - if (argc == 4) - threads = strtoul(argv[3], NULL, 0); + if (argc == 4) + threads = strtoul(argv[3], NULL, 0); for (i = 1; i <= threads; i++) { rc = fork(); @@ -47,7 +54,7 @@ int main(int argc, char *argv[]) rc = 0; } - if (threads && thread == 0) { /* parent process */ + if (threads && thread == 0) { /* parent process */ int live_threads = threads; while (live_threads > 0) { @@ -82,49 +89,55 @@ int main(int argc, char *argv[]) live_threads--; } } - } else { - if (threads) - sprintf(filename, "%s-%d", argv[1], thread); - else - strcpy(filename, argv[1]); + } else { + if (threads) + sprintf(filename, "%s-%d", argv[1], thread); + else + strcpy(filename, argv[1]); - fd = open(filename, O_RDWR|O_CREAT, 0644); - if (fd < 0) { - fprintf(stderr, "open(%s, O_CREAT): %s\n", filename, - strerror(errno)); - exit(errno); - } - if (close(fd) < 0) { - fprintf(stderr, "close(): %s\n", strerror(errno)); - rc = errno; - goto unlink; - } + fd = open(filename, O_RDWR|O_CREAT, 0644); + if (fd < 0) { + fprintf(stderr, "open(%s, O_CREAT): %s\n", filename, + strerror(errno)); + exit(errno); + } + if (close(fd) < 0) { + fprintf(stderr, "close(): %s\n", strerror(errno)); + rc = errno; + goto unlink; + } - for (i = 0; i < count; i++) { - fd = open(filename, O_RDWR|O_LARGEFILE|O_DIRECT); - if (fd < 0) { - fprintf(stderr, "open(%s, O_RDWR): %s\n", - filename, strerror(errno)); - rc = errno; - break; - } - if (close(fd) < 0) { - fprintf(stderr, "close(): %s\n", - strerror(errno)); - rc = errno; - break; - } - } - unlink: - if (unlink(filename) < 0) { - fprintf(stderr, "unlink(%s): %s\n", filename, - strerror(errno)); - rc = errno; - } - if (threads) - printf("Thread %d done: rc = %d\n", thread, rc); - else - printf("Done: rc = %d\n", rc); - } + for (i = 0; i < count; i++) { + fd = open(filename, O_RDWR|O_LARGEFILE|O_DIRECT); + if (fd < 0) { + fprintf(stderr, "open(%s, O_RDWR): %s\n", + filename, strerror(errno)); + rc = errno; + break; + } + if (ioctl(fd, LL_IOC_SETFLAGS, &ioctl_flags) < 0) { + fprintf(stderr, "ioctl(): %s\n", + strerror(errno)); + rc = errno; + break; + } + if (close(fd) < 0) { + fprintf(stderr, "close(): %s\n", + strerror(errno)); + rc = errno; + break; + } + } + unlink: + if (unlink(filename) < 0) { + fprintf(stderr, "unlink(%s): %s\n", filename, + strerror(errno)); + rc = errno; + } + if (threads) + printf("Thread %d done: rc = %d\n", thread, rc); + else + printf("Done: rc = %d\n", rc); + } return rc; }