From: yury Date: Fri, 25 Mar 2005 13:44:27 +0000 (+0000) Subject: - fixed ability of ret_mode being used uninitialized in mds_lock_mode_for_dir() X-Git-Tag: 1.3.4~33 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=7944f98f6b3f681c014d483b93541946dff4838b;p=fs%2Flustre-release.git - fixed ability of ret_mode being used uninitialized in mds_lock_mode_for_dir() d=84 --- diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index f0e837f..d328fd1 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -160,7 +160,7 @@ static int mds_sendpage(struct ptlrpc_request *req, struct file *file, int mds_lock_mode_for_dir(struct obd_device *obd, struct dentry *dentry, int mode) { - int ret_mode, split; + int ret_mode = 0, split; /* any dir access needs couple locks: * 1) on part of dir we gonna lookup/modify in @@ -192,21 +192,21 @@ int mds_lock_mode_for_dir(struct obd_device *obd, * this inode won't be splitted. so we need not to protect from * just flush client's cache on modification. */ - ret_mode = 0; if (mode == LCK_PW) ret_mode = LCK_CW; + else + ret_mode = 0; } else { - if (mode == LCK_EX) - return LCK_EX; - - if (mode == LCK_PR) { + if (mode == LCK_EX) { + ret_mode = LCK_EX; + } else if (mode == LCK_PR) { ret_mode = LCK_CR; } else if (mode == LCK_PW) { /* - * caller gonna modify directory.we use concurrent write - * lock here to retract client's cache for readdir. + * caller gonna modify directory. We use concurrent + * write lock here to retract client's cache for + * readdir. */ - ret_mode = LCK_CW; if (split == MDS_EXPECT_SPLIT) { /* * splitting possible. serialize any access the @@ -221,6 +221,8 @@ int mds_lock_mode_for_dir(struct obd_device *obd, (unsigned long)dentry->d_inode->i_ino, (unsigned long)dentry->d_inode->i_generation); ret_mode = LCK_EX; + } else { + ret_mode = LCK_CW; } } }