[bug report] ceph: quota: support for ceph.quota.max_files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Luis Henriques,

This is a semi-automatic email about new static checker warnings.

The patch b7a2921765cf: "ceph: quota: support for 
ceph.quota.max_files" from Jan 5, 2018, leads to the following Smatch 
complaint:

    fs/ceph/quota.c:240 check_quota_exceeded()
     error: we previously assumed 'realm' could be null (see line 188)

fs/ceph/quota.c
   187					   "null i_snap_realm\n", ceph_vinop(inode));
   188		while (realm) {
                       ^^^^^
Check for NULL.

   189			spin_lock(&realm->inodes_with_caps_lock);
   190			in = realm->inode ? igrab(realm->inode) : NULL;
   191			spin_unlock(&realm->inodes_with_caps_lock);
   192			if (!in)
   193				break;
   194	
   195			ci = ceph_inode(in);
   196			spin_lock(&ci->i_ceph_lock);
   197			if (op == QUOTA_CHECK_MAX_FILES_OP) {
   198				max = ci->i_max_files;
   199				rvalue = ci->i_rfiles + ci->i_rsubdirs;
   200			} else {
   201				max = ci->i_max_bytes;
   202				rvalue = ci->i_rbytes;
   203			}
   204			spin_unlock(&ci->i_ceph_lock);
   205			switch (op) {
   206			case QUOTA_CHECK_MAX_FILES_OP:
   207				exceeded = (max && (rvalue >= max));
   208				break;
   209			case QUOTA_CHECK_MAX_BYTES_OP:
   210				exceeded = (max && (rvalue + delta > max));
   211				break;
   212			case QUOTA_CHECK_MAX_BYTES_APPROACHING_OP:
   213				if (max) {
   214					if (rvalue >= max)
   215						exceeded = true;
   216					else {
   217						/*
   218						 * when we're writing more that 1/16th
   219						 * of the available space
   220						 */
   221						exceeded =
   222							(((max - rvalue) >> 4) < delta);
   223					}
   224				}
   225				break;
   226			default:
   227				/* Shouldn't happen */
   228				pr_warn("Invalid quota check op (%d)\n", op);
   229				exceeded = true; /* Just break the loop */
   230			}
   231			iput(in);
   232	
   233			next = realm->parent;
   234			if (exceeded || !next)
   235				break;
   236			ceph_get_snap_realm(mdsc, next);
   237			ceph_put_snap_realm(mdsc, realm);
   238			realm = next;
   239		}
   240		ceph_put_snap_realm(mdsc, realm);
                                          ^^^^^
Unchecked dereference inside function.

   241		up_read(&mdsc->snap_rwsem);
   242	

regards,
dan carpenter



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux