~ubuntu-branches/ubuntu/precise/ceph/precise

« back to all changes in this revision

Viewing changes to src/client/test_ioctls.c

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum, Clint Byrum, Micah Gersten
  • Date: 2011-02-12 22:50:26 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110212225026-yyyw4tk0msgql3ul
Tags: 0.24.2-0ubuntu1
[ Clint Byrum <clint@ubuntu.com> ]
* New upstream release. (LP: #658670, LP: #684011)
* debian/patches/fix-mkcephfs.patch: dropped (applied upstream)
* Removed .la files from libceph1-dev, libcrush1-dev and 
  librados1-dev (per Debian policy v3.9.1 10.2).
* debian/control: adding pkg-config as a build dependency
* debian/control: depend on libcrypto++-dev instead of libssl-dev
* debian/watch: added watch file

[ Micah Gersten <micahg@ubuntu.com> ]
* debian/control: add Homepage

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
#include <sys/types.h>
6
6
#include <sys/stat.h>
7
7
#include <fcntl.h>
 
8
#include <limits.h>
8
9
 
9
10
#include <sys/ioctl.h>
10
11
#include <netinet/in.h>
19
20
        int fd, err;
20
21
        struct ceph_ioctl_layout l;
21
22
        struct ceph_ioctl_dataloc dl;
 
23
        char new_file_name[PATH_MAX];
22
24
 
23
25
        if (argc < 3) {
24
26
                printf("usage: test_ioctls <filename> <offset>\n");
31
33
                perror("couldn't open file");
32
34
                return 1;
33
35
        }
 
36
 
 
37
        /* get layout */
 
38
        err = ioctl(fd, CEPH_IOC_GET_LAYOUT, (unsigned long)&l);
 
39
        if (err < 0) {
 
40
                perror("ioctl IOC_GET_LAYOUT error");
 
41
                return 1;
 
42
        }
 
43
        printf("layout:\n stripe_unit %lld\n stripe_count %lld\n object_size %lld\n data_pool %lld\n preferred osd %lld\n",
 
44
               (long long)l.stripe_unit, (long long)l.stripe_count, (long long)l.object_size, (long long)l.data_pool, (long long)l.preferred_osd);
 
45
 
 
46
 
 
47
        /* set layout */
 
48
        l.stripe_unit = 1048576;
 
49
        l.stripe_count = 2;
 
50
        err = ioctl(fd, CEPH_IOC_SET_LAYOUT, (unsigned long)&l);
 
51
        if (err < 0) {
 
52
               perror("ioctl IOC_SET_LAYOUT error");
 
53
               return 1;
 
54
        }
 
55
        printf("set layout, writing to file\n");
 
56
 
34
57
        printf("file %s\n", fn);
35
 
 
36
 
        /* get layout */
 
58
        /* get layout again */
37
59
        err = ioctl(fd, CEPH_IOC_GET_LAYOUT, (unsigned long)&l);
38
60
        if (err < 0) {
39
61
                perror("ioctl IOC_GET_LAYOUT error");
40
62
                return 1;
41
63
        }
42
 
        printf("layout:\n stripe_unit %lld\n stripe_count %lld\n object_size %lld\n data_pool %lld\npreferred osd %lld\n",
 
64
        printf("layout:\n stripe_unit %lld\n stripe_count %lld\n object_size %lld\n data_pool %lld\n preferred osd %lld\n",
43
65
               (long long)l.stripe_unit, (long long)l.stripe_count, (long long)l.object_size, (long long)l.data_pool, (long long)l.preferred_osd);
44
66
 
45
67
        /* dataloc */
61
83
        getnameinfo((struct sockaddr *)&dl.osd_addr, sizeof(dl.osd_addr), buf, sizeof(buf), 0, 0, NI_NUMERICHOST);
62
84
        printf(" osd%lld %s\n", (long long)dl.osd, buf);
63
85
 
64
 
        return 0;       
 
86
        if (argc < 4)
 
87
          return 0;
 
88
 
 
89
        /* set dir default layout */
 
90
        printf("testing dir policy setting\n");
 
91
        fd = open(argv[3], O_RDONLY);
 
92
        if (fd < 0) {
 
93
                perror("couldn't open dir");
 
94
                return 1;
 
95
        }
 
96
 
 
97
        l.object_size = 1048576;
 
98
        l.stripe_count = 1;
 
99
        err = ioctl(fd, CEPH_IOC_SET_LAYOUT_POLICY, (unsigned long)&l);
 
100
        if (err < 0) {
 
101
               perror("ioctl IOC_SET_LAYOUT_POLICY error");
 
102
               return 1;
 
103
        }
 
104
        printf("set layout, creating file\n");
 
105
 
 
106
        snprintf(new_file_name, sizeof(new_file_name),
 
107
                 "%s/testfile", argv[3]);
 
108
        fd = open(new_file_name, O_CREAT | O_RDWR, 0644);
 
109
        if (fd < 0) {
 
110
                perror("couldn't open file");
 
111
                return 1;
 
112
        }
 
113
        err = ioctl(fd, CEPH_IOC_GET_LAYOUT, (unsigned long)&l);
 
114
        if (err < 0) {
 
115
                perror("ioctl IOC_GET_LAYOUT error");
 
116
                return 1;
 
117
        }
 
118
        printf("layout:\n stripe_unit %lld\n stripe_count %lld\n object_size %lld\n data_pool %lld\n preferred osd %lld\n",
 
119
               (long long)l.stripe_unit, (long long)l.stripe_count, (long long)l.object_size, (long long)l.data_pool, (long long)l.preferred_osd);
 
120
        return 0;
65
121
}