Bug 1201622 - Convert quota size from n-to-h order before using it
Summary: Convert quota size from n-to-h order before using it
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: GlusterFS
Classification: Community
Component: replicate
Version: 3.6.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Krutika Dhananjay
QA Contact:
URL:
Whiteboard:
Depends On: 1200670
Blocks: glusterfs-3.6.3
TreeView+ depends on / blocked
 
Reported: 2015-03-13 06:14 UTC by Krutika Dhananjay
Modified: 2016-02-04 15:21 UTC (History)
2 users (show)

Fixed In Version: glusterfs-v3.6.3
Doc Type: Bug Fix
Doc Text:
Clone Of: 1200670
Environment:
Last Closed: 2016-02-04 15:21:33 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Embargoed:


Attachments (Terms of Use)

Description Krutika Dhananjay 2015-03-13 06:14:27 UTC
+++ This bug was initially created as a clone of Bug #1200670 +++

Description of problem:

Figured while reading code that AFR is NOT converting quota_size value from network to host byte order before using it in comparisons towards getting the max size. This can cause problems with max_size calculation when the client is running on a little endian machine.

0 afr_handle_quota_size (call_frame_t *frame, xlator_t *this)                                                                                                                                                                                                                 
  1 {                                                                                
  2         unsigned char *readable = NULL;                                          
  3         afr_local_t *local = NULL;                                               
  4         afr_private_t *priv = NULL;                                              
  5         struct afr_reply *replies = NULL;                                        
  6         int i = 0;                                                               
  7         uint64_t size = 0;                                                       
  8         uint64_t max_size = 0;                                                   
  9         int readable_cnt = 0;                                                    
 10         int read_subvol = -1;                                                    
 11                                                                                  
 12         local = frame->local;                                                    
 13         priv = this->private;                                                    
 14         replies = local->replies;                                                
 15                                                                                  
 16         readable = alloca0 (priv->child_count);                                  
 17                                                                                  
 18         afr_inode_read_subvol_get (local->inode, this, readable, 0, 0);          
 19                                                                                  
 20         readable_cnt = AFR_COUNT (readable, priv->child_count);                  
 21                                                                                  
 22         for (i = 0; i < priv->child_count; i++) {                                
 23                 if (!replies[i].valid || replies[i].op_ret == -1)                
 24                         continue;                                                
 25                 if (readable_cnt && !readable[i])                                
 26                         continue;                                                
 27                 if (!replies[i].xdata)                                           
 28                         continue;                                                
 29                 if (dict_get_uint64 (replies[i].xdata, QUOTA_SIZE_KEY, &size))         <---------- here
 30                         continue;                                                
 32                 if (read_subvol == -1)                                           
 33                         read_subvol = i;                                         
 34                 if (size > max_size) {                                           
 35                         read_subvol = i;                                         
 36                         max_size = size;                                         
 37                 }                                                                
 38         }                                                                        
 39                                                                                  
 40         if (!max_size)                                                           
 41                 return read_subvol;                                              
 44                                                                                  
 45         for (i = 0; i < priv->child_count; i++) {                                
 46                 if (!replies[i].valid || replies[i].op_ret == -1)                
 47                         continue;                                                
 48                 if (readable_cnt && !readable[i])                                
 49                         continue;                                                
 50                 if (!replies[i].xdata)                                           
 51                         continue;                                                
 52                 if (dict_set_uint64 (replies[i].xdata, QUOTA_SIZE_KEY, max_size))       <------ and here
 53                         continue;                                                
 54         }                                                                        
 55                                                                                  
 56         return read_subvol;                                                      
 57 }                                                                  



Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

--- Additional comment from Anand Avati on 2015-03-11 02:58:22 EDT ---

REVIEW: http://review.gluster.org/9853 (cluster/afr: Convert quota size from n/w to host order before use) posted (#1) for review on master by Krutika Dhananjay (kdhananj)

--- Additional comment from Anand Avati on 2015-03-12 07:44:55 EDT ---

REVIEW: http://review.gluster.org/9853 (cluster/afr: Convert quota size from n/w to host order before use) posted (#2) for review on master by Krutika Dhananjay (kdhananj)

--- Additional comment from Anand Avati on 2015-03-13 02:02:04 EDT ---

COMMIT: http://review.gluster.org/9853 committed in master by Pranith Kumar Karampuri (pkarampu) 
------
commit 65c68fb75640be2c5744782081250dda886a7b56
Author: Krutika Dhananjay <kdhananj>
Date:   Tue Mar 10 22:11:57 2015 +0530

    cluster/afr: Convert quota size from n/w to host order before use
    
    Change-Id: I3e4fe15716556441546fcd62b8ac2833869b21cf
    BUG: 1200670
    Signed-off-by: Krutika Dhananjay <kdhananj>
    Reviewed-on: http://review.gluster.org/9853
    Reviewed-by: Ravishankar N <ravishankar>
    Reviewed-by: Anuradha Talur <atalur>
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Pranith Kumar Karampuri <pkarampu>
    Tested-by: Pranith Kumar Karampuri <pkarampu>

Comment 1 Anand Avati 2015-03-16 02:54:31 UTC
REVIEW: http://review.gluster.org/9884 (cluster/afr: Convert quota size from n/w to host order before use) posted (#1) for review on release-3.6 by Krutika Dhananjay (kdhananj)

Comment 2 Anand Avati 2015-03-16 09:45:47 UTC
COMMIT: http://review.gluster.org/9884 committed in release-3.6 by Raghavendra Bhat (raghavendra) 
------
commit b46bd7feadd77374ba3d40ac19e127b2073b51d5
Author: Krutika Dhananjay <kdhananj>
Date:   Tue Mar 10 22:11:57 2015 +0530

    cluster/afr: Convert quota size from n/w to host order before use
    
            Backport of: http://review.gluster.org/9853
    
    Change-Id: I83f1ab16a2dc54841e7beff3033333fba009b3a4
    BUG: 1201622
    Signed-off-by: Krutika Dhananjay <kdhananj>
    Reviewed-on: http://review.gluster.org/9884
    Reviewed-by: Ravishankar N <ravishankar>
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Anuradha Talur <atalur>
    Reviewed-by: Pranith Kumar Karampuri <pkarampu>
    Reviewed-by: Raghavendra Bhat <raghavendra>

Comment 3 Kaushal 2016-02-04 15:21:33 UTC
This bug is getting closed because a release has been made available that should address the reported issue. In case the problem is still not fixed with glusterfs-v3.6.3, please open a new bug report.

glusterfs-v3.6.3 has been announced on the Gluster mailinglists [1], packages for several distributions should become available in the near future. Keep an eye on the Gluster Users mailinglist [2] and the update infrastructure for your distribution.

[1] https://www.gluster.org/pipermail/gluster-users/2015-April/021669.html
[2] http://thread.gmane.org/gmane.comp.file-systems.gluster.user


Note You need to log in before you can comment on or make changes to this bug.