ceph: specify max_bytes on readdir replies
authorSage Weil <sage@newdream.net>
Fri, 14 May 2010 20:06:30 +0000 (13:06 -0700)
committerSage Weil <sage@newdream.net>
Mon, 17 May 2010 22:25:41 +0000 (15:25 -0700)
Specify max bytes in request to bound size of reply.  Add associated
mount option with default value of 512 KB.

Signed-off-by: Sage Weil <sage@newdream.net>
fs/ceph/ceph_fs.h
fs/ceph/dir.c
fs/ceph/super.c
fs/ceph/super.h

index 715e39ce517a797f0d800a48e65ca51a7141b34d..3b9eeed097b3965c7b2eb0b5c176aa19249d1949 100644 (file)
@@ -361,6 +361,7 @@ union ceph_mds_request_args {
        struct {
                __le32 frag;                 /* which dir fragment */
                __le32 max_entries;          /* how many dentries to grab */
+               __le32 max_bytes;
        } __attribute__ ((packed)) readdir;
        struct {
                __le32 mode;
index d3bb8132a1aac021a04623a249c4290f7f83eff9..4fd30900eff7f7cc17e92c6ecfc962547aa7f343 100644 (file)
@@ -233,6 +233,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
        u32 ftype;
        struct ceph_mds_reply_info_parsed *rinfo;
        const int max_entries = client->mount_args->max_readdir;
+       const int max_bytes = client->mount_args->max_readdir_bytes;
 
        dout("readdir %p filp %p frag %u off %u\n", inode, filp, frag, off);
        if (fi->at_end)
@@ -316,6 +317,7 @@ more:
                req->r_readdir_offset = fi->next_offset;
                req->r_args.readdir.frag = cpu_to_le32(frag);
                req->r_args.readdir.max_entries = cpu_to_le32(max_entries);
+               req->r_args.readdir.max_bytes = cpu_to_le32(max_bytes);
                req->r_num_caps = max_entries + 1;
                err = ceph_mdsc_do_request(mdsc, NULL, req);
                if (err < 0) {
index 7f5b20dc4945ec18421dab323ff390c5cd7603e1..bac13898b943850af62374454cdd388b1a24d204 100644 (file)
@@ -190,6 +190,8 @@ static int ceph_show_options(struct seq_file *m, struct vfsmount *mnt)
                           args->cap_release_safety);
        if (args->max_readdir != CEPH_MAX_READDIR_DEFAULT)
                seq_printf(m, ",readdir_max_entries=%d", args->max_readdir);
+       if (args->max_readdir_bytes != CEPH_MAX_READDIR_BYTES_DEFAULT)
+               seq_printf(m, ",readdir_max_bytes=%d", args->max_readdir_bytes);
        if (strcmp(args->snapdir_name, CEPH_SNAPDIRNAME_DEFAULT))
                seq_printf(m, ",snapdirname=%s", args->snapdir_name);
        if (args->name)
@@ -333,6 +335,7 @@ enum {
        Opt_caps_wanted_delay_max,
        Opt_cap_release_safety,
        Opt_readdir_max_entries,
+       Opt_readdir_max_bytes,
        Opt_congestion_kb,
        Opt_last_int,
        /* int args above */
@@ -365,6 +368,7 @@ static match_table_t arg_tokens = {
        {Opt_caps_wanted_delay_max, "caps_wanted_delay_max=%d"},
        {Opt_cap_release_safety, "cap_release_safety=%d"},
        {Opt_readdir_max_entries, "readdir_max_entries=%d"},
+       {Opt_readdir_max_bytes, "readdir_max_bytes=%d"},
        {Opt_congestion_kb, "write_congestion_kb=%d"},
        /* int args above */
        {Opt_snapdirname, "snapdirname=%s"},
@@ -415,6 +419,7 @@ static struct ceph_mount_args *parse_mount_args(int flags, char *options,
        args->snapdir_name = kstrdup(CEPH_SNAPDIRNAME_DEFAULT, GFP_KERNEL);
        args->cap_release_safety = CEPH_CAP_RELEASE_SAFETY_DEFAULT;
        args->max_readdir = CEPH_MAX_READDIR_DEFAULT;
+       args->max_readdir_bytes = CEPH_MAX_READDIR_BYTES_DEFAULT;
        args->congestion_kb = default_congestion_kb();
 
        /* ip1[:port1][,ip2[:port2]...]:/subdir/in/fs */
@@ -522,6 +527,9 @@ static struct ceph_mount_args *parse_mount_args(int flags, char *options,
                case Opt_readdir_max_entries:
                        args->max_readdir = intval;
                        break;
+               case Opt_readdir_max_bytes:
+                       args->max_readdir_bytes = intval;
+                       break;
                case Opt_congestion_kb:
                        args->congestion_kb = intval;
                        break;
index 395adc5fcebb5645699307a9a60008c8a86c51ba..3725c9ee9d08427181410189de6f866e6e05a118 100644 (file)
@@ -66,7 +66,8 @@ struct ceph_mount_args {
        int congestion_kb;    /* max writeback in flight */
        int caps_wanted_delay_min, caps_wanted_delay_max;
        int cap_release_safety;
-       int max_readdir;      /* max readdir size */
+       int max_readdir;       /* max readdir result (entires) */
+       int max_readdir_bytes; /* max readdir result (bytes) */
        char *snapdir_name;   /* default ".snap" */
        char *name;
        char *secret;
@@ -81,6 +82,7 @@ struct ceph_mount_args {
 #define CEPH_OSD_IDLE_TTL_DEFAULT    60
 #define CEPH_MOUNT_RSIZE_DEFAULT    (512*1024) /* readahead */
 #define CEPH_MAX_READDIR_DEFAULT    1024
+#define CEPH_MAX_READDIR_BYTES_DEFAULT    (512*1024)
 
 #define CEPH_MSG_MAX_FRONT_LEN (16*1024*1024)
 #define CEPH_MSG_MAX_DATA_LEN  (16*1024*1024)