~ubuntu-branches/ubuntu/trusty/glusterfs/trusty

« back to all changes in this revision

Viewing changes to xlators/cluster/dht/src/dht-diskusage.c

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Matthäi
  • Date: 2010-02-09 18:53:10 UTC
  • mfrom: (1.2.4 upstream) (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100209185310-ww8p82lsbosorg2u
* New upstream release.
* Uploading to unstable.
* Bump Standards-Version to 3.8.4 (no changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
        int            this_call_cnt = 0;
44
44
        int            i = 0;
45
45
        double         percent = 0;
 
46
        uint64_t       bytes = 0;
46
47
 
47
48
        local = frame->local;
48
49
        conf = this->private;
51
52
        if (op_ret == -1) 
52
53
                goto out;
53
54
 
54
 
        if (statvfs && statvfs->f_blocks)
 
55
        if (statvfs && statvfs->f_blocks) {
55
56
                percent = (statvfs->f_bfree * 100) / statvfs->f_blocks;
 
57
                bytes = (statvfs->f_bfree * statvfs->f_bsize);
 
58
        }
56
59
        
57
60
        LOCK (&conf->subvolume_lock);
58
61
        {
59
62
                for (i = 0; i < conf->subvolume_cnt; i++)
60
 
                        if (prev->this == conf->subvolumes[i])
 
63
                        if (prev->this == conf->subvolumes[i]) {
61
64
                                conf->du_stats[i].avail_percent = percent;
 
65
                                conf->du_stats[i].avail_space   = bytes;
 
66
                                gf_log (this->name, GF_LOG_DEBUG,
 
67
                                        "on subvolume '%s': avail_percent is: "
 
68
                                        "%.2f and avail_space is: %"PRIu64"",
 
69
                                        prev->this->name, 
 
70
                                        conf->du_stats[i].avail_percent,
 
71
                                        conf->du_stats[i].avail_space);
 
72
                        }
62
73
        }
63
74
        UNLOCK (&conf->subvolume_lock);
64
75
 
175
186
 
176
187
        conf = this->private;
177
188
 
178
 
        /* Check for values above 90% free disk */
 
189
        /* Check for values above specified percent or free disk */
179
190
        LOCK (&conf->subvolume_lock);
180
191
        {
181
192
                for (i = 0; i < conf->subvolume_cnt; i++) {
182
 
                        if ((subvol == conf->subvolumes[i]) &&
183
 
                            (conf->du_stats[i].avail_percent < 
184
 
                             conf->min_free_disk)) {
185
 
                                subvol_filled = 1;
186
 
                                break;
 
193
                        if (subvol == conf->subvolumes[i]) {
 
194
                                if (conf->disk_unit == 'p') {
 
195
                                        if (conf->du_stats[i].avail_percent <
 
196
                                            conf->min_free_disk) {
 
197
                                                subvol_filled = 1;
 
198
                                                break;
 
199
                                        }
 
200
                                } else {
 
201
                                        if (conf->du_stats[i].avail_space <
 
202
                                            conf->min_free_disk) {
 
203
                                                subvol_filled = 1;
 
204
                                                break;
 
205
                                        }
 
206
                                }
187
207
                        }
188
208
                }
189
209
        }
190
210
        UNLOCK (&conf->subvolume_lock);
191
211
 
192
212
        if (subvol_filled) {
193
 
                if (!(conf->du_stats[i].log++ % GF_UNIVERSAL_ANSWER)) {
 
213
                if (!(conf->du_stats[i].log++ % (GF_UNIVERSAL_ANSWER * 10))) {
194
214
                        gf_log (this->name, GF_LOG_WARNING,
195
215
                                "disk space on subvolume '%s' is getting "
196
216
                                "full (%.2f %%), consider adding more nodes", 
206
226
dht_free_disk_available_subvol (xlator_t *this, xlator_t *subvol) 
207
227
{
208
228
        int         i = 0;
209
 
        double      max_avail = 0;
 
229
        double      max= 0;
210
230
        xlator_t   *avail_subvol = NULL;
211
231
        dht_conf_t *conf = NULL;
212
232
 
216
236
        LOCK (&conf->subvolume_lock);
217
237
        {
218
238
                for (i = 0; i < conf->subvolume_cnt; i++) {
219
 
                        if (conf->du_stats[i].avail_percent > max_avail) {
220
 
                                max_avail  = conf->du_stats[i].avail_percent;
221
 
                                avail_subvol = conf->subvolumes[i];
 
239
                        if (conf->disk_unit == 'p') {
 
240
                                if (conf->du_stats[i].avail_percent > max) {
 
241
                                        max = conf->du_stats[i].avail_percent;
 
242
                                        avail_subvol = conf->subvolumes[i];
 
243
                                }
 
244
                        } else {
 
245
                                if (conf->du_stats[i].avail_space > max) {
 
246
                                        max = conf->du_stats[i].avail_space;
 
247
                                        avail_subvol = conf->subvolumes[i];
 
248
                                }
222
249
                        }
223
250
                }
224
251
        }
225
252
        UNLOCK (&conf->subvolume_lock);
226
253
 
227
 
        if (max_avail < conf->min_free_disk)
 
254
        if (max < conf->min_free_disk)
228
255
                avail_subvol = subvol;
229
256
 
230
257
        if (avail_subvol == subvol) {